Skip to content

Commit 784f60f

Browse files
committed
feat(sdk)!: align API contracts for 0.17.0
1 parent bca1a8e commit 784f60f

15 files changed

Lines changed: 475 additions & 19 deletions

‎CHANGELOG.md‎

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

66
## [Unreleased]
77

8+
## [0.17.0]
9+
10+
### Added
11+
12+
- Add optional Managed `sessions.events.send(busy_mode="reject" | "steer")` in synchronous and asynchronous clients. Omit it for the service's `reject` default (HTTP 409 during an active Turn); `steer` (Beta) appends a user message without cancelling the Turn. Respond to pending tool confirmation or custom tool results first.
13+
- Add Forward Template `managed_tool_config.schedule` request/response types with `access_scope="identity" | "template"`. Omit or clear `schedule` for the identity default; template scope limits management to Schedules created by that Template and cannot be expanded by Identity overrides.
14+
- Add Managed Session Agent patch `name` and `description`. Pass `betas=["session-agent-patch-2026-07-21"]`; patches change the embedded snapshot, not its Agent ID/version or coordinator roster. Wait for idle when a clean Turn boundary is required.
15+
16+
### Fixed
17+
18+
- Make Forward `ManagedToolConfigParam.enabled_tools` optional so the documented empty-object clearing form is typed correctly. Template updates replace the whole baseline; `None`, `{}`, or `enabled_tools=[]` clears the managed capabilities.
19+
- Document Managed SA Key direct access with the existing `auth_mode="sa", access_token=sa_key` configuration. Add synchronous/asynchronous `--managed-direct` SA Key examples; the default still exchanges and caches a shared SAT for Forward and Managed. Forward business APIs require PAT or SAT.
20+
21+
### Breaking changes
22+
23+
- Narrow Managed `UserMessageEventParams.content` to text and image blocks, matching the public user-message contract. Document and redacted blocks are no longer accepted by that request type; historical response parsing and tool-result document input remain unchanged.
24+
25+
### Migration
26+
27+
- Send user messages as non-empty text/image arrays; use image Base64, HTTPS URL or uploaded File sources. Put document results in supported `user.tool_result` or `user.custom_tool_result` events instead of user messages. This is a typing correction, not new client-side runtime validation.
28+
- Existing `extra_body={"busy_mode": "steer"}` calls remain supported; use the explicit `busy_mode="steer"` argument for typed access. No new Beta header is added automatically.
29+
830
## [0.16.0]
931

1032
### Added

‎README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,23 @@ clients accept the same configuration). `QODER_ACCESS_TOKEN` supplies the select
8989
mode's token; only PAT mode falls back to `QODER_PAT`. Ordinary clients do not read
9090
`QODER_SA_KEY` or implicitly exchange it.
9191

