Repository navigation
Several decision questions in one request
Until now a decision agent answered one question per ask(). Asking "is it spam, which team, how urgent" about one support ticket took three agents and three requests, each sending the same ticket again.
Now the response_schema can be a flat class. Each field is one question, and all of them go out in a single request, so the shared input is sent and billed once:
@dataclass
class TicketTriage:
is_spam: Annotated[bool, Question("Is this message spam?")]
department: Annotated[Department, Question("Which team should handle this ticket?")]
urgency: Annotated[Urgency, Question("How urgent is this ticket?")]
triage = Agent(
"triage",
prompt="You triage support tickets.",
config=OpenAIDecisionsConfig(),
response_schema=TicketTriage,
)
reply = await triage.ask("I was charged twice this month.")
await reply.content() # TicketTriage(is_spam=False, department=Department.BILLING, urgency=Urgency.HIGH)
reply.response.metadata["department"]["confidence"] # 0.74It works with both OpenAIDecisionsConfig and TypeSafeConfig, and with a dataclass, a TypedDict or a Pydantic model. There is no new config or flag: a scalar schema is still one question, as before. A class the decision APIs can't answer (nested fields, Optional, defaults, a field without a question) is rejected locally, before any request goes out.
Token usage you can compare across providers
Usage.prompt_tokens meant different things depending on the provider. OpenAI and Gemini count cached tokens in the prompt; Anthropic and Bedrock reported only the uncached part. On a prompt-cached Anthropic call, prompt_tokens could be 3 while the model actually read 8,630 tokens, and every consumer (telemetry, TokenMonitor, UsageReport totals across a mixed-provider delegation tree) inherited the gap.
The rule is now fixed in one place, the provider mappers:
prompt_tokensis the whole input, including cache reads and writes;cache_read_input_tokensandcache_creation_input_tokensare parts of it, never additions;total_tokens >= prompt_tokens + completion_tokens.
Gemini Live follows the same rule: thinking tokens are now part of completion_tokens, as they already were for batch Gemini and xAI.
Behaviour change. On Anthropic and Bedrock,
prompt_tokens,total_tokens, telemetrygen_ai.usage.input_tokensand the input metric grow by the cached tokens. On Gemini Live thinking models,completion_tokensandtotal_tokensgrow by the thinking tokens. Token budgets andTokenMonitorthresholds are reached sooner on these workloads. Usage stored by earlier versions is not rewritten.
ACP 1.0
Breaking change. The
acpextra now requiresagent-client-protocol>=1.0.0,<2; 0.12.x is no longer supported. If you pinagent-client-protocolyourself, update that pin before upgrading.
- Messages stay separate. Before, every message chunk of a turn was joined into one string, so two messages ran together (
"Let me check.Done."). Each message is now its ownModelMessageevent, andreply.bodyis the agent's final message rather than everything it said. - More content survives. Text and blob resources, resource links, and the structure of tool results are no longer dropped.
- Sessions close cleanly. A session left open when the event loop shuts down no longer fails with
asynchronous generator is already running, soClaudeCodeConfigand the other client configs work withoutasync with. - Workspace paths are absolute.
cwdandadditional_directoriesare resolved when a session starts, which the realclaude-agent-acprequires.
Also changed: ag2.acp.AuthMethod drops the env-var method the SDK removed, BridgeState.turn_text is replaced by turn_messages, and PermissionPolicy is now exported from ag2.acp.
Python 3.15
AG2 is now tested and type-checked on Python 3.15 and lists it as supported.
PyYAML, a required dependency, has not published Python 3.15 wheels yet (yaml/pyyaml#994). Until it does, pip install ag2 on 3.15 builds PyYAML from source, which needs a C compiler. Linux and macOS usually have one; Windows without build tools may fail to install.
AG-UI
- assistant-ui quickstart. A new guide builds an assistant-ui chat on an AG2 server, with tool results, tool approval and shared state. Documentation
- Strict Base64 for inline media. Characters outside the Base64 alphabet used to be silently dropped, so a corrupted image or thought signature reached the model.
DataSource.valueandencryptedValueare now decoded strictly and a bad value is answered with400before the stream starts. This includes whitespace and line breaks, which were ignored before.
Fixes
- Agent: A turn that ends on a final tool result or a client-tool handoff now ends there, even when input was queued during it. Before, the queued input triggered one more model call that replaced the final result or dropped the client calls. The queued input now goes to the next turn.
- Gemini Live: Thought summaries arrive as
ModelReasoningand are no longer part of the reply text. - A2A: The basic server example supplies its agent card URL.
Documentation and project
- Examples for networks, Hub authentication, input factories and Perplexity were aligned with the current APIs.
- Live Anthropic tests run on Haiku 5.5.
What's Changed
- fix(usage)!: count prompt-cache tokens in prompt_tokens for Anthropic… by @vvlrff in #3620
- docs: clarify Perplexity answer compatibility and results by @shuaiyafei in #3586
- docs: fix vendor metadata examples for input factories by @shuaiyafei in #3601
- docs: align network Rule example with nested policy fields by @shuaiyafei in #3602
- docs: fix manual human invite acknowledgement by @shuaiyafei in #3640
- docs: fix direct network view projection example by @shuaiyafei in #3645
- docs: align network recovery examples with current APIs by @shuaiyafei in #3646
- fix(agent): end the turn on a forced response even with input queued by @coder-abu in #3639
- fix(ag-ui): reject invalid Base64 characters in inline media by @BlueLi66 in #3641
- docs(ag-ui): add assistant-ui quickstart by @vvlrff in #3649
- docs: align Hub authentication and identity examples by @shuaiyafei in #3650
- ci: upgrade live Anthropic tests to Haiku 5.5 by @marklysze in #3655
- chore(deps): bump opentelemetry-api from 1.45.1 to 1.45.2 by @dependabot[bot] in #3668
- chore(deps): bump dnspython from 2.9.0 to 2.9.2 by @dependabot[bot] in #3669
- fix(live): include Gemini Live thinking tokens in completion usage by @Assertive-xxh in #3667
- fix(a2a): supply the basic server example card URL by @shuaiyafei in #3665
- ci: add Python 3.15 to test and type-check matrices by @vvlrff in #3671
- fix(live): keep Gemini Live thought summaries out of the reply text by @Assertive-xxh in #3673
- chore(acp): migrate to agent-client-protocol 1.0.0 by @vvlrff in #3402
- feat(response): ask several decision questions in one request by @vvlrff in #3656
- chore: bump version to 1.3.2 by @vvlrff in #3676
New Contributors
- @BlueLi66 made their first contribution in #3641
- @Assertive-xxh made their first contribution in #3667
Full Changelog: v.1.3.1...v1.3.2