user-robot-xmarksAgents

Master agent lifecycle operations, orchestration patterns, and runtime controls with the Python SDK. Use CLI pages for low-code operations. Use REST as reference-only for internal integrations (for example GLChat).

circle-info

For current coverage, see the AIP capability matrixarrow-up-right. Key callouts for agents: CLI still leans on export/import for tool_configs, memory toggles, and runtime overrides. Run history and scheduling are available via the SDK; REST remains reference-only.

circle-info

CLI examples accept either an agent ID or a unique name for AGENT_REF. Partial matches trigger fuzzy search; add --select to disambiguate or pass the full ID when you need a deterministic lookup.

Execution Modes: Local vs Remote

See Local vs Remote Modearrow-up-right for detailed comparison and decision checklist.

Pattern Decision Guide

Choose the right pattern for your agent operations:

Use for creating and deploying single agents with simple configuration.

from glaip_sdk import Agent
from tools import CalculatorTool  # Your LangChain BaseTool class

agent = Agent(
    name="math-tutor",
    instruction="You are a patient tutor. Show working for every step.",
    tools=[CalculatorTool],  # Use LangChain BaseTool classes for local execution
    agent_config={"memory": "mem0"}
)

# Run the agent
result = agent.run("What is 15 * 23?")

Use this pattern for:

  • Creating and running single agents

  • Simple agent configuration

  • Quick prototypes

  • Self-contained agent operations

Client Pattern (Legacy/Advanced)

Use for listing, searching, and batch operations across multiple agents. This is a legacy/advanced pattern kept for backward compatibility and cross-agent governance workflows; prefer the Agent-first pattern for creating, updating, and running individual agents.

Use this pattern for:

  • Listing and searching agents

  • Batch operations across multiple agents

  • Complex resource management workflows

  • Multi-agent coordination

circle-exclamation

Create Agents

Python SDK

Recommended: Agent Pattern

Deprecated client pattern (still supported)

The older client.agents.create_agent API is kept for backward compatibility but new code should prefer the Agent pattern above for a simpler, low-code workflow and future improvements.

CLI

Specifying the Model

Agents use a default model (openai/gpt-5-nano) unless you specify otherwise. Use the model parameter with the standardized provider/model format:

Using Model Constants (Recommended):

Using String Format:

Using Model Class (Custom Configuration):

circle-info

Model Constants: Import typed constants from glaip_sdk.models for better IDE support and validation:

  • from glaip_sdk.models import OpenAI, Anthropic, Google, AzureOpenAI, DeepInfra, DeepSeek, Bedrock

  • Use from glaip_sdk.models import DEFAULT_MODEL to see the current default

See the Language modelsarrow-up-right for the complete list of available models.

In JSON definitions, disable planning by setting "planning": false in agent_config when you want a standard single-pass agent instead of a planning-enabled one.

circle-info

Agent.deploy() will create a new agent when it does not exist yet, and update the existing definition when called again with the same reference. Use agent.update() when you already have a deployed Agent instance and want to change fields incrementally.

circle-info

Need tool_configs, runtime overrides, or memory toggles from the CLI today? Export with aip agents get --export, edit the JSON, then re-import with aip agents create --import or aip agents update --import.

List and Inspect Agents

Python SDK

Note: client.agents.list_agents() and client.agents.get_agent_by_id() already return Agent instances, so you can call methods like agent.run(), agent.update(), or agent.delete() on the returned objects.

CLI

Update Agents

Python SDK

CLI

Delete and Restore Agents

Python SDK

CLI

Run Agents

Basic Execution

Python SDK

Synchronous:

Asynchronous (streaming):

Use agent.arun() when you need streaming responses or async integration.

CLI

With Files

Python SDK

CLI

Runtime Overrides and PII

Python SDK

Behind the scenes, Agent resolves tool_configs and mcp_configs using the global registries. This means you can define these configs against class-based Tool and MCP definitions, tool names, or IDs, and the SDK will map them to the correct resource IDs at deploy or run time.