92+
Managed also accepts the complete SA Key directly, without exchanging a SAT:
93+
94+
```python
95+
import os
96+
from qca import Managed
97+
98+
with Managed(auth_mode="sa", access_token=os.environ["QODER_SA_KEY"]) as managed:
99+
agents = managed.agents.list(limit=1)
100+
```
101+
102+
`AsyncManaged` accepts the same static configuration. Forward business APIs
103+
require PAT or SAT, not a raw SA Key. Use the credential below to exchange and
104+
cache a SAT shared by Forward and Managed. The runnable SA Key example preserves
105+
that shared-SAT default; select `python -m examples.auth.sa_key --managed-direct`
106+
(or add `--async`) for Managed-only direct access. Configure the matching CN base
107+
URL explicitly when using a CN key.
108+
92109
```python
93110
from qca import Forward, Managed, ServiceAccountCredential
94111

‎docs/api/reference.md‎

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15308,6 +15308,22 @@ class ManagedCapabilityOverride(BaseModel)
1530815308

1530915309
# qca.forward.types.managed\_tool\_config
1531015310

15311+
<a id="qca.forward.types.managed_tool_config.ManagedScheduleConfig"></a>
15312+
15313+
## ManagedScheduleConfig
15314+
15315+
```python
15316+
class ManagedScheduleConfig(BaseModel)
15317+
```
15318+
15319+
[[view_source]](https://github.com/QoderAI/qoder-cloud-agents-sdk-python/blob/main/src/qca/forward/types/managed_tool_config.py)
15320+
15321+
Template Schedule scope; template confines management to its Schedules.
15322+
15323+
<a id="qca.forward.types.managed_tool_config.ManagedScheduleConfig.access_scope"></a>
15324+
15325+
#### access\_scope
15326+
1531115327
<a id="qca.forward.types.managed_tool_config.ManagedToolConfig"></a>
1531215328

1531315329
## ManagedToolConfig
@@ -15324,10 +15340,30 @@ Forward-managed tools, distinct from tools[].enabled_tools.
1532415340

1532515341
#### enabled\_tools
1532615342

15343+
<a id="qca.forward.types.managed_tool_config.ManagedToolConfig.schedule"></a>
15344+
15345+
#### schedule
15346+
1532715347
<a id="qca.forward.types.managed_tool_config_param"></a>
1532815348

1532915349
# qca.forward.types.managed\_tool\_config\_param
1533015350

15351+
<a id="qca.forward.types.managed_tool_config_param.ManagedScheduleConfigParam"></a>
15352+
15353+
## ManagedScheduleConfigParam
15354+
15355+
```python
15356+
class ManagedScheduleConfigParam(TypedDict)
15357+
```
15358+
15359+
[[view_source]](https://github.com/QoderAI/qoder-cloud-agents-sdk-python/blob/main/src/qca/forward/types/managed_tool_config_param.py)
15360+
15361+
Schedule management scope; omission defaults to identity.
15362+
15363+
<a id="qca.forward.types.managed_tool_config_param.ManagedScheduleConfigParam.access_scope"></a>
15364+
15365+
#### access\_scope
15366+
1533115367
<a id="qca.forward.types.managed_tool_config_param.ManagedToolConfigParam"></a>
1533215368

1533315369
## ManagedToolConfigParam
@@ -15338,12 +15374,16 @@ class ManagedToolConfigParam(TypedDict)
1533815374

1533915375
[[view_source]](https://github.com/QoderAI/qoder-cloud-agents-sdk-python/blob/main/src/qca/forward/types/managed_tool_config_param.py)
1534015376

15341-
Replaces the complete enabled list; [] disables all managed tools.
15377+
Replaces the entire Template baseline; {} or enabled_tools=[] clears it.
1534215378

1534315379
<a id="qca.forward.types.managed_tool_config_param.ManagedToolConfigParam.enabled_tools"></a>
1534415380

1534515381
#### enabled\_tools
1534615382

15383+
<a id="qca.forward.types.managed_tool_config_param.ManagedToolConfigParam.schedule"></a>
15384+
15385+
#### schedule
15386+
1534715387
<a id="qca.forward.types.mcp_server"></a>
1534815388

1534915389
# qca.forward.types.mcp\_server
@@ -24989,6 +25029,7 @@ def send(
2498925029
UserToolResultEventParams,
2499025030
SystemMessageEventParams,
2499125031
]],
25032+
busy_mode: Union[Literal["reject", "steer"], NotGiven] = NOT_GIVEN,
2499225033
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
2499325034
betas: Union[List[str], None, NotGiven] = NOT_GIVEN,
2499425035
extra_headers: Dict[str, str] | None = None,
@@ -25002,6 +25043,10 @@ def send(
2500225043

2500325044
POST /sessions/{session_id}/events.
2500425045

25046+
Omit busy_mode for the server's reject default (409 during an active Turn).
25047+
Use steer (Beta) to append user.message without cancelling the current Turn.
25048+
Respond to pending tool confirmation or custom tool results first.
25049+
2500525050
<a id="qca.managed.resources.sessions.events.Events.stream"></a>
2500625051

2500725052
#### stream
@@ -25108,6 +25153,7 @@ async def send(
2510825153
UserToolResultEventParams,
2510925154
SystemMessageEventParams,
2511025155
]],
25156+
busy_mode: Union[Literal["reject", "steer"], NotGiven] = NOT_GIVEN,
2511125157
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
2511225158
betas: Union[List[str], None, NotGiven] = NOT_GIVEN,
2511325159
extra_headers: Dict[str, str] | None = None,
@@ -25121,6 +25167,10 @@ async def send(
2512125167

2512225168
POST /sessions/{session_id}/events.
2512325169

25170+
Omit busy_mode for the server's reject default (409 during an active Turn).
25171+
Use steer (Beta) to append user.message without cancelling the current Turn.
25172+
Respond to pending tool confirmation or custom tool results first.
25173+
2512425174
<a id="qca.managed.resources.sessions.events.AsyncEvents.stream"></a>
2512525175

2512625176
#### stream
@@ -35321,6 +35371,19 @@ class SessionAgentUpdateParam(TypedDict)
3532135371

3532235372
[[view_source]](https://github.com/QoderAI/qoder-cloud-agents-sdk-python/blob/main/src/qca/managed/types/session_agent_update_param.py)
3532335373

35374+
Patch the embedded snapshot, not its ID/version or coordinator roster.
35375+
35376+
model, system, skills, name and description require session-agent-patch-2026-07-21.
35377+
Lists are complete replacements; wait for idle for a clean Turn boundary.
35378+
35379+
<a id="qca.managed.types.session_agent_update_param.SessionAgentUpdateParam.name"></a>
35380+
35381+
#### name
35382+
35383+
<a id="qca.managed.types.session_agent_update_param.SessionAgentUpdateParam.description"></a>
35384+
35385+
#### description
35386+
3532435387
<a id="qca.managed.types.session_agent_update_param.SessionAgentUpdateParam.model"></a>
3532535388

3532635389
#### model
@@ -35823,6 +35886,10 @@ class SessionEventSendParams(TypedDict)
3582335886

3582435887
#### events
3582535888

35889+
<a id="qca.managed.types.session_event_send_params.SessionEventSendParams.busy_mode"></a>
35890+
35891+
#### busy\_mode
35892+
3582635893
<a id="qca.managed.types.session_event_send_params.SessionEventSendParams.workspace_id"></a>
3582735894

3582835895
#### workspace\_id
@@ -38943,6 +39010,8 @@ class UserMessageEventParams(TypedDict)
3894339010

3894439011
[[view_source]](https://github.com/QoderAI/qoder-cloud-agents-sdk-python/blob/main/src/qca/managed/types/user_message_event_params.py)
3894539012

39013+
User input accepts a non-empty array of text or image blocks.
39014+
3894639015
<a id="qca.managed.types.user_message_event_params.UserMessageEventParams.content"></a>
3894739016

3894839017
#### content

‎examples/auth/sa_key.py‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""Exchange an SA Key automatically; list Forward templates and Managed agents.
1+
"""Use an SA Key directly for Managed or exchange a shared SAT for both APIs.
22
33
Set QODER_SA_KEY and QODER_SA_REGION=cn|global in the process environment.
4-
Run: python -m examples.auth.sa_key [--async]
4+
Run: python -m examples.auth.sa_key [--async] [--managed-direct]
55
"""
66

77
import argparse
@@ -28,8 +28,14 @@ def config():
2828
return dict(sa_key=os.environ["QODER_SA_KEY"], region=region, scopes=["qca.access", "forward.access"]), host
2929

3030

31-
def main():
31+
def main(*, managed_direct=False):
3232
options, host = config()
33+
if managed_direct:
34+
with Managed(
35+
auth_mode="sa", access_token=options["sa_key"], base_url=f"{host}/api/v1/cloud", max_retries=0
36+
) as managed:
37+
print("Managed agents:", len(managed.agents.list(limit=1).data))
38+
return
3339
with ServiceAccountCredential(**options) as credential:
3440
with (
3541
Forward(credential=credential, base_url=f"{host}/api/v1/forward", max_retries=0) as forward,
@@ -39,8 +45,14 @@ def main():
3945
print("Managed agents:", len(managed.agents.list(limit=1).data))
4046

4147

42-
async def async_main():
48+
async def async_main(*, managed_direct=False):
4349
options, host = config()
50+
if managed_direct:
51+
async with AsyncManaged(
52+
auth_mode="sa", access_token=options["sa_key"], base_url=f"{host}/api/v1/cloud", max_retries=0
53+
) as managed:
54+
print("Managed agents:", len((await managed.agents.list(limit=1)).data))
55+
return
4456
async with AsyncServiceAccountCredential(**options) as credential:
4557
async with (
4658
AsyncForward(credential=credential, base_url=f"{host}/api/v1/forward", max_retries=0) as forward,
@@ -53,9 +65,15 @@ async def async_main():
5365
if __name__ == "__main__":
5466
parser = argparse.ArgumentParser(description=__doc__)
5567
parser.add_argument("--async", dest="use_async", action="store_true")
68+
parser.add_argument(
69+
"--managed-direct", action="store_true", help="Use the SA Key without SAT exchange (Managed only)"
70+
)
5671
args = parser.parse_args()
5772
try:
58-
asyncio.run(async_main()) if args.use_async else main()
73+
if args.use_async:
74+
asyncio.run(async_main(managed_direct=args.managed_direct))
75+
else:
76+
main(managed_direct=args.managed_direct)
5977
except Exception as error:
6078
# Avoid dumping authentication headers from an HTTP error traceback.
6179
print(f"SA Key example failed: {type(error).__name__}")

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "qca-sdk"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
description = "Typed synchronous and asynchronous clients for Qoder Cloud Agents"
55
authors = [{name = "Qoder"}]
66
license = "MIT"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@
143143
from .image_source_param import ImageSourceParam as ImageSourceParam
144144
from .managed_capability_override import ManagedCapabilityOverride as ManagedCapabilityOverride
145145
from .managed_capability_override import ManagedCapabilityOverrideParam as ManagedCapabilityOverrideParam
146+
from .managed_tool_config import ManagedScheduleConfig as ManagedScheduleConfig
146147
from .managed_tool_config import ManagedToolConfig as ManagedToolConfig
148+
from .managed_tool_config_param import ManagedScheduleConfigParam as ManagedScheduleConfigParam
147149
from .managed_tool_config_param import ManagedToolConfigParam as ManagedToolConfigParam
148150
from .mcp_server import MCPServer as MCPServer
149151
from .mcp_server_override import MCPServerOverride as MCPServerOverride
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
from typing import Literal
2+
13
from qca.common._models import BaseModel
24

35

6+
class ManagedScheduleConfig(BaseModel):
7+
"""Template Schedule scope; template confines management to its Schedules."""
8+
9+
access_scope: Literal["identity", "template"]
10+
11+
412
class ManagedToolConfig(BaseModel):
513
"""Forward-managed tools, distinct from tools[].enabled_tools."""
614

715
enabled_tools: list[str]
16+
schedule: ManagedScheduleConfig | None = None
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
from typing import Literal
2+
13
from typing_extensions import TypedDict
24

35

4-
class ManagedToolConfigParam(TypedDict):
5-
"""Replaces the complete enabled list; [] disables all managed tools."""
6+
class ManagedScheduleConfigParam(TypedDict, total=False):
7+
"""Schedule management scope; omission defaults to identity."""
8+
9+
access_scope: Literal["identity", "template"]
10+
11+
12+
class ManagedToolConfigParam(TypedDict, total=False):
13+
"""Replaces the entire Template baseline; {} or enabled_tools=[] clears it."""
614

715
enabled_tools: list[str]
16+
schedule: ManagedScheduleConfigParam | None

‎src/qca/managed/resources/sessions/events.py‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,23 @@ def send(
8686
SystemMessageEventParams,
8787
]
8888
],
89+
busy_mode: Union[Literal["reject", "steer"], NotGiven] = NOT_GIVEN,
8990
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
9091
betas: Union[List[str], None, NotGiven] = NOT_GIVEN,
9192
extra_headers: Dict[str, str] | None = None,
9293
extra_query: Dict[str, Any] | None = None,
9394
extra_body: Dict[str, Any] | None = None,
9495
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
9596
) -> SendSessionEvents:
96-
"""POST /sessions/{session_id}/events."""
97+
"""POST /sessions/{session_id}/events.
98+
99+
Omit busy_mode for the server's reject default (409 during an active Turn).
100+
Use steer (Beta) to append user.message without cancelling the current Turn.
101+
Respond to pending tool confirmation or custom tool results first.
102+
"""
97103
_path = path_template("/sessions/{session_id}/events", session_id=session_id)
98104
options = make_request_options(
99-
body={"events": events},
105+
body={"events": events, "busy_mode": busy_mode},
100106
query={},
101107
headers={"qoder-workspace-id": workspace_id, "x-qoder-beta": betas},
102108
extra_headers=extra_headers,
@@ -231,17 +237,23 @@ async def send(
231237
SystemMessageEventParams,
232238
]
233239
],
240+
busy_mode: Union[Literal["reject", "steer"], NotGiven] = NOT_GIVEN,
234241
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
235242
betas: Union[List[str], None, NotGiven] = NOT_GIVEN,
236243
extra_headers: Dict[str, str] | None = None,
237244
extra_query: Dict[str, Any] | None = None,
238245
extra_body: Dict[str, Any] | None = None,
239246
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
240247
) -> SendSessionEvents:
241-
"""POST /sessions/{session_id}/events."""
248+
"""POST /sessions/{session_id}/events.
249+
250+
Omit busy_mode for the server's reject default (409 during an active Turn).
251+
Use steer (Beta) to append user.message without cancelling the current Turn.
252+
Respond to pending tool confirmation or custom tool results first.
253+
"""
242254
_path = path_template("/sessions/{session_id}/events", session_id=session_id)
243255
options = make_request_options(
244-
body={"events": events},
256+
body={"events": events, "busy_mode": busy_mode},
245257
query={},
246258
headers={"qoder-workspace-id": workspace_id, "x-qoder-beta": betas},
247259
extra_headers=extra_headers,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818

1919

2020
class SessionAgentUpdateParam(TypedDict, total=False):
21+
"""Patch the embedded snapshot, not its ID/version or coordinator roster.
22+
23+
model, system, skills, name and description require session-agent-patch-2026-07-21.
24+
Lists are complete replacements; wait for idle for a clean Turn boundary.
25+
"""
26+
27+
name: str
28+
description: str
2129
model: Union[str, ModelConfigParams]
2230
system: Optional[str]
2331
skills: List[Union[QoderSkillParams, CustomSkillParams]]

0 commit comments

Comments
 (0)