Skip to main content

Agents Overview

Agents are AI-powered assistants configured with personas, tools, workflows, and security policies. They execute autonomously using the Agent Loop V4 (LangGraph).

Agent Types

TypeDescription
assistantGeneral-purpose conversational agent
chatbotLightweight chat agent
workflowStep-driven workflow agent
classifierIntent classification agent

Agent Lifecycle

draft → published → archived
↑ │ │
│ ▼ │
│ 📸 snapshot │
└────── restore ─────┘
StatusBehavior
draftCan be executed (with warning in logs) — for builders testing
publishedNormal execution. Creates an automatic version snapshot (see Versioning). All schemas are validated before publishing — invalid schemas block publication
archivedExecution blocked — returns error
Version Tracking

Every change to agents, schemas, triggers, and MCP servers is automatically versioned via PostgreSQL triggers. Publishing creates a full snapshot that can be used for rollback. See Versioning for details.

Authentication

Agent management endpoints support hybrid authentication:

MethodAccess Level
JWT (Authorization: Bearer <jwt> + x-tenant-id)Full access (read + write)
API Key (X-Api-Key: YOUR_API_KEY)Read-only (GET operations only)

CRUD Endpoints

GET /api/agents

List all agents for the tenant.

Query Parameters:

ParamTypeDescription
statusstringdraft, published, archived
typestringAgent type filter
includeArchivedbooleanInclude archived agents
includeTelemetrybooleanInclude telemetry data (total_interactions, avg_response_time)
includeSchemasSummarybooleanInclude schemas summary (schemas_count, schema_types)
Parameter Convention

Parameters accept both camelCase and snake_case: includeTelemetry or include_telemetry.

Response:

{
"success": true,
"data": [
{
"id": "uuid",
"name": "sales-agent",
"commercial_name": "Sales Assistant",
"bio": "AI-powered sales assistant",
"type": "assistant",
"status": "published",
"llm_config": {
"model": "auto",
"temperature": 0.7
},
"created_at": "2025-12-01T00:00:00.000Z"
}
],
"count": 5
}

GET /api/agents/:id

Get agent details by ID.

POST /api/agents

Create a new agent.

Request Body:

{
"name": "my-agent",
"commercial_name": "My AI Agent",
"bio": "Description of the agent",
"type": "assistant",
"llm_config": {
"model": "auto",
"temperature": 0.7
},
"tags": ["tag1", "tag2"],
"visibility": "tenant"
}

PATCH /api/agents/:id

Update an existing agent (partial fields).

DELETE /api/agents/:id

Archive an agent (soft delete).


Status Management

POST /api/agents/:id/publish

Publish an agent, making it available for execution. Automatically creates a version snapshot capturing the complete agent state (persona, schemas, triggers, MCP servers) for future rollback.

Schema Validation on Publish

Publishing validates all agent schemas before proceeding. If any schema is invalid (e.g., missing required fields, bad connection_id, unknown secret_ref), publishing is blocked and the response includes details of the invalid schemas. Fix the reported errors and retry.

POST /api/agents/:id/unpublish

Unpublish an agent (JWT only).

PATCH /api/agents/:id/status

Change agent status with unified method.

Request Body:

{
"status": "draft | published | archived",
"config": {}
}

POST /api/agents/:id/restore

Restore an archived agent to draft status.


GET /api/agents/:id/full

Get agent with all schemas, linked CSPs, triggers, and telemetry.

Response:

{
"success": true,
"data": {
"id": "uuid",
"name": "sales-agent",
"status": "published",
"llm_config": { "model": "auto", "temperature": 0.7 },
"schemas": [
{
"id": "schema-uuid",
"schema_type": "persona_config",
"schema_data": {},
"is_active": true
}
],
"schemas_count": 5,
"active_schemas_count": 4,
"schema_types": ["persona_config", "tools", "csp_config"],
"linked_csps": [],
"triggers": [],
"total_interactions": 150,
"avg_response_time": 1234.5
}
}

