Skip to content

Commit 2de8939

Browse files
committed
fix: accept latest child Agent versions in Managed rosters
Agent rosters may save a child version as "latest", but the SDK typed roster versions as integers, so strict response parsing rejected valid Agents. Add a roster-specific request type and accept int or string versions in responses; Session and Deployment references stay numeric.
1 parent b6c97c4 commit 2de8939

7 files changed

Lines changed: 83 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ existing `0.1.0` release; earlier development prereleases are not listed.
55

66
## [Unreleased]
77

8+
### Fixed
9+
10+
- Accept `"latest"` and positive integer strings for child Agent `version` in Managed Agent multiagent rosters through the new `MultiagentAgentParams` type, and parse saved `"latest"` versions in Agent responses, including with `_strict_response_validation=True`. `MultiagentAgentUnion.version` is now typed `int | str`; Session and Deployment Agent references keep numeric versions.
11+
812
## [0.15.0]
913

1014
### Added

‎docs/api/reference.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33249,6 +33249,32 @@ class Multiagent(BaseModel)
3324933249

3325033250
#### type
3325133251

33252+
<a id="qca.managed.types.multiagent_agent_params"></a>
33253+
33254+
# qca.managed.types.multiagent\_agent\_params
33255+
33256+
<a id="qca.managed.types.multiagent_agent_params.MultiagentAgentParams"></a>
33257+
33258+
## MultiagentAgentParams
33259+
33260+
```python
33261+
class MultiagentAgentParams(TypedDict)
33262+
```
33263+
33264+
[[view_source]](https://github.com/QoderAI/qoder-cloud-agents-sdk-python/blob/main/src/qca/managed/types/multiagent_agent_params.py)
33265+
33266+
<a id="qca.managed.types.multiagent_agent_params.MultiagentAgentParams.id"></a>
33267+
33268+
#### id
33269+
33270+
<a id="qca.managed.types.multiagent_agent_params.MultiagentAgentParams.type"></a>
33271+
33272+
#### type
33273+
33274+
<a id="qca.managed.types.multiagent_agent_params.MultiagentAgentParams.version"></a>
33275+
33276+
#### version
33277+
3325233278
<a id="qca.managed.types.multiagent_agent_union"></a>
3325333279

3325433280
# qca.managed.types.multiagent\_agent\_union

‎src/qca/managed/types/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
from .monetary_amount import MonetaryAmount as MonetaryAmount
242242
from .monetary_amount_param import MonetaryAmountParam as MonetaryAmountParam
243243
from .multiagent import Multiagent as Multiagent
244+
from .multiagent_agent_params import MultiagentAgentParams as MultiagentAgentParams
244245
from .multiagent_agent_union import MultiagentAgentUnion as MultiagentAgentUnion
245246
from .multiagent_params import MultiagentParams as MultiagentParams
246247
from .multiagent_self_params import MultiagentSelfParams as MultiagentSelfParams
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import annotations
2+
3+
from typing import Literal, Optional, Union
4+
5+
from typing_extensions import Required, TypedDict
6+
7+
__all__ = ["MultiagentAgentParams"]
8+
9+
10+
class MultiagentAgentParams(TypedDict, total=False):
11+
id: Required[str]
12+
type: Required[Literal["agent"]]
13+
# A positive integer, "latest", or a positive integer string. Omit to pin the
14+
# latest numeric version at save time.
15+
version: Optional[Union[int, str]]

‎src/qca/managed/types/multiagent_agent_union.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
class MultiagentAgentUnion(BaseModel):
1414
id: Optional[str] = None
1515
type: Optional[str] = None
16-
version: Optional[int] = None
16+
# A saved child Agent version: a concrete version or "latest".
17+
version: Optional[Union[int, str]] = None
1718
model: Optional[Union[str, ModelConfig]] = None

‎src/qca/managed/types/multiagent_params.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
if TYPE_CHECKING:
88
from .advisor_params import AdvisorParams
9-
from .agent_params import AgentParams
9+
from .multiagent_agent_params import MultiagentAgentParams
1010
from .multiagent_self_params import MultiagentSelfParams
1111

1212
__all__ = ["MultiagentParams"]
1313

1414

1515
class MultiagentParams(TypedDict, total=False):
16-
agents: Required[List[Union[str, AgentParams, MultiagentSelfParams, AdvisorParams]]]
16+
agents: Required[List[Union[str, MultiagentAgentParams, MultiagentSelfParams, AdvisorParams]]]
1717
type: Required[Literal["coordinator"]]

‎tests/test_official_contract_alignment.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,36 @@ def handle(req):
282282
assert credential.to_dict() == {"type": "access_key", "access_key_id": "test****"}
283283
assert not hasattr(credential, "access_key_secret")
284284
assert not expected
285+
286+
287+
# Official Agent schema retrieved 2026-11-20: roster child versions accept "latest".
288+
@pytest.mark.parametrize("async_", [False, True])
289+
async def test_managed_agent_roster_latest_version(async_):
290+
roster = {
291+
"type": "coordinator",
292+
"agents": [
293+
{"type": "agent", "id": "agent_latest", "version": "latest"},
294+
{"type": "agent", "id": "agent_text", "version": "3"},
295+
{"type": "agent", "id": "agent_pinned", "version": 3},
296+
],
297+
}
298+
saved = {
299+
"type": "coordinator",
300+
"agents": [
301+
{"type": "agent", "id": "agent_latest", "version": "latest"},
302+
{"type": "agent", "id": "agent_text", "version": 3},
303+
{"type": "advisor", "model": "ultimate"},
304+
],
305+
}
306+
307+
def handle(req):
308+
assert json.loads(req.content)["multiagent"] == roster
309+
return httpx.Response(200, json={"id": "agent_parent", "multiagent": saved})
310+
311+
http = (httpx.AsyncClient if async_ else httpx.Client)(transport=httpx.MockTransport(handle))
312+
client = (AsyncManaged if async_ else Managed)(pat="test", http_client=http, _strict_response_validation=True)
313+
try:
314+
agent = await resolve(client.agents.create(name="coordinator", model="auto", multiagent=roster))
315+
assert [entry.version for entry in agent.multiagent.agents] == ["latest", 3, None]
316+
finally:
317+
await resolve(client.close())

0 commit comments

Comments
 (0)