Skip to content
Open
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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ existing `0.1.0` release; earlier development prereleases are not listed.

## [Unreleased]

## [0.17.0]

### Added

- 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.
- 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.
- 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.

### Fixed

- 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.
- 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.

### Breaking changes

- 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.

### Migration

- 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.
- 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.

## [0.16.0]

### Added
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ clients accept the same configuration). `QODER_ACCESS_TOKEN` supplies the select
mode's token; only PAT mode falls back to `QODER_PAT`. Ordinary clients do not read
`QODER_SA_KEY` or implicitly exchange it.

Managed also accepts the complete SA Key directly, without exchanging a SAT:

```python
import os
from qca import Managed

with Managed(auth_mode="sa", access_token=os.environ["QODER_SA_KEY"]) as managed:
agents = managed.agents.list(limit=1)
```

`AsyncManaged` accepts the same static configuration. Forward business APIs
require PAT or SAT, not a raw SA Key. Use the credential below to exchange and
cache a SAT shared by Forward and Managed. The runnable SA Key example preserves
that shared-SAT default; select `python -m examples.auth.sa_key --managed-direct`
(or add `--async`) for Managed-only direct access. Configure the matching CN base
URL explicitly when using a CN key.

```python
from qca import Forward, Managed, ServiceAccountCredential

Expand Down
71 changes: 70 additions & 1 deletion docs/api/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15308,6 +15308,22 @@ class ManagedCapabilityOverride(BaseModel)

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

<a id="qca.forward.types.managed_tool_config.ManagedScheduleConfig"></a>

## ManagedScheduleConfig

```python
class ManagedScheduleConfig(BaseModel)
```

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

Template Schedule scope; template confines management to its Schedules.

<a id="qca.forward.types.managed_tool_config.ManagedScheduleConfig.access_scope"></a>

#### access\_scope

<a id="qca.forward.types.managed_tool_config.ManagedToolConfig"></a>

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

#### enabled\_tools

<a id="qca.forward.types.managed_tool_config.ManagedToolConfig.schedule"></a>

#### schedule

<a id="qca.forward.types.managed_tool_config_param"></a>

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

<a id="qca.forward.types.managed_tool_config_param.ManagedScheduleConfigParam"></a>

## ManagedScheduleConfigParam

```python
class ManagedScheduleConfigParam(TypedDict)
```

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

Schedule management scope; omission defaults to identity.

<a id="qca.forward.types.managed_tool_config_param.ManagedScheduleConfigParam.access_scope"></a>

#### access\_scope

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

## ManagedToolConfigParam
Expand All @@ -15338,12 +15374,16 @@ class ManagedToolConfigParam(TypedDict)

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

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

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

#### enabled\_tools

<a id="qca.forward.types.managed_tool_config_param.ManagedToolConfigParam.schedule"></a>

#### schedule

<a id="qca.forward.types.mcp_server"></a>

# qca.forward.types.mcp\_server
Expand Down Expand Up @@ -24989,6 +25029,7 @@ def send(
UserToolResultEventParams,
SystemMessageEventParams,
]],
busy_mode: Union[Literal["reject", "steer"], NotGiven] = NOT_GIVEN,
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
betas: Union[List[str], None, NotGiven] = NOT_GIVEN,
extra_headers: Dict[str, str] | None = None,
Expand All @@ -25002,6 +25043,10 @@ def send(

POST /sessions/{session_id}/events.

Omit busy_mode for the server's reject default (409 during an active Turn).
Use steer (Beta) to append user.message without cancelling the current Turn.
Respond to pending tool confirmation or custom tool results first.

<a id="qca.managed.resources.sessions.events.Events.stream"></a>

#### stream
Expand Down Expand Up @@ -25108,6 +25153,7 @@ async def send(
UserToolResultEventParams,
SystemMessageEventParams,
]],
busy_mode: Union[Literal["reject", "steer"], NotGiven] = NOT_GIVEN,
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
betas: Union[List[str], None, NotGiven] = NOT_GIVEN,
extra_headers: Dict[str, str] | None = None,
Expand All @@ -25121,6 +25167,10 @@ async def send(

POST /sessions/{session_id}/events.

Omit busy_mode for the server's reject default (409 during an active Turn).
Use steer (Beta) to append user.message without cancelling the current Turn.
Respond to pending tool confirmation or custom tool results first.

<a id="qca.managed.resources.sessions.events.AsyncEvents.stream"></a>

#### stream
Expand Down Expand Up @@ -35321,6 +35371,19 @@ class SessionAgentUpdateParam(TypedDict)

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

Patch the embedded snapshot, not its ID/version or coordinator roster.

model, system, skills, name and description require session-agent-patch-2026-07-21.
Lists are complete replacements; wait for idle for a clean Turn boundary.

<a id="qca.managed.types.session_agent_update_param.SessionAgentUpdateParam.name"></a>

#### name

<a id="qca.managed.types.session_agent_update_param.SessionAgentUpdateParam.description"></a>

#### description

<a id="qca.managed.types.session_agent_update_param.SessionAgentUpdateParam.model"></a>

#### model
Expand Down Expand Up @@ -35823,6 +35886,10 @@ class SessionEventSendParams(TypedDict)

#### events

<a id="qca.managed.types.session_event_send_params.SessionEventSendParams.busy_mode"></a>

#### busy\_mode

<a id="qca.managed.types.session_event_send_params.SessionEventSendParams.workspace_id"></a>

#### workspace\_id
Expand Down Expand Up @@ -38943,6 +39010,8 @@ class UserMessageEventParams(TypedDict)

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

User input accepts a non-empty array of text or image blocks.

<a id="qca.managed.types.user_message_event_params.UserMessageEventParams.content"></a>

#### content
Expand Down
28 changes: 23 additions & 5 deletions examples/auth/sa_key.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Exchange an SA Key automatically; list Forward templates and Managed agents.
"""Use an SA Key directly for Managed or exchange a shared SAT for both APIs.

Set QODER_SA_KEY and QODER_SA_REGION=cn|global in the process environment.
Run: python -m examples.auth.sa_key [--async]
Run: python -m examples.auth.sa_key [--async] [--managed-direct]
"""

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


def main():
def main(*, managed_direct=False):
options, host = config()
if managed_direct:
with Managed(
auth_mode="sa", access_token=options["sa_key"], base_url=f"{host}/api/v1/cloud", max_retries=0
) as managed:
print("Managed agents:", len(managed.agents.list(limit=1).data))
return
with ServiceAccountCredential(**options) as credential:
with (
Forward(credential=credential, base_url=f"{host}/api/v1/forward", max_retries=0) as forward,
Expand All @@ -39,8 +45,14 @@ def main():
print("Managed agents:", len(managed.agents.list(limit=1).data))


async def async_main():
async def async_main(*, managed_direct=False):
options, host = config()
if managed_direct:
async with AsyncManaged(
auth_mode="sa", access_token=options["sa_key"], base_url=f"{host}/api/v1/cloud", max_retries=0
) as managed:
print("Managed agents:", len((await managed.agents.list(limit=1)).data))
return
async with AsyncServiceAccountCredential(**options) as credential:
async with (
AsyncForward(credential=credential, base_url=f"{host}/api/v1/forward", max_retries=0) as forward,
Expand All @@ -53,9 +65,15 @@ async def async_main():
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--async", dest="use_async", action="store_true")
parser.add_argument(
"--managed-direct", action="store_true", help="Use the SA Key without SAT exchange (Managed only)"
)
args = parser.parse_args()
try:
asyncio.run(async_main()) if args.use_async else main()
if args.use_async:
asyncio.run(async_main(managed_direct=args.managed_direct))
else:
main(managed_direct=args.managed_direct)
except Exception as error:
# Avoid dumping authentication headers from an HTTP error traceback.
print(f"SA Key example failed: {type(error).__name__}")
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 = "qca-sdk"
version = "0.16.0"
version = "0.17.0"
description = "Typed synchronous and asynchronous clients for Qoder Cloud Agents"
authors = [{name = "Qoder"}]
license = "MIT"
Expand Down
2 changes: 2 additions & 0 deletions src/qca/forward/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@
from .image_source_param import ImageSourceParam as ImageSourceParam
from .managed_capability_override import ManagedCapabilityOverride as ManagedCapabilityOverride
from .managed_capability_override import ManagedCapabilityOverrideParam as ManagedCapabilityOverrideParam
from .managed_tool_config import ManagedScheduleConfig as ManagedScheduleConfig
from .managed_tool_config import ManagedToolConfig as ManagedToolConfig
from .managed_tool_config_param import ManagedScheduleConfigParam as ManagedScheduleConfigParam
from .managed_tool_config_param import ManagedToolConfigParam as ManagedToolConfigParam
from .mcp_server import MCPServer as MCPServer
from .mcp_server_override import MCPServerOverride as MCPServerOverride
Expand Down
9 changes: 9 additions & 0 deletions src/qca/forward/types/managed_tool_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
from typing import Literal

from qca.common._models import BaseModel


class ManagedScheduleConfig(BaseModel):
"""Template Schedule scope; template confines management to its Schedules."""

access_scope: Literal["identity", "template"]


class ManagedToolConfig(BaseModel):
"""Forward-managed tools, distinct from tools[].enabled_tools."""

enabled_tools: list[str]
schedule: ManagedScheduleConfig | None = None
13 changes: 11 additions & 2 deletions src/qca/forward/types/managed_tool_config_param.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
from typing import Literal

from typing_extensions import TypedDict


class ManagedToolConfigParam(TypedDict):
"""Replaces the complete enabled list; [] disables all managed tools."""
class ManagedScheduleConfigParam(TypedDict, total=False):
"""Schedule management scope; omission defaults to identity."""

access_scope: Literal["identity", "template"]


class ManagedToolConfigParam(TypedDict, total=False):
"""Replaces the entire Template baseline; {} or enabled_tools=[] clears it."""

enabled_tools: list[str]
schedule: ManagedScheduleConfigParam | None
20 changes: 16 additions & 4 deletions src/qca/managed/resources/sessions/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,23 @@ def send(
SystemMessageEventParams,
]
],
busy_mode: Union[Literal["reject", "steer"], NotGiven] = NOT_GIVEN,
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
betas: Union[List[str], None, NotGiven] = NOT_GIVEN,
extra_headers: Dict[str, str] | None = None,
extra_query: Dict[str, Any] | None = None,
extra_body: Dict[str, Any] | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SendSessionEvents:
"""POST /sessions/{session_id}/events."""
"""POST /sessions/{session_id}/events.

Omit busy_mode for the server's reject default (409 during an active Turn).
Use steer (Beta) to append user.message without cancelling the current Turn.
Respond to pending tool confirmation or custom tool results first.
"""
_path = path_template("/sessions/{session_id}/events", session_id=session_id)
options = make_request_options(
body={"events": events},
body={"events": events, "busy_mode": busy_mode},
query={},
headers={"qoder-workspace-id": workspace_id, "x-qoder-beta": betas},
extra_headers=extra_headers,
Expand Down Expand Up @@ -231,17 +237,23 @@ async def send(
SystemMessageEventParams,
]
],
busy_mode: Union[Literal["reject", "steer"], NotGiven] = NOT_GIVEN,
workspace_id: Union[str, None, NotGiven] = NOT_GIVEN,
betas: Union[List[str], None, NotGiven] = NOT_GIVEN,
extra_headers: Dict[str, str] | None = None,
extra_query: Dict[str, Any] | None = None,
extra_body: Dict[str, Any] | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SendSessionEvents:
"""POST /sessions/{session_id}/events."""
"""POST /sessions/{session_id}/events.

Omit busy_mode for the server's reject default (409 during an active Turn).
Use steer (Beta) to append user.message without cancelling the current Turn.
Respond to pending tool confirmation or custom tool results first.
"""
_path = path_template("/sessions/{session_id}/events", session_id=session_id)
options = make_request_options(
body={"events": events},
body={"events": events, "busy_mode": busy_mode},
query={},
headers={"qoder-workspace-id": workspace_id, "x-qoder-beta": betas},
extra_headers=extra_headers,
Expand Down
8 changes: 8 additions & 0 deletions src/qca/managed/types/session_agent_update_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@


class SessionAgentUpdateParam(TypedDict, total=False):
"""Patch the embedded snapshot, not its ID/version or coordinator roster.

model, system, skills, name and description require session-agent-patch-2026-07-21.
Lists are complete replacements; wait for idle for a clean Turn boundary.
"""

name: str
description: str
model: Union[str, ModelConfigParams]
system: Optional[str]
skills: List[Union[QoderSkillParams, CustomSkillParams]]
Expand Down
3 changes: 2 additions & 1 deletion src/qca/managed/types/session_event_send_params.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, List, Optional, Union
from typing import TYPE_CHECKING, List, Literal, Optional, Union

from typing_extensions import Required, TypedDict

Expand Down Expand Up @@ -30,5 +30,6 @@ class SessionEventSendParams(TypedDict, total=False):
]
]
]
busy_mode: Literal["reject", "steer"]
workspace_id: Optional[str]
betas: List[str]
Loading