The Agents API lets you monitor and control the four processing agents that form the document ingestion pipeline: watcher, ocr, classifier, and storage. Each agent can be triggered independently or as part of a sequential pipeline where each step feeds the next.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gcapella0/agente-inteligente-expedientes/llms.txt
Use this file to discover all available pages before exploring further.
GET /agentes
List the current state of every agent and the overall pipeline status. Authentication:Authorization: Bearer <token> required.
Response 200 OK
Response fields
One entry per agent in pipeline order.
Agent identifier. One of
watcher | ocr | classifier | storage.Current agent state:
idle | running | error.ISO 8601 UTC timestamp of the last completed run, or
null if never run.Cumulative count of successful executions since the last state reset.
Last error message if
estado is error, otherwise null.Name of the next agent in the chain.
null for storage (last step).true while a pipeline execution is in progress.Name of the agent currently executing inside the pipeline, or
null when idle.Agent state is persisted in the MongoDB collection
sistema_agentes_estado. On API startup, any agents stuck in running state are automatically reset to idle to prevent stale locks after a crash or restart.POST /agentes/{nombre}/ejecutar
Trigger execution of a single agent or start the full pipeline from that agent onward. Authentication:Authorization: Bearer <token> required.
Path parameters
The agent to execute. Must be one of:
watcher, ocr, classifier, storage.Query parameters
Execution mode:
independiente— runs only the specified agent, no chain.pipeline— runs the specified agent and all subsequent agents in order (watcher → ocr → classifier → storage).
Response 202 Accepted
Execution is started as a FastAPI BackgroundTask and the response is returned immediately.
Unique hex identifier for this execution run. Useful for correlating log entries.
Next agent that will run after this one when
modo=pipeline. null when running in independiente mode or when the last agent in the chain is triggered.Error responses
| Status | Condition |
|---|---|
400 Bad Request | nombre is not a valid agent name, or modo is not independiente / pipeline. |
409 Conflict | The specified agent is already in running state, or (when modo=pipeline) another pipeline execution is already active. |
500 Internal Server Error | Unexpected error starting the background task. |
POST /agentes/{nombre}/stop
Mark an agent as stopped and deactivate the pipeline flag. Authentication:Authorization: Bearer <token> required.
Path parameters
The agent to stop. Must be one of:
watcher, ocr, classifier, storage.Response 200 OK
- Sets
estado→idlein MongoDB for the given agent. - Sets
error_msg→"Detenido por el usuario". - Sets
pipeline_activo→falseandpipeline_paso_actual→null. - Writes a
stop_agenteaudit event viaaudit_log().
cURL examples
Pipeline execution model
The four agents run in a fixed order:modo=pipeline the background thread checks the pipeline_activo flag in MongoDB before starting each step. If the flag was cleared by a stop call, execution halts without running the remaining agents. A 2-second pause is inserted between steps to allow state to propagate.
Each agent function is resolved lazily from src.main at runtime, so any changes to agent logic take effect on the next invocation without restarting the API.