Config key resolution: In runtime_config, you can reference tools and MCPs by:

  • Custom LangChain tool class: {GreetingTool: {"param": "value"}} — your BaseTool subclass

  • Tool helper instance: {Tool.from_native("time_tool"): {"param": "value"}} — a Tool reference

  • MCP helper instance: {MCP.from_native("weather"): {"auth": {...}}} — an MCP reference

  • Name string: {"greeting_tool": {"param": "value"}} — tool/MCP name on the remote server

  • UUID: {"550e8400-e29b-...": {"param": "value"}} — direct ID registered in the server

Configuration priority order (lowest to highest):

Agent configurations are resolved in the following priority order, with higher priority overriding lower:

  1. Agent definition configs (lowest priority) — agent_config, tool_configs, mcp_configs passed to Agent() constructor

  2. Runtime config global — Top-level keys in runtime_config (e.g., runtime_config["tool_configs"])

  3. Runtime config agent-specific (highest priority) — Agent-specific overrides in runtime_config[agent]

Example showing all three layers:

This layered approach allows you to:

  • Set sensible defaults at agent definition time

  • Apply global overrides for all agents in a workflow

  • Fine-tune specific agents with agent-specific overrides

CLI

pii_mapping and runtime_config flags are in development. Use the SDK or REST API for sensitive workflows until dedicated options land.

Chat History

Python SDK

CLI

Persist long-term context with agent_config.memory="mem0"; edit exports or use SDK kwargs until CLI flags arrive.

Planning Mode

Enable planning mode to have agents create a structured plan before executing complex tasks. This improves reasoning quality and task decomposition for multi-step queries.

Python SDK

CLI

circle-info

Planning mode is especially useful for:

  • Complex multi-step tasks that benefit from upfront reasoning

  • Tasks requiring coordination across multiple tools

  • Scenarios where transparency in the agent's approach is valuable

Timeouts and Limits

Setting
Default
Maximum
How to Change

Agent Runtime

5 minutes

No limit

Set timeout_seconds in agent_config

Step Limit

100 steps

1000 steps

Set in agent_config

Sub-Agent Levels

5 levels

10 levels

Set in agent_config

Tool Timeouts: Some tools have their own timeouts (like Browser Use tools), but these are separate from your agent timeout.

circle-info

Long running agents: When building agents that need extended runtime (e.g., data analysis workflows, multi-step research tasks, or automated document processing), configure timeout_seconds appropriately. For long running agents that may take hours to complete, set a generous timeout and consider combining with retry configuration to handle transient failures. Remember that individual tools may have their own timeout limits that you cannot override.

Configuration: Timeout and Step Limit

Long running agents require careful timeout and step limit configuration to ensure they have enough time to complete complex tasks while preventing infinite loops. Use these settings to balance performance and task completion.

How to configure timeout and step limits in your agent:

Define agent_config in your agent class:

Configuration options:

Setting
Type
Default
Range
Description

timeout_seconds

int (seconds)

300

Any positive integer

Total runtime for the agent

max_steps

int

100

1-1000

Maximum number of agent actions/steps

max_delegation_depth

int

5

1-10

How deep sub-agents can be nested

max_retries

int

3

Any positive integer

LLM call retry attempts

initial_delay

float

1.0

Any positive float

Starting delay between retries (seconds)

max_delay

float

30.0

Any positive float

Maximum delay between retries (seconds)

exponential_base

float

2.0

Any positive float

Exponential backoff multiplier

circle-info

Configuring long running agents:

  • Data analysis workflows: Set timeout_seconds to 3600+ (1+ hour) for processing large datasets

  • Multi-step research tasks: Increase max_steps to 500+ for complex research with multiple tools

  • Document processing: Use max_delegation_depth of 5-10 for hierarchical document parsing

  • Automated pipelines: Configure retry settings (max_retries, max_delay) to handle network or API rate limits

For long running agents, consider monitoring progress through logs or implementing checkpoint mechanisms if supported by your agent tools.

GL Connectors Token

circle-exclamation

Use the gl_connectors_token parameter when your remote run can invoke native tools or MCPs that require end-user auth via GL Connectors.

  • When required: at least one reachable integration (native tool or MCP) has user_authentication=true in its tool_configs or mcp_configs.

  • Execution scope: per-run only; it is not stored in the deployed agent definition.

  • Transport support: forwarded in both JSON-only runs and multipart runs with file attachments.

Python SDK

