Core Run Management¶
cortex_agents.core.run.AgentRun ¶
Execute synchronous Cortex Agent runs.
Source code in cortex_agents/core/run.py
run ¶
run(*, query: str | None = None, agent_name: str | None = None, database: str | None = None, schema: str | None = None, thread_id: str | int | None = None, parent_message_id: str | int | None = None, tool_choice: dict[str, Any] | None = None, messages: Iterable[dict[str, Any]] | None = None, agent_config: Mapping[str, Any] | None = None, stream: bool = True) -> AgentResponse
Execute a Cortex Agent run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | None
|
User query string. |
None
|
agent_name
|
str | None
|
Name of saved agent to run (optional). |
None
|
database
|
str | None
|
Database name (required if agent_name provided). |
None
|
schema
|
str | None
|
Schema name (required if agent_name provided). |
None
|
thread_id
|
str | int | None
|
Thread ID for multi-turn conversations (optional). |
None
|
parent_message_id
|
str | int | None
|
Parent message ID in thread (required if thread_id set). |
None
|
tool_choice
|
dict[str, Any] | None
|
Tool selection strategy (optional). |
None
|
messages
|
Iterable[dict[str, Any]] | None
|
Conversation history messages (optional). |
None
|
agent_config
|
Mapping[str, Any] | None
|
Inline agent configuration for ephemeral runs (optional). |
None
|
Returns:
| Type | Description |
|---|---|
AgentResponse
|
AgentResponse with streaming support. |
Raises:
| Type | Description |
|---|---|
SnowflakeAPIError
|
If the request fails or parameters are invalid. |
Examples:
# Run saved agent
response = runner.run(
query="What's the revenue?",
agent_name="MY_AGENT",
database="DB",
schema="SCHEMA"
)
# Stream events
for event in response:
print(event)
Source code in cortex_agents/core/run.py
cortex_agents.core.run.AsyncAgentRun ¶
Execute asynchronous Cortex Agent runs.
Source code in cortex_agents/core/run.py
run
async
¶
run(*, query: str | None = None, agent_name: str | None = None, database: str | None = None, schema: str | None = None, thread_id: str | int | None = None, parent_message_id: str | int | None = None, tool_choice: dict[str, Any] | None = None, messages: Iterable[dict[str, Any]] | None = None, agent_config: Mapping[str, Any] | None = None, stream: bool = True) -> AgentResponse
Execute a Cortex Agent run (async).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | None
|
User query string. |
None
|
agent_name
|
str | None
|
Name of saved agent to run (optional). |
None
|
database
|
str | None
|
Database name (required if agent_name provided). |
None
|
schema
|
str | None
|
Schema name (required if agent_name provided). |
None
|
thread_id
|
str | int | None
|
Thread ID for multi-turn conversations (optional). |
None
|
parent_message_id
|
str | int | None
|
Parent message ID in thread (required if thread_id set). |
None
|
tool_choice
|
dict[str, Any] | None
|
Tool selection strategy (optional). |
None
|
messages
|
Iterable[dict[str, Any]] | None
|
Conversation history messages (optional). |
None
|
agent_config
|
Mapping[str, Any] | None
|
Inline agent configuration for ephemeral runs (optional). |
None
|
Returns:
| Type | Description |
|---|---|
AgentResponse
|
AgentResponse with async streaming support. |
Raises:
| Type | Description |
|---|---|
SnowflakeAPIError
|
If the request fails or parameters are invalid. |
Examples:
# Run saved agent
response = await runner.run(
query="What's the revenue?",
agent_name="MY_AGENT",
database="DB",
schema="SCHEMA"
)
# Stream events asynchronously
async for event in response:
print(event)
Source code in cortex_agents/core/run.py
cortex_agents.core.run.RunRequest
dataclass
¶
Resolved endpoint and payload for a Cortex Agent :run invocation.
Attributes:
| Name | Type | Description |
|---|---|---|
endpoint |
str
|
API endpoint URL for the run request. |
payload |
dict[str, Any]
|
Request payload containing messages and configuration. |