Overview
The Orq.ai Agents Framework provides a powerful API for creating, configuring, and executing intelligent AI agents. This guide covers the complete workflow for building agents programmatically and integrating them into your applications using the Agents API and SDKs.Core Concepts
Agent Lifecycle
Agents follow a simple two-step lifecycle:- Creation - Define your agent configuration via
POST /v2/agents - Execution - Send messages via
POST /v2/agents/{agent_key}/responses
A2A Protocol
All agent communication uses the A2A Protocol for standardized agent-to-agent messaging. Messages are structured with a role and parts array containing content blocks.Task IDs and Context
Each agent execution returns atask_id that maintains conversation context across multiple turns. Use the same task_id in subsequent requests to continue conversations without replaying the full history.
Step 1: Creating Agents
Agent Configuration
An agent requires the following configuration:- key (required): Unique identifier within your workspace
- role: The agent’s function or purpose
- description: Brief summary of capabilities
- instructions: Behavioral guidelines and system prompt
- model: Model to use (string or object format)
- path: Storage location in your project structure
- settings: Execution parameters (max_iterations, max_execution_time, tools)
Creating a Simple Agent
Model Parameter Formats
Themodel parameter supports two formats:
String Format (simple, recommended for basic use):
Agent Settings
Configure execution behavior with thesettings object:
| Parameter | Type | Description | Default |
|---|---|---|---|
max_iterations | number | Maximum agent processing loops | 100 |
max_execution_time | number | Maximum execution time in seconds | 300 |
tools | array | Tools available to the agent | [] |
tool_approval_required | string | Tool approval mode | ”respect_tool” |
"respect_tool"(default) - Use tool’s individual approval settings. Each tool defines whether approval is required"none"- Never require approval, execute all tools automatically. Use for trusted tools and automated workflows"always"- Always require manual approval before any tool execution. Use for high-risk operations (coming soon)
| Mode | Best For | Example |
|---|---|---|
respect_tool | Mixed trust levels | Some tools (web search) are safe, others (CRM inserts) need approval |
none | Automated, trusted tools | Retrieving current date, reading knowledge bases |
always | High-risk operations | Financial transactions, account deletions, data modifications |
To learn more about tools, see the Tools Documentation.
Step 2: Executing Agents
Basic Execution
Execute an agent using the Responses API:Response Structure
The response includes:- output: Array of A2A protocol messages with the agent’s responses
- task_id: Identifier for continuing this conversation
- usage: Token consumption details
- model: Model used for execution
Step 3: Multi-Turn Conversations
Using Task IDs for Context
Continue conversations by providing thetask_id from a previous response:
Advanced Configuration
Execution Modes
| Execution Mode | Synchronous (background: false) | Asynchronous (background: true) |
|---|---|---|
| Behavior | Agent processes request completely before returning | Returns immediately with task_id and initial status |
| Response | Complete output, all tool results, token usage | Initial status only; agent continues in background |
| Timeout | Respects max_execution_time (default: 300s); fails on exceed | No immediate timeout concern |
| Result retrieval | Immediate in response | Must poll using task_id |
| Best for | Interactive apps, chatbots, APIs needing immediate responses | Long-running operations, batch processing, high-load scenarios |
| Trade-off | Client must wait for completion | Requires polling |
Agent State Management
Agents process tasks asynchronously. The/responses endpoint returns:
task_id: Reference to continue multi-turn conversationsoutput: Array of messages with agent’s responseusage: Token consumption details
task_id in subsequent requests to maintain conversation context.
Best Practices
Instructions Design
- Write clear, concise instructions
- Define expected outputs and formats
- Specify when to escalate or ask for clarification
- Include examples when helpful
Performance Optimization
- Set appropriate
max_iterationslimits - Use
max_execution_timeto prevent runaway processes - Leverage
task_idto avoid context replay - Batch related requests when possible
Complete Example: Conversational Loop
Next Steps
- Tools with Agents - Add capabilities like web search and custom functions
- Multi-Agent Workflows - Orchestrate multiple agents together
- API Reference - Detailed endpoint documentation