Skip to content

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.

ChatResponse.messages: list of ContentItem

Content items in the response.

ChatResponse.raw: dict

Original API response data for debugging and advanced use.

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, or None if not available.
ChatResponse.tool_results(
name: Optional[str] = None, status: Optional[str] = None
) -> list[ToolResult]

Filter tool results by name and/or status.

Parameters:

  • name

    (str, default: None) - Tool name to filter by.
  • status

    (str, default: None) - Status to filter by (e.g., "success", "error").

Returns:

  • list of ToolResult - Matching tool result objects.
ChatResponse.tool_calls(name: Optional[str] = None) -> list[ToolCall]

Filter tool calls by name.

Parameters:

  • name

    (str, default: None) - Tool name to filter by.

Returns:

  • list of ToolCall - Matching tool call objects.
ChatResponse.text_content() -> list[str]

Extract all text content from messages.

Returns:

  • list of str - Text strings from all messages with content.
ChatResponse.full_text() -> str

Get all text content concatenated.

Returns:

  • str - All message text joined by newlines.
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.
 agent > cortex > chat
└──  CortexAgentChat
    └──  send