v0.41.0
0.41.0
Breaking Changes
-
Name swap:
AgentSessionnow refers to the wrapper class (previously calledChat), not the Pydantic record. On 0.39.0AgentSessionwas the record type atroboto.ai.core.AgentSession; in this release the record is renamed toAgentSessionRecordandAgentSessionis reused as the wrapper class. Code that followed 0.39.0's guidance and didAgentSession(session_id=..., messages=...)will now hit a wrapper-class constructor with a completely different signature. Update toAgentSessionRecord(...)when constructing the record directly. -
Renamed
ChattoAgentSessionand dropped allChat*backwards-compatibility aliases on the Python SDK surface. Update imports:from roboto.ai import AgentSession(wasChat)from roboto.ai.agent_session import ...(wasroboto.ai.chat)AgentSessionRecord(wasChatRecord)AgentMessage/AgentRole/AgentSessionStatus/ ... (wasChatMessage/ChatRole/ChatStatus/ ...)AgentEvent/AgentTextDeltaEvent/ ... (wasChatEvent/ChatTextDeltaEvent/ ...)StartAgentSessionRequest(wasStartChatRequest)AgentToolDetailResponse(wasChatToolDetailResponse)
The HTTP API is unchanged: URLs still live under
/v1/ai/chats/...and responses still includechat_idfor wire compatibility. -
Consolidated the
AgentSessioncontrol-flow surface down to two methods:run()(driver — auto-dispatches registered client-side tools until user turn; takes a singleon_eventcallback) andevents()(observer — yieldsAgentEventobjects until the session pauses, no auto-dispatch). Removedawait_user_turn(),stream(), andstream_events()— their behaviors are composable fromrun/events. -
Removed
is_user_turn(),is_client_tool_turn(), andis_roboto_turn()inspectors — comparesession.statusagainstAgentSessionStatus.XXXdirectly when branching is needed. -
Removed the
chat_idproperty on the wrapper class; usesession_id. (chat_idremains onAgentSessionRecordas a computed alias for wire compatibility.)
Features Added
AgentSession.start()/send()/send_text()now acceptclient_tools=[ClientTool | ClientToolSpec]to register client-side tools the agent can invoke.- New
AgentSession.run()drives the session until user turn, auto-dispatching registered client-side tools and optionally emitting progress via anon_eventcallback that receives typedAgentEventobjects (text deltas, tool uses, tool results, errors). - New
AgentSession.events()yieldsAgentEventobjects as the agent generates, without auto-dispatching; callers observe and handle tool-dispatch manually by callingsubmit_client_tool_results()betweenevents()loops. - New
ClientToolclass and@client_tooldecorator wrap a Python callable as a client-side tool; name, description, and JSON Schema are inferred from the function's__name__, docstring, and type hints. Per-parameter descriptions are parsed from the docstring'sArgs:section (Google style);typing.Annotated[T, pydantic.Field(description=...)]andparam: T = pydantic.Field(description=...)take precedence over the docstring when both are present. The tool description is the summary/body of the docstring — theArgs:section is stripped out. - New
AgentSession.submit_client_tool_results(results, client_tools=...)for manual tool-result submission when callers want to drive dispatch themselves. - New
AgentSession.unregister_client_tool(name)removes a previously registered callback; symmetric withregister_client_tool. The tool remains declared client-side on the session so a subsequenttool_useproduces an error result rather than being silently skipped. AgentToolUseEventnow carries the parsedinputdict so progress hooks and observers can see the arguments the model chose.AgentToolResultEventnow carries the rawoutputdict andruntime_msalongsidesuccess, so observers can display what a tool actually returned (previously only a success bool was exposed).- New
AgentErrorEventfires fromevents()when an assistant message carriesAgentErrorContent(for example, a failed or cancelled generation), so callers observing the event stream can detect failures without inspectingsession.messagesafterward. AgentSession.start()validates that every initial message has roleUSERorASSISTANT(seeded history); passingROBOTOorSYSTEMraisesValueErrorup front rather than producing an opaque server rejection.
Bugs Fixed
AgentSession.events()no longer emits spuriousAgentStartTextEvent/AgentTextEndEventpairs while a message is still generating across multiple polls. A text span now stays open until the underlying message reaches a terminal status (or a non-text content block arrives within the same message), so a streaming assistant response produces a singleStart → Delta* → Endsequence instead of one per poll.AgentSession.run()no longer submits a client-side errortool_resultfor server-issuedtool_use_ids when a mixed server+client turn lands before the server has mirrored its own tool result. The dispatcher now filters to tool names declared as client-side on the session; server tools are left for the server to answer. Without this filter, twotool_results for the sametool_use_idcould race, producing a Bedrock-invalid turn.