Skip to content

Commit 519d982

Browse files
authored
feat(sdk)!: align Forward and Managed capability contracts (#44)
Expose Forward session, A2A and OSS configuration and Managed browser/media tools and deny policies while preserving historical response snapshots.
1 parent 9b1a2e6 commit 519d982

67 files changed

Lines changed: 2632 additions & 54 deletions

File tree

Some content is hidden

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

‎CHANGELOG.md‎

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

66
## [Unreleased]
77

8+
### Added
9+
10+
- Add Forward Session `auto_title` on creation and nullable `config.multiagent` on update. Omit `auto_title` for the server's false default; when true, omit `title` entirely. Clearing a roster with `None` does not restore Template inheritance, and create config still does not accept a roster.
11+
- Add independent Forward Template A2A publication settings and synchronous/asynchronous `templates.retrieve_agent_card()` discovery for A2A 0.3 and 1.0, with typed protocol fields and unknown-field preservation. PAT callers can select a runtime Identity; SAT callers omit it. No task invocation client is included.
12+
- Add typed Forward Environment config, packages and OSS bucket storage with separate write credentials and safe read models. Updates replace the whole config; omit a bucket credential to retain it, or use `buckets=[]` to remove future mounts without changing existing Sessions. Forward supports up to seven buckets through the existing `oss-bucket-2026-09-23` beta header.
13+
- Add Managed `AlwaysDenyPolicy`/`AlwaysDenyPolicyParam` and `always_deny` to all built-in and MCP request policy unions, including defaults.
14+
- Add Managed ImageGen, ImageSearch, VideoGen and DeliverArtifacts config types with required canonical or supported snake-case names. Add type-only BrowserToolset20260714 request/response types across Agent and Session snapshots; use the existing `betas=["browser-use-2026-07-14"]` option when configuring Browser Use.
15+
816
### Fixed
917

18+
- Preserve historical string `configs[].permission_policy` values when leniently parsing Managed Agent, Session and Thread tool snapshots. Tools and configs retain model attribute access instead of becoming Browser models or raw dictionaries; known Browser/media variants keep their concrete types and strict validation still rejects invalid payloads.
19+
- Expose Managed MCP toolsets' top-level `permission_policy` in requests and Agent/Session/Thread responses, including `always_deny` without `configs`. Set server-wide defaults here: nested `default_config.permission_policy` is retained unchanged for compatibility but does not set the MCP default; omitting the top-level policy defaults to allow.
1020
- 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.
1121

22+
### Breaking changes
23+
24+
- Managed Agent, Session and Thread tool snapshots now return `BrowserToolset20260714` for Browser entries instead of a generic tool model. Browser supports only `type`, so attributes such as `configs` and `mcp_server_name` are not available on that variant.
25+
26+
### Migration
27+
28+
- Check each tool's variant before reading toolset-specific fields. The same branching applies to Agent, Session and Thread snapshots in synchronous and asynchronous clients:
29+
30+
```python
31+
from qca.managed.types import BrowserToolset20260714
32+
33+
for tool in agent.tools or []:
34+
if isinstance(tool, BrowserToolset20260714):
35+
continue
36+
for config in tool.configs or []:
37+
print(config.name)
38+
```
39+
1240
## [0.15.0]
1341

1442
### Added

‎README.md‎

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,114 @@ See the official [Forward](https://docs.qoder.com/cloud-agents/api/forward/envir
173173
and [Managed](https://docs.qoder.com/cloud-agents/api/environments/schemas#environment-startup-script)
174174
contracts.
175175

176+
## Capability configuration
177+
178+
These functions are runnable with an authenticated client and accessible resource
179+
IDs. All calls also have async counterparts. The SDK leaves service validation
180+
and merge semantics to the API; no model execution is needed for Card discovery.
181+
182+
```python
183+
from qca import Forward
184+
from qca.forward.types import A2AConfigParam
185+
186+
187+
def configure_forward(client: Forward, template_id: str, identity_id: str) -> None:
188+
publication: A2AConfigParam = {
189+
"enabled": True,
190+
"description": "Summarize supplied text",
191+
"skills": [{"id": "summary", "name": "Summarize", "description": "Summarize text"}],
192+
}
193+
client.templates.update(template_id, a2a=publication)
194+
card = client.templates.retrieve_agent_card(
195+
template_id, identity_id=identity_id, a2a_version="1.0"
196+
)
197+
print(card.name, card.default_input_modes, card.supported_interfaces)
198+
session = client.sessions.create(
199+
template_id=template_id, identity_id=identity_id, auto_title=True
200+
) # Do not supply title, even None, when auto_title is true.
201+
client.sessions.update(session.id, config={"multiagent": None})
202+
```
203+
204+
Omitting `auto_title` uses the server's false default. Session update roster
205+
omission keeps the current roster; `None` clears it without restoring inheritance.
206+
Do not put `multiagent` in Session create config. Template `a2a` is independent
207+
of `multiagent`: omitted members or `{}` keep saved A2A settings, `skills=[]`
208+
clears advertised skills, and `a2a=None` clears/disables publication. Individual
209+
A2A members cannot be null. Card fields use Python snake-case attributes with
210+
wire aliases (`defaultInputModes`, `supportedInterfaces`); unknown fields are
211+
retained. With SAT, omit `identity_id` from Card retrieval. The SDK does not
212+
invoke A2A tasks or follow URLs from Cards.
213+
214+
```python
215+
from qca import Forward
216+
from qca.forward.types import EnvironmentConfigParam
217+
218+
219+
def mount_oss(client: Forward, environment_id: str, bucket: str, role_arn: str) -> None:
220+
config: EnvironmentConfigParam = {
221+
"type": "cloud",
222+
"storage": {"buckets": [{
223+
"name": "datasets", "provider": "aliyun-oss", "region": "cn-hangzhou",
224+
"bucket": bucket, "access": "read_only",
225+
"credential": {"type": "ram_role", "role_arn": role_arn},
226+
}]},
227+
}
228+
env = client.environments.update(
229+
environment_id, config=config,
230+
extra_headers={"X-Qoder-Beta": "oss-bucket-2026-09-23"},
231+
)
232+
print(env.config.storage.buckets[0].credential.type)
233+
```
234+
235+
Forward supports up to seven cloud bucket mounts. Config updates replace the
236+
whole config, so retain any packages/scripts you still need. New buckets require
237+
credentials; updates may omit `credential` to keep stored credentials. Responses
238+
expose only credential type and an optional masked AccessKey ID, never a secret
239+
or role ARN. `storage={"buckets": []}` removes mounts for future Sessions;
240+
existing Session snapshots are unchanged.
241+
242+
```python
243+
from qca import Managed
244+
from qca.managed.types import AgentToolset20260401Params, BrowserToolset20260714Params, MCPToolsetParams
245+
246+
247+
def configure_tools(client: Managed, agent_id: str) -> None:
248+
builtins: AgentToolset20260401Params = {
249+
"type": "agent_toolset_20260401",
250+
"enabled_tools": ["ImageGen", "ImageSearch", "DeliverArtifacts"],
251+
"default_config": {"permission_policy": {"type": "always_deny"}},
252+
"configs": [
253+
{"name": "ImageGen", "permission_policy": {"type": "always_ask"}},
254+
{"name": "ImageSearch", "permission_policy": {"type": "always_allow"}},
255+
{"name": "VideoGen", "enabled": False},
256+
{"name": "DeliverArtifacts", "permission_policy": {"type": "always_ask"}},
257+
],
258+
}
259+
mcp: MCPToolsetParams = {
260+
"type": "mcp_toolset",
261+
"mcp_server_name": "weather",
262+
"permission_policy": {"type": "always_deny"},
263+
}
264+
browser: BrowserToolset20260714Params = {"type": "browser_toolset_20260714"}
265+
client.agents.update(
266+
agent_id, tools=[builtins, mcp, browser], betas=["browser-use-2026-07-14"]
267+
)
268+
```
269+
270+
Media config entries require `name` (canonical name or supported snake-case
271+
alias); generation prompts and media parameters belong in Session messages, not
272+
tool config. Browser request entries contain only `type`, not `enabled` or
273+
`configs`. Agent updates do not require `version` and affect future Session
274+
snapshots, not existing ones.
275+
276+
For MCP, set the server-wide default in the toolset's **top-level**
277+
`permission_policy`: `always_allow`, `always_ask`, or `always_deny`, even without
278+
`configs`. Use `configs[].permission_policy` for per-tool policies. Omitting the
279+
top-level policy defaults to allow, not the built-in tool default.
280+
`default_config` remains available for raw payload compatibility, but its nested
281+
`permission_policy` does not set the MCP server-wide default. The example assumes
282+
`weather` is already configured in the Agent's `mcp_servers`.
283+
176284
## Streaming
177285

178286
Streaming responses are consumed incrementally. Close the stream when finished and handle interruption explicitly; closing a local stream does not cancel server-side work.
@@ -216,6 +324,12 @@ except APIStatusError as exc:
216324

217325
By default, responses are constructed into models without requiring every field to match the declared schema, matching Anthropic's Python SDK. Nested objects are still converted to models and unknown fields are retained. Unexpected field values may keep their original type, so type annotations describe the expected API schema rather than guaranteeing the runtime value.
218326

327+
Managed Agent, Session and Thread snapshots with historical string
328+
`configs[].permission_policy` values keep tool/config model attribute access and
329+
preserve those strings unchanged. Known Browser and media variants retain their
330+
concrete response classes; unknown tools use the generic model. This compatibility
331+
does not relax strict response validation.
332+
219333
To require Pydantic response validation and raise `APIResponseValidationError` on a schema mismatch, enable the constructor option:
220334

221335
```python

0 commit comments

Comments
 (0)