Skip to content

Commit 481d812

Browse files
committed
Merge branch 'main' into jason/document-examples
2 parents 8c6d00a + b5642eb commit 481d812

File tree

67 files changed

+1129
-358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1129
-358
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.4.26"
2+
".": "0.5.0"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 34
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-c34c0577d9716c22554633ecb41d091675248d1385e9d1cc7c19479d55b56cb1.yml
3-
openapi_spec_hash: 3daaeab87b12b271ba2ee39e7dc166f2
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-2b422fbf02ff3b77795fb8c71cbe784de3a3add48560655ba4fe7f3fcc509995.yml
3+
openapi_spec_hash: bca5c04d823694c87417dae188480291
44
config_hash: 6481ea6b42040f435dedcb00a98f35f8

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## 0.5.0 (2025-10-28)
4+
5+
Full Changelog: [v0.4.28...v0.5.0](https://github.com/scaleapi/agentex-python/compare/v0.4.28...v0.5.0)
6+
7+
### Features
8+
9+
* **api:** api update ([129fae6](https://github.com/scaleapi/agentex-python/commit/129fae69844e655b5dd02b6f67c44d15f5dbfa93))
10+
11+
## 0.4.28 (2025-10-28)
12+
13+
Full Changelog: [v0.4.27...v0.4.28](https://github.com/scaleapi/agentex-python/compare/v0.4.27...v0.4.28)
14+
15+
## 0.4.27 (2025-10-27)
16+
17+
Full Changelog: [v0.4.26...v0.4.27](https://github.com/scaleapi/agentex-python/compare/v0.4.26...v0.4.27)
18+
19+
### Features
20+
21+
* **api:** api update ([f5e4fd2](https://github.com/scaleapi/agentex-python/commit/f5e4fd2f2fbb2c7e67e51795fba1f0b2e13048de))
22+
323
## 0.4.26 (2025-10-21)
424

525
Full Changelog: [v0.4.25...v0.4.26](https://github.com/scaleapi/agentex-python/compare/v0.4.25...v0.4.26)

api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ Methods:
4343
Types:
4444

4545
```python
46-
from agentex.types import Task, TaskListResponse
46+
from agentex.types import Task, TaskRetrieveResponse, TaskListResponse, TaskRetrieveByNameResponse
4747
```
4848

4949
Methods:
5050

51-
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/agentex/resources/tasks.py">retrieve</a>(task_id) -> <a href="./src/agentex/types/task.py">Task</a></code>
51+
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/agentex/resources/tasks.py">retrieve</a>(task_id, \*\*<a href="src/agentex/types/task_retrieve_params.py">params</a>) -> <a href="./src/agentex/types/task_retrieve_response.py">TaskRetrieveResponse</a></code>
5252
- <code title="get /tasks">client.tasks.<a href="./src/agentex/resources/tasks.py">list</a>(\*\*<a href="src/agentex/types/task_list_params.py">params</a>) -> <a href="./src/agentex/types/task_list_response.py">TaskListResponse</a></code>
5353
- <code title="delete /tasks/{task_id}">client.tasks.<a href="./src/agentex/resources/tasks.py">delete</a>(task_id) -> <a href="./src/agentex/types/shared/delete_response.py">DeleteResponse</a></code>
5454
- <code title="delete /tasks/name/{task_name}">client.tasks.<a href="./src/agentex/resources/tasks.py">delete_by_name</a>(task_name) -> <a href="./src/agentex/types/shared/delete_response.py">DeleteResponse</a></code>
55-
- <code title="get /tasks/name/{task_name}">client.tasks.<a href="./src/agentex/resources/tasks.py">retrieve_by_name</a>(task_name) -> <a href="./src/agentex/types/task.py">Task</a></code>
55+
- <code title="get /tasks/name/{task_name}">client.tasks.<a href="./src/agentex/resources/tasks.py">retrieve_by_name</a>(task_name, \*\*<a href="src/agentex/types/task_retrieve_by_name_params.py">params</a>) -> <a href="./src/agentex/types/task_retrieve_by_name_response.py">TaskRetrieveByNameResponse</a></code>
5656
- <code title="get /tasks/{task_id}/stream">client.tasks.<a href="./src/agentex/resources/tasks.py">stream_events</a>(task_id) -> object</code>
5757
- <code title="get /tasks/name/{task_name}/stream">client.tasks.<a href="./src/agentex/resources/tasks.py">stream_events_by_name</a>(task_name) -> object</code>
5858

examples/tutorials/00_sync/000_hello_acp/tests/test_agent.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
"""
1818

1919
import os
20-
from agentex.types import TextContentParam, TextDelta, TextContent
21-
from agentex.types.agent_rpc_params import ParamsSendMessageRequest
22-
from agentex.types.task_message_update import StreamTaskMessageDelta, StreamTaskMessageFull
20+
2321
import pytest
24-
from agentex import Agentex
2522

23+
from agentex import Agentex
24+
from agentex.types import TextDelta, TextContent, TextContentParam
25+
from agentex.types.agent_rpc_params import ParamsSendMessageRequest
26+
from agentex.types.task_message_update import StreamTaskMessageFull, StreamTaskMessageDelta
2627

2728
# Configuration from environment variables
2829
AGENTEX_API_BASE_URL = os.environ.get("AGENTEX_API_BASE_URL", "http://localhost:5003")

examples/tutorials/00_sync/010_multiturn/project/acp.py

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import os
22
from typing import Union, AsyncGenerator
33

4+
from agents import Agent, Runner, RunConfig
5+
46
from agentex.lib import adk
7+
from agentex.types import TextContent
58
from agentex.lib.types.acp import SendMessageParams
9+
from agentex.lib.types.converters import convert_task_messages_to_oai_agents_inputs
610
from agentex.lib.utils.model_utils import BaseModel
7-
from agentex.lib.types.llm_messages import LLMConfig, UserMessage, SystemMessage, AssistantMessage
811
from agentex.lib.sdk.fastacp.fastacp import FastACP
912
from agentex.types.task_message_update import TaskMessageUpdate
1013
from agentex.types.task_message_content import TaskMessageContent
11-
from agentex.types import TextContent
14+
from agentex.lib.adk.providers._modules.sync_provider import SyncStreamingProvider
1215

1316
# Create an ACP server
1417
acp = FastACP.create(
@@ -66,21 +69,27 @@ async def handle_message_send(
6669
task_messages = await adk.messages.list(task_id=params.task.id)
6770

6871
#########################################################
69-
# 3. Convert task messages to LLM messages.
72+
# 3. Run the agent with OpenAI Agents SDK
7073
#########################################################
7174

72-
# This might seem duplicative, but the split between TaskMessage and LLMMessage is intentional and important.
75+
# Initialize the provider and run config to allow for tracing
76+
provider = SyncStreamingProvider(
77+
trace_id=params.task.id,
78+
)
79+
80+
run_config = RunConfig(
81+
model_provider=provider,
82+
)
83+
84+
# Initialize the agent
85+
test_agent = Agent(name="assistant", instructions=state.system_prompt, model=state.model)
86+
87+
# Convert task messages to OpenAI Agents SDK format
88+
input_list = convert_task_messages_to_oai_agents_inputs(task_messages)
89+
90+
# Run the agent
91+
result = await Runner.run(test_agent, input_list, run_config=run_config)
7392

74-
llm_messages = [
75-
SystemMessage(content=state.system_prompt),
76-
*[
77-
UserMessage(content=getattr(message.content, "content", ""))
78-
if getattr(message.content, "author", None) == "user"
79-
else AssistantMessage(content=getattr(message.content, "content", ""))
80-
for message in task_messages
81-
if getattr(message.content, "type", None) == "text"
82-
],
83-
]
8493

8594
# TaskMessages are messages that are sent between an Agent and a Client. They are fundamentally decoupled from messages sent to the LLM. This is because you may want to send additional metadata to allow the client to render the message on the UI differently.
8695

@@ -94,25 +103,7 @@ async def handle_message_send(
94103
# - If using multiple LLMs, but one LLM's output should not be sent to the user (i.e. a critic model), you can leverage the State as an internal storage mechanism to store the critic model's conversation history. This i s a powerful and flexible way to handle complex scenarios.
95104

96105
#########################################################
97-
# 4. Call an LLM to respond to the user's message.
106+
# 4. Return the agent response to the client.
98107
#########################################################
99108

100-
# Call an LLM to respond to the user's message
101-
chat_completion = await adk.providers.litellm.chat_completion(
102-
llm_config=LLMConfig(model=state.model, messages=llm_messages),
103-
trace_id=params.task.id,
104-
)
105-
106-
#########################################################
107-
# 5. Return the agent response to the client.
108-
#########################################################
109-
110-
# The Agentex server automatically commits input and output messages to the database so you don't need to do this yourself, simply process the input content and return the output content.
111-
112-
# Return the agent response to the client
113-
if chat_completion.choices[0].message:
114-
content_str = chat_completion.choices[0].message.content or ""
115-
else:
116-
content_str = ""
117-
118-
return TextContent(author="agent", content=content_str)
109+
return TextContent(author="agent", content=result.final_output)

examples/tutorials/00_sync/010_multiturn/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "An AgentEx agent"
99
readme = "README.md"
1010
requires-python = ">=3.12"
1111
dependencies = [
12-
"agentex-sdk",
12+
"agentex-sdk==0.4.28",
1313
"scale-gp",
1414
]
1515

examples/tutorials/00_sync/010_multiturn/tests/test_agent.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@
1616
- AGENT_NAME: Name of the agent to test (default: s010-multiturn)
1717
"""
1818

19-
import enum
2019
import os
2120

22-
from agentex.lib.sdk.fastacp.base.base_acp_server import uuid
23-
from agentex.lib.types.acp import SendMessageParams
24-
25-
from test_utils.sync import collect_streaming_response, validate_text_in_string
26-
27-
from agentex.types import TaskMessageContentParam, TextContent, TextContentParam, task_list_params
28-
from agentex.types.agent_rpc_params import ParamsCreateTaskRequest, ParamsSendMessageRequest
2921
import pytest
30-
from agentex import Agentex
22+
from test_utils.sync import validate_text_in_string, collect_streaming_response
3123

24+
from agentex import Agentex
25+
from agentex.types import TextContent, TextContentParam
26+
from agentex.types.agent_rpc_params import ParamsCreateTaskRequest, ParamsSendMessageRequest
27+
from agentex.lib.sdk.fastacp.base.base_acp_server import uuid
3228

3329
# Configuration from environment variables
3430
AGENTEX_API_BASE_URL = os.environ.get("AGENTEX_API_BASE_URL", "http://localhost:5003")

examples/tutorials/00_sync/020_streaming/project/acp.py

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import os
22
from typing import Union, AsyncGenerator
33

4+
from agents import Agent, Runner, RunConfig
5+
46
from agentex.lib import adk
57
from agentex.lib.types.acp import SendMessageParams
8+
from agentex.lib.types.converters import convert_task_messages_to_oai_agents_inputs
69
from agentex.lib.utils.model_utils import BaseModel
7-
from agentex.lib.types.llm_messages import LLMConfig, UserMessage, SystemMessage, AssistantMessage
810
from agentex.lib.sdk.fastacp.fastacp import FastACP
9-
from agentex.types.task_message_delta import TextDelta
10-
from agentex.types.task_message_update import (
11-
TaskMessageUpdate,
12-
StreamTaskMessageDone,
13-
StreamTaskMessageFull,
14-
StreamTaskMessageDelta,
15-
)
11+
from agentex.types.task_message_update import TaskMessageUpdate, StreamTaskMessageFull
1612
from agentex.types.task_message_content import TextContent, TaskMessageContent
13+
from agentex.lib.adk.providers._modules.sync_provider import (
14+
SyncStreamingProvider,
15+
convert_openai_to_agentex_events,
16+
)
1717

1818
# Create an ACP server
1919
acp = FastACP.create(
@@ -69,40 +69,35 @@ async def handle_message_send(
6969

7070
task_messages = await adk.messages.list(task_id=params.task.id)
7171

72-
llm_messages = [
73-
SystemMessage(content=state.system_prompt),
74-
*[
75-
UserMessage(content=getattr(message.content, "content", ""))
76-
if getattr(message.content, "author", None) == "user"
77-
else AssistantMessage(content=getattr(message.content, "content", ""))
78-
for message in task_messages
79-
if message.content and getattr(message.content, "type", None) == "text"
80-
],
81-
]
8272

83-
#########################################################
84-
# 4. Call an LLM to respond to the user's message and stream the response to the client.
85-
#########################################################
73+
# Initialize the provider and run config to allow for tracing
74+
provider = SyncStreamingProvider(
75+
trace_id=params.task.id,
76+
)
8677

87-
# Call an LLM to respond to the user's message
78+
# Initialize the run config to allow for tracing and streaming
79+
run_config = RunConfig(
80+
model_provider=provider,
81+
)
8882

89-
print(f"Calling LLM with model {state.model} and messages {llm_messages}")
9083

91-
# The Agentex server automatically commits input and output messages to the database so you don't need to do this yourself, simply process the input content and return the output content.
84+
test_agent = Agent(name="assistant", instructions=state.system_prompt, model=state.model)
85+
86+
# Convert task messages to OpenAI Agents SDK format
87+
input_list = convert_task_messages_to_oai_agents_inputs(task_messages)
88+
89+
# Run the agent and stream the events
90+
result = Runner.run_streamed(test_agent, input_list, run_config=run_config)
91+
92+
93+
#########################################################
94+
# 4. Stream the events to the client.
95+
#########################################################
96+
# Convert the OpenAI events to Agentex events
97+
# This is done by converting the OpenAI events to Agentex events and yielding them to the client
98+
stream = result.stream_events()
99+
100+
# Yield the Agentex events to the client
101+
async for agentex_event in convert_openai_to_agentex_events(stream):
102+
yield agentex_event
92103

93-
message_index = 0
94-
async for chunk in adk.providers.litellm.chat_completion_stream(
95-
llm_config=LLMConfig(model=state.model, messages=llm_messages, stream=True),
96-
trace_id=params.task.id,
97-
):
98-
if chunk and chunk.choices and chunk.choices[0].delta and chunk.choices[0].delta.content:
99-
yield StreamTaskMessageDelta(
100-
type="delta",
101-
index=message_index,
102-
delta=TextDelta(type="text", text_delta=chunk.choices[0].delta.content or ""),
103-
)
104-
105-
yield StreamTaskMessageDone(
106-
type="done",
107-
index=message_index,
108-
)

examples/tutorials/00_sync/020_streaming/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "An AgentEx agent that does multiturn streaming chat"
99
readme = "README.md"
1010
requires-python = ">=3.12"
1111
dependencies = [
12-
"agentex-sdk",
12+
"agentex-sdk==0.4.28",
1313
"scale-gp",
1414
]
1515

0 commit comments

Comments
 (0)