ChatResponse
relationalai.agent.cortex.chat
ChatResponse(messages: list[ContentItem], raw: dict)Complete response from an agent conversation turn.
Contains all content items generated during a single agent interaction, including text responses, tool calls, and tool results. Provides utility methods for filtering, asserting, and debugging response content.
Attributes
Section titled “Attributes”.messages
Section titled “.messages”ChatResponse.messages: list of ContentItemContent items in the response.
ChatResponse.raw: dictOriginal API response data for debugging and advanced use.
Methods
Section titled “Methods”.usage()
Section titled “.usage()”ChatResponse.usage() -> Optional[Usage]Token usage data from the Cortex API for this turn, if available.
Returns:
Usage or None- Token usage for this turn, orNoneif not available.
.tool_results()
Section titled “.tool_results()”ChatResponse.tool_results( name: Optional[str] = None, status: Optional[str] = None) -> list[ToolResult]Filter tool results by name and/or status.
Parameters:
(namestr, default:None) - Tool name to filter by.
(statusstr, default:None) - Status to filter by (e.g.,"success","error").
Returns:
list of ToolResult- Matching tool result objects.
.tool_calls()
Section titled “.tool_calls()”ChatResponse.tool_calls(name: Optional[str] = None) -> list[ToolCall]Filter tool calls by name.
Parameters:
(namestr, default:None) - Tool name to filter by.
Returns:
list of ToolCall- Matching tool call objects.
.text_content()
Section titled “.text_content()”ChatResponse.text_content() -> list[str]Extract all text content from messages.
Returns:
list of str- Text strings from all messages with content.
.full_text()
Section titled “.full_text()”ChatResponse.full_text() -> strGet all text content concatenated.
Returns:
str- All message text joined by newlines.
.tool_usage_summary()
Section titled “.tool_usage_summary()”ChatResponse.tool_usage_summary() -> dict[str, int]Get tool call counts by tool name.
Returns:
dict of str to int- Dictionary mapping tool names to call counts.
Returned By
Section titled “Returned By”agent > cortex > chat └── CortexAgentChat └── send