Skip to main content
Version: 1.68

Agents

The Python client lets you manage Agents from code: list, create, and update agents in a Workspace, and read back their sessions and traces.

Prerequisites​

Configure a Client with a Workspace, as described in Authentication. All agent methods require a Workspace to be set.

Managing agents​

List agents​

agents = client.get_agents(include_deployments=False, tag_name=None)

get_agents returns a list of Agent objects. Pass include_deployments=True to also return each agent's linked Deployments, and tag_name to filter by tag.

Get a single agent​

agent = client.get_agent(agent_id, include_deployments=True)

By default, Deployments are included for a single agent (unlike the list call).

Create an agent​

from deeploy import CreateAgent

create_options: CreateAgent = {
"name": "Support Bot",
"intended_purpose": "Resolve tier-1 support tickets without human handoff",
}

agent = client.create_agent(create_options)

name is required and must be unique within the Workspace. intended_purpose, use_case_id, deployment_ids, and tags are optional.

Update an agent​

from deeploy import UpdateAgent

update_options: UpdateAgent = {
"intended_purpose": "Resolve tier-1 and tier-2 support tickets",
}

updated_agent = client.update_agent(agent_id, update_options)

Updates are partial: omitted fields are left unchanged, while use_case_id: None unlinks the agent from its use case, and supplying deployment_ids/tags replaces the existing associations.

Reading sessions and traces​

Agent sessions​

sessions = client.get_agent_traces(agent_id)

get_agent_traces returns a list of AgentTrace session summaries (trace ID, start time, duration, user, session type, models, tool calls, and total tokens). Use the options argument to page through results (offset, limit, up to 1000), restrict a time window (start/end in Unix milliseconds), and apply filters; the backend defaults to the 20 most recent sessions when no options are given.

Trace detail​

trace = client.get_agent_trace(agent_id, trace_id)

get_agent_trace returns the raw trace payload as a dictionary, since its shape is not yet stabilized into a typed model.