Schema Types

Schemas define the agent's configuration and are stored in builder_agent_schemas.schema_data.

TypePurpose
persona_configAgent identity, role, tone, language, constraints
api_configHTTP tool definitions (external APIs)
db_configDatabase query tool definitions
workflow_configStep-driven execution workflows
policyBehavior rules and restrictions
knowledgeKnowledge base content

Schema CRUD

EndpointMethodAuth
GET /api/agents/:id/schemasList schemasJWT or API Key
GET /api/agents/:agentId/schemas/:schemaIdGet schemaJWT or API Key
POST /api/agents/:id/schemasCreate schemaJWT only
PATCH /api/agents/:agentId/schemas/:schemaIdUpdate schemaJWT only
DELETE /api/agents/:agentId/schemas/:schemaIdDeactivate schemaJWT only

Persona Config

The persona defines the agent's identity and behavior. Path: schema_data.editor_schema.persona

Key Fields:

FieldRequiredDescription
roleYesAgent role (heading in system prompt)
objectiveYesAgent objective
toneNoCommunication tone (default: "professional")
languageNoLanguage (default: "pt-BR")
expertiseNoAreas of expertise
constraintsNoMandatory rules
response_styleNoFormat, rules, max_response_length
custom_guidelinesNoFree-form key/value guidelines

Example:

{
"editor_schema": {
"persona": {
"role": "Sales Assistant",
"objective": "Help buyers request quotes for agricultural supplies.",
"tone": "professional",
"language": "pt-BR",
"expertise": ["Agricultural products"],
"constraints": ["Never invent products", "Always query the database first"],
"response_style": {
"format": "markdown",
"rules": ["Use lists when there are more than 2 items"],
"max_response_length": 2000
}
}
}
}

Template Variables

The system prompt supports dynamic template variables that are interpolated at runtime:

VariableDescriptionExample Output
{{current_date}}Today's date (pt-BR)02/03/2026
{{current_time}}Current time (pt-BR)14:30:00
{{current_weekday}}Day of the week (pt-BR)segunda-feira
{{agent_name}}Agent's nameSales Assistant

Unrecognized variables (e.g., {{custom_var}}) are kept intact in the output.

Example usage in persona objective:

"objective": "Help users with purchases. Today is {{current_date}} ({{current_weekday}})."

Schema Validation

All schemas are validated on creation and update. Invalid schemas are rejected with detailed error messages.

Validation Rules by Type

Schema TypeValidated Fields
persona_configrole (min 3 chars), objective (min 10 chars), tone (warning), language (warning)
api_configtool_definition (name, description, input_schema), editor_schema.api (base_url, endpoints, auth)
db_configconnection_id (exists, active), tool_definition, query_template, parameter_mapping
knowledgeBasic structure check
workflow_configBasic structure check
policyBasic structure check

Validation Response

When a schema fails validation, the response includes detailed error and warning information:

{
"success": false,
"error": "Invalid schema",
"validation": {
"errors": ["persona.role is required (minimum 3 characters)"],
"warnings": ["persona.tone not defined"]
}
}
Dry-run Validation

Use the MCP tool validate_schema_data to validate a schema without saving it. This is useful for testing schema structures before creating or updating.


Authentication Summary

EndpointMethodJWTAPI Key
/api/agentsGETYesYes
/api/agents/:idGETYesYes
/api/agents/:id/fullGETYesYes
/api/agents/:id/schemasGETYesYes
/api/agentsPOSTYesNo
/api/agents/:idPATCHYesNo
/api/agents/:idDELETEYesNo
/api/agents/:id/publishPOSTYesNo
/api/agents/:id/unpublishPOSTYesNo
/api/agents/:id/statusPATCHYesNo
/api/agents/:id/restorePOSTYesNo
/api/agents/:id/schemasPOSTYesNo