Skip to main content
You can call Atlas AI agents from the Cognite Python SDK or the Agents REST API to embed agents in your applications, automate workflows, and build custom user interfaces.
Beta / Alpha: The Agents API is in beta. The Python SDK support is in alpha and subject to change.

Prerequisites

Chatting with an agent

Send a message to an agent and read the response:
from cognite.client import CogniteClient
from cognite.client.data_classes.agents import Message

client = CogniteClient()

response = client.agents.chat(
    agent_external_id="my_agent",
    messages=Message("What can you tell me about compressor C-101?"),
)

print(response.text)

Continuing a conversation

Use the cursor from the previous response to continue the same conversation. You do not need to resend previous messages — the cursor keeps track of conversation state:
follow_up = client.agents.chat(
    agent_external_id="my_agent",
    messages=Message("What are the related time series?"),
    cursor=response.cursor,
)

print(follow_up.text)

Handling tool confirmation

When an agent uses an integration tool — Call Function, Run Python code, or Call REST API — the response may include a tool confirmation request before the tool runs. This is a security measure to prevent the agent from performing destructive or unintended actions without explicit approval. The confirmation appears as a toolConfirmation action in the response. Your application must respond with ALLOW to proceed or DENY to cancel. In the Python SDK, response.action_calls is None when the response contains no actions, so check for it before you iterate over it.

The confirmation flow

1

Send a message that triggers a confirmation-required tool

Your message causes the agent to want to run an integration tool.
2

Receive a toolConfirmation action in the response

The response contains an action with type: "toolConfirmation" instead of the final result. It includes the tool name, arguments, and a human-readable description of what the tool will do.
3

Inspect and decide: ALLOW or DENY

Your application reviews the tool call details and sends back ALLOW to execute it or DENY to cancel it.
4

Receive the final response

The agent executes (or skips) the tool and returns the final result.

Example

from cognite.client import CogniteClient
from cognite.client.data_classes.agents import Message, ToolConfirmationCall, ToolConfirmationResult

client = CogniteClient()

# Step 1: Send the initial message
response = client.agents.chat(
    agent_external_id="my_agent",
    messages=Message("Run the data quality check function"),
)

# Step 2: Check for tool confirmation requests
if response.action_calls:
    confirmations = []
    for action in response.action_calls:
        if isinstance(action, ToolConfirmationCall):
            print(f"Agent wants to run: {action.tool_name}")
            print(f"Tool type: {action.tool_type}")
            print(f"Arguments: {action.tool_arguments}")
            print(f"Description: {action.tool_description}")

            confirmations.append(
                ToolConfirmationResult(
                    action_id=action.action_id,
                    status="ALLOW",  # or "DENY" to cancel
                )
            )

    # Step 3: Send ALLOW or DENY
    if confirmations:
        response = client.agents.chat(
            agent_external_id="my_agent",
            messages=confirmations,
            cursor=response.cursor,
        )

# Step 4: Print the final result
print(response.text)
Include the cursor from the confirmation response in your ALLOW or DENY request so the agent continues the same conversation.

Learn more

Last modified on March 31, 2026