MATIH Platform is in active MVP development. Documentation reflects current implementation status.
12. AI Service
Agent Endpoints

Agent Endpoints

The Agent API provides endpoints for managing agent lifecycle, triggering agent orchestration, streaming agent responses, and configuring agent behavior. These endpoints are the primary interface for the Agentic Workbench and programmatic agent interactions.


Process Message

Sends a message to the agent orchestrator for processing through the multi-agent pipeline.

PropertyValue
MethodPOST
Path/api/v1/agents/process
AuthJWT required

Request Body

{
  "session_id": "sess-abc123",
  "message": "Show me sales trends for the last 6 months",
  "tenant_id": "acme-corp",
  "user_id": "user-456",
  "agent_config": {
    "provider": "openai",
    "model": "gpt-4",
    "temperature": 0.7,
    "tools_enabled": true
  }
}

Response

{
  "id": "resp-789",
  "content": "Here are the sales trends...",
  "tool_calls": [],
  "tool_results": [],
  "reasoning": "Identified as a time-series analysis query...",
  "requires_approval": false,
  "execution_time_ms": 2450,
  "tokens_used": 1823
}

Stream Agent Response

Opens a Server-Sent Events stream for real-time agent response delivery.

PropertyValue
MethodGET
Path/api/v1/agents/stream/:session_id
AuthJWT required
Content-Typetext/event-stream

Event Types

Event TypeDescription
textIncremental text content from the agent
tool_callAgent is invoking a tool
tool_resultTool execution result
statusAgent status update (thinking, executing, complete)
errorError during agent processing

Example SSE Stream

event: status
data: {"type": "status", "content": "thinking"}

event: text
data: {"type": "text", "content": "Analyzing sales data..."}

event: tool_call
data: {"type": "tool_call", "data": {"tool": "sql_generator", "input": "..."}}

event: text
data: {"type": "text", "content": "Based on the query results...", "is_final": true}

List Agents

Returns available agent types and their configurations.

PropertyValue
MethodGET
Path/api/v1/agents
AuthJWT required

Response

{
  "agents": [
    {
      "id": "router-agent",
      "type": "router",
      "name": "Router Agent",
      "description": "Routes queries to specialized agents",
      "capabilities": ["intent_classification", "routing"]
    },
    {
      "id": "sql-agent",
      "type": "specialist",
      "name": "SQL Agent",
      "description": "Generates and executes SQL queries",
      "capabilities": ["sql_generation", "query_execution"]
    }
  ]
}

Get Agent Status

Returns the current status of an active agent session.

PropertyValue
MethodGET
Path/api/v1/agents/status/:session_id
AuthJWT required

Response

{
  "session_id": "sess-abc123",
  "status": "idle",
  "active_agents": [],
  "message_count": 5,
  "last_activity": "2025-03-15T10:30:00Z"
}

Submit Approval

Submits an approval decision for a human-in-the-loop checkpoint.

PropertyValue
MethodPOST
Path/api/v1/agents/approve
AuthJWT required

Request Body

{
  "approval_id": "appr-101",
  "session_id": "sess-abc123",
  "decision": "approved",
  "comment": "SQL query looks correct"
}

Response

{
  "success": true,
  "approval_id": "appr-101",
  "status": "approved",
  "resumed": true
}