Agents
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).
For current coverage, see the AIP capability matrix. 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.
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 Mode for detailed comparison and decision checklist.
Pattern Decision Guide
Choose the right pattern for your agent operations:
Agent-First Pattern (Recommended)
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
Client-only operations (legacy/advanced admin path):
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 only for these administrative and batch workflows.
Create Agents
Python SDK
Recommended: Agent Pattern
Deprecated client pattern (still supported)
The older
client.agents.create_agentAPI is kept for backward compatibility but new code should prefer theAgentpattern 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):
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, BedrockUse
from glaip_sdk.models import DEFAULT_MODELto see the current default
See the Language models 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.
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.
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"}}— yourBaseToolsubclassTool helper instance:
{Tool.from_native("time_tool"): {"param": "value"}}— aToolreferenceMCP helper instance:
{MCP.from_native("weather"): {"auth": {...}}}— anMCPreferenceName string:
{"greeting_tool": {"param": "value"}}— tool/MCP name on the remote serverUUID:
{"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:
Agent definition configs (lowest priority) —
agent_config,tool_configs,mcp_configspassed toAgent()constructorRuntime config global — Top-level keys in
runtime_config(e.g.,runtime_config["tool_configs"])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
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
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.
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:
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
Configuring long running agents:
Data analysis workflows: Set
timeout_secondsto 3600+ (1+ hour) for processing large datasetsMulti-step research tasks: Increase
max_stepsto 500+ for complex research with multiple toolsDocument processing: Use
max_delegation_depthof 5-10 for hierarchical document parsingAutomated 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
gl_connectors_token is a remote-only feature. It is forwarded to the platform's /agents/{agent_id}/run endpoint and has no effect on local runs. Deploy your agent with agent.deploy() before using this parameter.
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=truein itstool_configsormcp_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 overview 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 overview 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:
Export the agent —
aip agents get prod-research --export prod-research.jsoncaptures the full payload (instruction,tool_configs, runtime defaults).Edit locally — adjust instructions, swap
language_model_id, or tighten tool settings. Commit the file so teammates can review changes.Re-import —
aip agents update prod-research --import prod-research.jsonapplies the update immediately; any CLI flags you pass override the JSON.Validate — run
aip agents run prod-research --view mdor--view jsonto 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 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)
/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.
Trigger a remote run with a reproducible input.
Capture the run ID (it appears in the streaming metadata and in run history).
Inspect tool calls, errors, and final output from the run record.
CLI (interactive remote runs browser):
Inside the palette:
Run
/agentsand select the agent you want to debug.Run
/runsto browse that agent's remote run history.Open a run to view the full transcript and export it if needed.
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.outputformetadata.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 guide for cron formats, full CRUD, and run history retrieval.
Troubleshooting
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
Scope instructions — concise prompts improve output quality.
Attach only necessary tools — reduces attack surface and execution time.
Reuse memory intentionally — enable
mem0when cross-run context adds value.Audit run history — review recent runs via
client.agents.runs.list_runs(...)and CLI transcripts for failure patterns.Sanitise secrets — leverage
pii_mappingand runtime MCP overrides to avoid persisting credentials.
Related Documentation
Tools — manage native and custom tooling.
MCPs — connect external systems and rotate credentials.
Language models — configure models using provider/model format or Model class.
Automation & scripting — orchestrate agents programmatically.
Multi-Agent System Patterns overview — explore multi-agent coordination strategies.
Last updated
Was this helpful?