head-side-gearAgents Guide

Master agent lifecycle operations, orchestration patterns, and runtime controls across the REST API, Python SDK, and CLI. This guide tracks the current production release and mirrors the capability matrix in the documentation overview.

circle-info

For current REST, SDK, and CLI 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 now available via SDK and REST.

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

SDK Client Pattern (Secondary)

Use for listing, searching, and batch operations across multiple agents. This is a secondary pattern kept for backward compatibility and cross-agent 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-info

Features requiring Client pattern:

  • Creating agents from JSON/YAML files (create_agent_from_file)

  • Bulk listing and filtering agents

  • LangFlow sync operations

  • Run history retrieval via client.agents.runs

Use the Client pattern for these administrative and batch workflows.


Create Agents

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.

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

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.

Update Agents

Delete and Restore Agents

Run Agents

Basic Execution

Synchronous:

Asynchronous (streaming):

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

With Files

Runtime Overrides and PII

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

Chat History

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.

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.

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.

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

Iterate Quickly with Export and Import

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 management guidearrow-up-right for a full promotion checklist.

Observability

Run History

Use run_type=schedule to filter for scheduled runs only:

SDK support is available via client.schedules.list_runs(). CLI commands are under development.

Scheduling

Schedules run the same agent input on a recurring timetable in Asia/Jakarta (WIB). Create schedules with the SDK; REST examples live in the Automation & scripting guide. CLI commands are on the roadmap.

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

Example (Python SDK):

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

Troubleshooting

Issue
Symptoms
Resolution

Authentication errors

401 responses

Re-run aip configure 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 /agents filters.

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 — monitor /agents/{id}/runs for failure patterns or token usage.

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

Last updated