Conversation control
Conversation control — loading the slides…
A conversation is more than messages. The company can ask the user to sign in part-way through, the user can talk to the company directly through the agent's interface, either side can bring in a person, and the agent can close it. The paired examples drive one Manzanita conversation through all four, against a Manzanita with a support desk staffed.
- Sign-in mid-conversation (§8.11). An
authorizationevent is alwaysinsufficient_scope, with thescopethe request needs. The host signs the user in with any mode the company offers and keeps sending to the same conversation ID, in the same Session, with the new access token. - Direct Conversations (§8.10). Only the personal agent starts one, for
the user to talk with the company in the agent's interface. While it is
open, the parent refuses messages and handoff with
direct_conversation_open; the SDK puts the open conversation's ID inerror.details["conversation_id"]. - Handoff (§8.9).
handoff()asks for a person;handoffispendinguntil one takes it, thenresponderishuman, and the person's messages name theirauthor:typehuman, with the person'sidandnamewhen the company gives them. When no one is available the company says so and the agent continues. - Closing (§8.12).
close()ends the conversation; it doesn't cancel anything the conversation started, such as an order or a return.
The model sees event types, the state fields, the company's answers, and error codes. Tokens, the device code, and Session JWTs stay host-only; the user code is shown to the user by the host, not by the model.
TypeScript: startDirect(), handoff(), and close() on
ConversationClient, with the same error codes and details.
- Run the Pydantic AI example.
- Run the Agent Runtimes example.
- Read the conversations guide.