latent.agents.response¶
Structured agent response for conversation simulation.
Classes¶
AgentResponse¶
Response from an agent in a conversation simulation.
Attributes: text: The agent's text response. tool_calls: Tool calls made during response generation. should_end: Whether the agent signals the conversation should end.
StreamingAgent¶
Protocol for agents compatible with respond_from_events.
Requires run() (async LLM call) and events (populated by run).
Satisfied by ReActAgent and its subclasses.
ToolCallRecord¶
A single tool call extracted from agent events.
Attributes: tool_name: Name of the tool that was called. arguments: Arguments passed to the tool.
Functions¶
respond_from_events¶
respond_from_events(agent: StreamingAgent, messages: list[Message], end_tool_name: str = END_CALL_TOOL_NAME) -> AgentResponse
Standard respond() implementation for agents in conversation simulation.
Calls agent.run(messages) (which clears and repopulates agent.events),
then inspects events for tool calls and end-of-conversation signals.
Args:
agent: A ReActAgent (or subclass) with run() and events.
messages: Conversation history as Message objects.
end_tool_name: Tool name that signals conversation end.
Returns: AgentResponse with text, typed tool calls, and end signal.