From 2de8939369c0b2402d32af66fc382f1a9cacfd16 Mon Sep 17 00:00:00 2001
From: moonyue-w <300878504+moonyue-w@users.noreply.github.com>
Date: Fri, 20 Nov 2026 21:34:47 +0800
Subject: [PATCH] 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.
---
CHANGELOG.md | 4 +++
docs/api/reference.md | 26 +++++++++++++++
src/qca/managed/types/__init__.py | 1 +
.../managed/types/multiagent_agent_params.py | 15 +++++++++
.../managed/types/multiagent_agent_union.py | 3 +-
src/qca/managed/types/multiagent_params.py | 4 +--
tests/test_official_contract_alignment.py | 33 +++++++++++++++++++
7 files changed, 83 insertions(+), 3 deletions(-)
create mode 100644 src/qca/managed/types/multiagent_agent_params.py
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7e15e7f..d03c0ac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,10 @@ existing `0.1.0` release; earlier development prereleases are not listed.
## [Unreleased]
+### Fixed
+
+- 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.
+
## [0.15.0]
### Added
diff --git a/docs/api/reference.md b/docs/api/reference.md
index 8954437..8b65d20 100644
--- a/docs/api/reference.md
+++ b/docs/api/reference.md
@@ -33249,6 +33249,32 @@ class Multiagent(BaseModel)
#### type
+
+
+# qca.managed.types.multiagent\_agent\_params
+
+
+
+## MultiagentAgentParams
+
+```python
+class MultiagentAgentParams(TypedDict)
+```
+
+[[view_source]](https://github.com/QoderAI/qoder-cloud-agents-sdk-python/blob/main/src/qca/managed/types/multiagent_agent_params.py)
+
+
+
+#### id
+
+
+
+#### type
+
+
+
+#### version
+
# qca.managed.types.multiagent\_agent\_union
diff --git a/src/qca/managed/types/__init__.py b/src/qca/managed/types/__init__.py
index f937356..1588586 100644
--- a/src/qca/managed/types/__init__.py
+++ b/src/qca/managed/types/__init__.py
@@ -241,6 +241,7 @@
from .monetary_amount import MonetaryAmount as MonetaryAmount
from .monetary_amount_param import MonetaryAmountParam as MonetaryAmountParam
from .multiagent import Multiagent as Multiagent
+from .multiagent_agent_params import MultiagentAgentParams as MultiagentAgentParams
from .multiagent_agent_union import MultiagentAgentUnion as MultiagentAgentUnion
from .multiagent_params import MultiagentParams as MultiagentParams
from .multiagent_self_params import MultiagentSelfParams as MultiagentSelfParams
diff --git a/src/qca/managed/types/multiagent_agent_params.py b/src/qca/managed/types/multiagent_agent_params.py
new file mode 100644
index 0000000..713a07d
--- /dev/null
+++ b/src/qca/managed/types/multiagent_agent_params.py
@@ -0,0 +1,15 @@
+from __future__ import annotations
+
+from typing import Literal, Optional, Union
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["MultiagentAgentParams"]
+
+
+class MultiagentAgentParams(TypedDict, total=False):
+ id: Required[str]
+ type: Required[Literal["agent"]]
+ # A positive integer, "latest", or a positive integer string. Omit to pin the
+ # latest numeric version at save time.
+ version: Optional[Union[int, str]]
diff --git a/src/qca/managed/types/multiagent_agent_union.py b/src/qca/managed/types/multiagent_agent_union.py
index f6a1f77..e42da4d 100644
--- a/src/qca/managed/types/multiagent_agent_union.py
+++ b/src/qca/managed/types/multiagent_agent_union.py
@@ -13,5 +13,6 @@
class MultiagentAgentUnion(BaseModel):
id: Optional[str] = None
type: Optional[str] = None
- version: Optional[int] = None
+ # A saved child Agent version: a concrete version or "latest".
+ version: Optional[Union[int, str]] = None
model: Optional[Union[str, ModelConfig]] = None
diff --git a/src/qca/managed/types/multiagent_params.py b/src/qca/managed/types/multiagent_params.py
index 0e0525c..5cf67fa 100644
--- a/src/qca/managed/types/multiagent_params.py
+++ b/src/qca/managed/types/multiagent_params.py
@@ -6,12 +6,12 @@
if TYPE_CHECKING:
from .advisor_params import AdvisorParams
- from .agent_params import AgentParams
+ from .multiagent_agent_params import MultiagentAgentParams
from .multiagent_self_params import MultiagentSelfParams
__all__ = ["MultiagentParams"]
class MultiagentParams(TypedDict, total=False):
- agents: Required[List[Union[str, AgentParams, MultiagentSelfParams, AdvisorParams]]]
+ agents: Required[List[Union[str, MultiagentAgentParams, MultiagentSelfParams, AdvisorParams]]]
type: Required[Literal["coordinator"]]
diff --git a/tests/test_official_contract_alignment.py b/tests/test_official_contract_alignment.py
index 424b164..8fc8f33 100644
--- a/tests/test_official_contract_alignment.py
+++ b/tests/test_official_contract_alignment.py
@@ -282,3 +282,36 @@ def handle(req):
assert credential.to_dict() == {"type": "access_key", "access_key_id": "test****"}
assert not hasattr(credential, "access_key_secret")
assert not expected
+
+
+# Official Agent schema retrieved 2026-11-20: roster child versions accept "latest".
+@pytest.mark.parametrize("async_", [False, True])
+async def test_managed_agent_roster_latest_version(async_):
+ roster = {
+ "type": "coordinator",
+ "agents": [
+ {"type": "agent", "id": "agent_latest", "version": "latest"},
+ {"type": "agent", "id": "agent_text", "version": "3"},
+ {"type": "agent", "id": "agent_pinned", "version": 3},
+ ],
+ }
+ saved = {
+ "type": "coordinator",
+ "agents": [
+ {"type": "agent", "id": "agent_latest", "version": "latest"},
+ {"type": "agent", "id": "agent_text", "version": 3},
+ {"type": "advisor", "model": "ultimate"},
+ ],
+ }
+
+ def handle(req):
+ assert json.loads(req.content)["multiagent"] == roster
+ return httpx.Response(200, json={"id": "agent_parent", "multiagent": saved})
+
+ http = (httpx.AsyncClient if async_ else httpx.Client)(transport=httpx.MockTransport(handle))
+ client = (AsyncManaged if async_ else Managed)(pat="test", http_client=http, _strict_response_validation=True)
+ try:
+ agent = await resolve(client.agents.create(name="coordinator", model="auto", multiagent=roster))
+ assert [entry.version for entry in agent.multiagent.agents] == ["latest", 3, None]
+ finally:
+ await resolve(client.close())