CortexAgentChat
CortexAgentChat( client: httpx.Client, name: str, db="SNOWFLAKE_INTELLIGENCE", schema="AGENTS", app_name="",)High-level client for conversing with deployed Cortex agents.
Provides a simple interface for interacting with agents defined in Snowflake. The agent handles tool execution server-side, manages conversation state through threads, and you simply send messages and receive structured responses.
Parameters
Section titled “Parameters”
(clienthttpx.Client) - Configuredhttpx.Clientwith authentication headers.
(namestr) - Agent name to interact with.
(dbstr, default:“SNOWFLAKE_INTELLIGENCE”) - Database name. Default:"SNOWFLAKE_INTELLIGENCE".
(schemastr, default:“AGENTS”) - Schema name. Default:"AGENTS".
(app_namestr, default:"") - Optional application identifier for thread grouping.
Examples
Section titled “Examples”>>> chat = CortexAgentChat(client=client, name="my_agent")>>> response = chat.send("What can I ask about?")>>> print(response.full_text())Methods
Section titled “Methods”.config()
Section titled “.config()”CortexAgentChat.config() -> dictRetrieve the agent’s configuration.
Fetches the complete agent specification from the API and returns it as a dictionary.
Returns:
dict- Dictionary containing agent name andcortex_agentspecification.
Raises:
AssertionError- Ifagent_specis not present in the response.httpx.HTTPStatusError- If the API request fails.
.send()
Section titled “.send()”CortexAgentChat.send(prompt: str) -> ChatResponseSend a message to the agent and get the response.
Creates a thread if this is the first message, then sends the prompt
to the agent and returns the complete response including any tool calls
and results. Automatically maintains conversation context across
multiple send() calls.
Parameters:
(promptstr) - User message to send to the agent.
Returns:
ChatResponse- The agent’s reply including tool interactions.
Raises:
httpx.HTTPStatusError- If the API request fails.AssertionError- If the response doesn’t contain expected content.
.thread_id()
Section titled “.thread_id()”CortexAgentChat.thread_id() -> intGet the current thread ID, creating one if necessary.
Returns:
int- Thread ID for this conversation.
.messages()
Section titled “.messages()”CortexAgentChat.messages() -> ListRetrieve all messages from the current conversation thread.
Fetches the complete message history from the server, including both user and assistant messages. Messages are returned in descending order (newest first) by default.
Returns:
list of CortexThreadApi.Message- Conversation history.
Raises:
RAIException- If no thread exists yet (callsend()first).httpx.HTTPStatusError- If the API request fails.
Returned By
Section titled “Returned By”agent > cortex > cortex_agent_manager └── CortexAgentManager └── chat