Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.4"
".": "0.1.0-alpha.5"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 34
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-021b55c88964b7a5bfc9d692d32a52c6b0150445656d2407c4cb8e9dd1e5f100.yml
openapi_spec_hash: ed92c0d5d6bed9cb5617f8a776ac42c9
config_hash: 7661726e3cccf9f6349179841153601d
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp%2Fagentex-sdk-1d08fb2290b5310c91801d7575d356628d372fd5434e15d3b9cead48eadb893f.yml
openapi_spec_hash: c07c588fb8429fbf024189df62f20fa4
config_hash: 2e4b423af3db79ebd8170c401ea9093a
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 0.1.0-alpha.5 (2025-07-23)

Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/scaleapi/agentex-python/compare/v0.1.0-alpha.4...v0.1.0-alpha.5)

### Features

* **api:** deprecate name subresource ([14881c0](https://github.com/scaleapi/agentex-python/commit/14881c0ff2922e0a622975a0f5b314de99d7aabb))
* **api:** manual updates ([d999a43](https://github.com/scaleapi/agentex-python/commit/d999a438c409f04b7e36b5df2d9b080d1d1b0e4a))
* **api:** manual updates ([a885d8d](https://github.com/scaleapi/agentex-python/commit/a885d8dbabfe2cc2a556ef02e75e5502fd799c46))


### Bug Fixes

* **api:** build errors ([7bde6b7](https://github.com/scaleapi/agentex-python/commit/7bde6b727d6d16ebd6805ef843596fc3224445a6))
* **parsing:** parse extra field types ([d40e6e0](https://github.com/scaleapi/agentex-python/commit/d40e6e0d6911be0bc9bfc419e02bd7c1d5ad5be4))

## 0.1.0-alpha.4 (2025-07-22)

Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/scaleapi/agentex-python/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)
Expand Down
44 changes: 15 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ pip install git+ssh://git@github.com/scaleapi/agentex-python.git
The full API of this library can be found in [api.md](api.md).

```python
import os
from agentex import Agentex

client = Agentex(
api_key=os.environ.get("AGENTEX_SDK_API_KEY"), # This is the default and can be omitted
# defaults to "production".
environment="development",
)

agent = client.agents.retrieve(
"agent_id",
)
print(agent.id)
tasks = client.tasks.list()
```

While you can provide an `api_key` keyword argument,
Expand All @@ -51,20 +50,19 @@ so that your API Key is not stored in source control.
Simply import `AsyncAgentex` instead of `Agentex` and use `await` with each API call:

```python
import os
import asyncio
from agentex import AsyncAgentex

client = AsyncAgentex(
api_key=os.environ.get("AGENTEX_SDK_API_KEY"), # This is the default and can be omitted
# defaults to "production".
environment="development",
)


async def main() -> None:
agent = await client.agents.retrieve(
"agent_id",
)
print(agent.id)
tasks = await client.tasks.list()


asyncio.run(main())
Expand Down Expand Up @@ -93,12 +91,10 @@ from agentex import AsyncAgentex

async def main() -> None:
async with AsyncAgentex(
api_key="My API Key",
http_client=DefaultAioHttpClient(),
) as client:
agent = await client.agents.retrieve(
"agent_id",
)
print(agent.id)
tasks = await client.tasks.list()


asyncio.run(main())
Expand Down Expand Up @@ -129,9 +125,7 @@ from agentex import Agentex
client = Agentex()

try:
client.agents.retrieve(
"agent_id",
)
client.tasks.list()
except agentex.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -174,9 +168,7 @@ client = Agentex(
)

# Or, configure per-request:
client.with_options(max_retries=5).agents.retrieve(
"agent_id",
)
client.with_options(max_retries=5).tasks.list()
```

### Timeouts
Expand All @@ -199,9 +191,7 @@ client = Agentex(
)

# Override per-request:
client.with_options(timeout=5.0).agents.retrieve(
"agent_id",
)
client.with_options(timeout=5.0).tasks.list()
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -242,13 +232,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from agentex import Agentex

client = Agentex()
response = client.agents.with_raw_response.retrieve(
"agent_id",
)
response = client.tasks.with_raw_response.list()
print(response.headers.get('X-My-Header'))

agent = response.parse() # get the object that `agents.retrieve()` would have returned
print(agent.id)
task = response.parse() # get the object that `tasks.list()` would have returned
print(task)
```

These methods return an [`APIResponse`](https://github.com/scaleapi/agentex-python/tree/main/src/agentex/_response.py) object.
Expand All @@ -262,9 +250,7 @@ The above interface eagerly reads the full response body when you make the reque
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.

```python
with client.agents.with_streaming_response.retrieve(
"agent_id",
) as response:
with client.tasks.with_streaming_response.list() as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
Expand Down
28 changes: 24 additions & 4 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
# Shared Types

```python
from agentex.types import TaskMessageUpdate
```

# Agents

Types:

```python
from agentex.types import AcpType, Agent, AgentRpcRequest, AgentListResponse
from agentex.types import (
AcpType,
Agent,
AgentRpcParams,
AgentRpcRequest,
AgentRpcResponse,
AgentRpcResult,
DataDelta,
TaskMessageContent,
TaskMessageDelta,
TaskMessageUpdate,
TextDelta,
ToolRequestDelta,
ToolResponseDelta,
AgentListResponse,
)
```

Methods:
Expand All @@ -13,8 +34,8 @@ Methods:
- <code title="delete /agents/{agent_id}">client.agents.<a href="./src/agentex/resources/agents.py">delete</a>(agent_id) -> <a href="./src/agentex/types/agent.py">Agent</a></code>
- <code title="delete /agents/name/{agent_name}">client.agents.<a href="./src/agentex/resources/agents.py">delete_by_name</a>(agent_name) -> <a href="./src/agentex/types/agent.py">Agent</a></code>
- <code title="get /agents/name/{agent_name}">client.agents.<a href="./src/agentex/resources/agents.py">retrieve_by_name</a>(agent_name) -> <a href="./src/agentex/types/agent.py">Agent</a></code>
- <code title="post /agents/{agent_id}/rpc">client.agents.<a href="./src/agentex/resources/agents.py">rpc</a>(agent_id, \*\*<a href="src/agentex/types/agent_rpc_params.py">params</a>) -> object</code>
- <code title="post /agents/name/{agent_name}/rpc">client.agents.<a href="./src/agentex/resources/agents.py">rpc_by_name</a>(agent_name, \*\*<a href="src/agentex/types/agent_rpc_by_name_params.py">params</a>) -> object</code>
- <code title="post /agents/{agent_id}/rpc">client.agents.<a href="./src/agentex/resources/agents.py">rpc</a>(agent_id, \*\*<a href="src/agentex/types/agent_rpc_params.py">params</a>) -> <a href="./src/agentex/types/agent_rpc_response.py">AgentRpcResponse</a></code>
- <code title="post /agents/name/{agent_name}/rpc">client.agents.<a href="./src/agentex/resources/agents.py">rpc_by_name</a>(agent_name, \*\*<a href="src/agentex/types/agent_rpc_by_name_params.py">params</a>) -> <a href="./src/agentex/types/agent_rpc_response.py">AgentRpcResponse</a></code>

# Tasks

Expand Down Expand Up @@ -43,7 +64,6 @@ from agentex.types import (
DataContent,
MessageAuthor,
MessageStyle,
StreamingStatus,
TaskMessage,
TextContent,
ToolRequestContent,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "agentex"
version = "0.1.0-alpha.4"
version = "0.1.0-alpha.5"
description = "The official Python library for the agentex API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
25 changes: 23 additions & 2 deletions src/agentex/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,18 @@ def construct( # pyright: ignore[reportIncompatibleMethodOverride]
else:
fields_values[name] = field_get_default(field)

extra_field_type = _get_extra_fields_type(__cls)

_extra = {}
for key, value in values.items():
if key not in model_fields:
parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value

if PYDANTIC_V2:
_extra[key] = value
_extra[key] = parsed
else:
_fields_set.add(key)
fields_values[key] = value
fields_values[key] = parsed

object.__setattr__(m, "__dict__", fields_values)

Expand Down Expand Up @@ -370,6 +374,23 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))


def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
if not PYDANTIC_V2:
# TODO
return None

schema = cls.__pydantic_core_schema__
if schema["type"] == "model":
fields = schema["schema"]
if fields["type"] == "model-fields":
extras = fields.get("extras_schema")
if extras and "cls" in extras:
# mypy can't narrow the type
return extras["cls"] # type: ignore[no-any-return]

return None


def is_basemodel(type_: type) -> bool:
"""Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
if is_union(type_):
Expand Down
2 changes: 1 addition & 1 deletion src/agentex/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "agentex"
__version__ = "0.1.0-alpha.4" # x-release-please-version
__version__ = "0.1.0-alpha.5" # x-release-please-version
Loading
Loading