With a native tool (BOSA): configure user_authentication=True in tool_configs at agent initialization, deploy, then pass gl_connectors_token at run time:

With an MCP: configure user_authentication=True in mcp_configs at agent initialization, deploy, then pass gl_connectors_token at run time:

If the token is missing/invalid for required integrations, the run can fail early with backend auth or precheck errors (for example 403/409), which helps prevent partial execution with unauthenticated integrations.

Multi-Agent Patterns

Need a refresher? The Multi-Agent System Patterns overviewarrow-up-right dives deep into hierarchies, routers, aggregators, and more. Use the snippet below as a quick starter.

Python SDK

CLI

See the Multi-Agent System Patterns overviewarrow-up-right for topology-specific examples (hierarchical, router, aggregator, sequential, parallel).

Iterate Quickly with Export and Import

CLI

Python SDK

Iterate on Instructions Quickly

The CLI merges imports with flag overrides, so keep your definition in source control and loop quickly:

  1. Export the agentaip agents get prod-research --export prod-research.json captures the full payload (instruction, tool_configs, runtime defaults).

  2. Edit locally — adjust instructions, swap language_model_id, or tighten tool settings. Commit the file so teammates can review changes.

  3. Re-importaip agents update prod-research --import prod-research.json applies the update immediately; any CLI flags you pass override the JSON.

  4. Validate — run aip agents run prod-research --view md or --view json to confirm behaviour before moving to the next tweak.

Prefer IDs in scripts to avoid fuzzy matches, and branch your JSON when testing alternative prompts so you can compare diffs later. When you are ready to move between environments, follow the Configuration managementarrow-up-right for a full promotion checklist.

Observability

Run History

Python SDK:

CLI (local transcript cache):

/transcripts opens the local transcript history; select a run in the browser to inspect details.

Debug Remote Runs (Interactive /runs + SDK Run Detail)

Use this when a deployed agent behaves unexpectedly (tool failures, timeouts, inconsistent outputs) and you need an audit trail you can share.

  1. Trigger a remote run with a reproducible input.

  2. Capture the run ID (it appears in the streaming metadata and in run history).

  3. Inspect tool calls, errors, and final output from the run record.

CLI (interactive remote runs browser):

Inside the palette:

  1. Run /agents and select the agent you want to debug.

  2. Run /runs to browse that agent's remote run history.

  3. Open a run to view the full transcript and export it if needed.

circle-info

Screenshot placeholder: /runs table view with a selected run, plus the run detail panel showing tool calls and final output.

Python SDK (fetch run output events):

Common debugging patterns:

  • If the run ends early, search run.output for metadata.kind == "error" or terminal events (final_response, error, step_limit_exceeded).

  • If a tool is misbehaving, compare the tool call args from the run transcript against your expected schema and defaults (tool_configs).

  • If a run is inconsistent, export the agent definition and diff it across environments, then re-run with identical inputs and runtime overrides.

Scheduling

Schedules run the same agent input on a recurring timetable in Asia/Jakarta (WIB). Create schedules with the SDK; CLI commands are on the roadmap. REST documentation exists as reference only in Resources.

In the SDK, you can provide a cron string (minute hour day_of_month month day_of_week) or a ScheduleConfig object. Unspecified fields default to * (every).

Example (Python SDK):

See the Automation & scripting guidearrow-up-right for cron formats, full CRUD, and run history retrieval.

Troubleshooting

Issue
Symptoms
Resolution

Authentication errors

401 responses

Re-run aip accounts add <name> + aip accounts use <name>, or update Client(api_key=...).

Validation errors

422 responses

Check required fields with aip agents create --help or inspect error payloads.

Resource not found

404 responses

Confirm IDs with aip agents list or client.agents.list_agents().

Timeouts

AgentTimeoutError or HTTP 504

Increase timeout or review schedule load.

Best Practices

  1. Scope instructions — concise prompts improve output quality.

  2. Attach only necessary tools — reduces attack surface and execution time.

  3. Reuse memory intentionally — enable mem0 when cross-run context adds value.

  4. Audit run history — review recent runs via client.agents.runs.list_runs(...) and CLI transcripts for failure patterns.

  5. Sanitise secrets — leverage pii_mapping and runtime MCP overrides to avoid persisting credentials.

Last updated

Was this helpful?