agentManager REST API v0.1.0
This document describes the REST API endpoints for agentManager. This project is a Phase 1 prototype and is not production-ready. All endpoints return JSON responses.
http://localhost:8000
Currently, no authentication is required. This will be added in Phase 2.
Responses are returned as plain JSON objects. Success responses use the endpoint-specific shape shown below. Error responses use FastAPI's standard {"detail": "..."} format.
Health check endpoint. Use this to verify the API is running. By default,
configured dependencies are checked in non-strict mode: dependency failures
return HTTP 200 with status: "degraded". Load balancers can call
/health?strict=true to receive HTTP 503 when a configured dependency is down.
Request:
curl http://localhost:8000/healthResponse (200 OK):
{
"status": "ok",
"version": "0.1.0",
"timestamp": "2026-06-01T04:00:00Z",
"dependencies": {}
}Response (200 OK, non-strict degraded):
{
"status": "degraded",
"version": "0.1.0",
"timestamp": "2026-06-01T04:00:00Z",
"dependencies": {
"postgres": "degraded",
"redis": "ok"
}
}Response (503 Service Unavailable, strict degraded):
{
"status": "unhealthy",
"version": "0.1.0",
"timestamp": "2026-06-01T04:00:00Z",
"dependencies": {
"postgres": "degraded"
}
}Fields:
status:ok,degraded, orunhealthydependencies: only includes dependencies configured through environment variables; supported keys arepostgresandredis
Use Cases:
- Kubernetes liveness probe
- Load balancer health check
- Monitoring and alerting
Prometheus metrics endpoint. The default registry includes API task/error metrics and audit sink failure counters.
Request:
curl http://localhost:8000/metricsMetrics:
agentmanager_tasks_totalagentmanager_task_duration_secondsagentmanager_errors_totalagentmanager_repairs_totalagentmanager_audit_sink_failures_total{sink="db|object_storage"}
Get current system status including task counts and metrics.
Request:
curl http://localhost:8000/statusResponse (200 OK):
{
"total_tasks": 10,
"running_tasks": 3,
"completed_tasks": 5,
"dag_nodes": 10,
"events_published": 25
}Fields:
total_tasks: Total number of tasks in the systemrunning_tasks: Number of currently running taskscompleted_tasks: Number of completed tasksdag_nodes: Number of nodes in the DAGevents_published: Total events published
Create a new task in the system.
Request:
curl -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{
"node_id": "task_1",
"task_type": "data_processing",
"dependencies": ["task_0"],
"metadata": {"priority": "high"}
}'Request Body:
{
"node_id": "string (required)",
"task_type": "string (required)",
"dependencies": ["string"] (optional, default: []),
"metadata": {object} (optional, default: {})
}Response (201 Created):
{
"node_id": "task_1",
"task_type": "data_processing",
"status": "pending",
"dependencies": ["task_0"],
"metadata": {"priority": "high"}
}Error Responses:
- 400 Bad Request: Task already exists or dependency not found
- 500 Internal Server Error: Server error
Validation Rules:
node_id: Must be unique, non-empty stringtask_type: Must be non-empty stringdependencies: All referenced tasks must exist- No circular dependencies allowed
Example:
# Create a simple task
curl -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{"node_id":"task_1","task_type":"type1"}'
# Create task with dependencies
curl -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{
"node_id":"task_2",
"task_type":"type2",
"dependencies":["task_1"]
}'Get information about a specific task.
Request:
curl http://localhost:8000/tasks/task_1Response (200 OK):
{
"node_id": "task_1",
"task_type": "data_processing",
"status": "pending",
"dependencies": [],
"metadata": {}
}Path Parameters:
task_id: The ID of the task to retrieve
Response Fields:
node_id: Task identifiertask_type: Type of taskstatus: Current task status (pending, ready, running, verifying, completed, failed, blocked_repair, blocked_hitl)dependencies: List of dependency task IDsmetadata: Custom metadata
Error Responses:
- 404 Not Found: Task does not exist
Example:
curl http://localhost:8000/tasks/task_1Get all tasks that are ready for execution (no pending dependencies). The ready_tasks field contains task/node IDs, not full task objects.
Request:
curl http://localhost:8000/tasks/readyResponse (200 OK):
{
"ready_tasks": ["task_1", "task_3"],
"total_tasks": 5,
"running_tasks": 2
}Response Fields:
ready_tasks: List of task IDs ready to executetotal_tasks: Total number of tasks in systemrunning_tasks: Number of currently running tasks
Use Cases:
- Scheduler polling for next tasks to execute
- Monitoring dashboard
- Task distribution to workers
Example:
curl http://localhost:8000/tasks/readyMark a task as completed.
Request:
curl -X POST http://localhost:8000/tasks/task_1/completeResponse (200 OK):
{
"task_id": "task_1",
"status": "completed"
}Path Parameters:
task_id: The ID of the task to complete
Error Responses:
- 404 Not Found: Task does not exist
- 500 Internal Server Error: Invalid state transition
State Transitions:
- The handler transitions any non-terminal task to
COMPLETED. COMPLETEDandBLOCKED_HITLare terminal states and are not transitioned by this endpoint.
Example:
curl -X POST http://localhost:8000/tasks/task_1/completeMark a task as failed.
Request:
curl -X POST "http://localhost:8000/tasks/task_1/fail?reason=timeout"Query Parameters:
reason(optional): Reason for failure
Response (200 OK):
{
"task_id": "task_1",
"status": "failed"
}Path Parameters:
task_id: The ID of the task to fail
Error Responses:
- 404 Not Found: Task does not exist
- 500 Internal Server Error: Invalid state transition
State Transitions:
- The handler transitions any non-terminal task to
FAILED. COMPLETEDandBLOCKED_HITLare terminal states and are not transitioned by this endpoint.
Example:
# Fail task with reason
curl -X POST "http://localhost:8000/tasks/task_1/fail?reason=network_error"
# Fail task without reason
curl -X POST http://localhost:8000/tasks/task_1/failCreate a task decomposition plan from a source task. Validates duplicate item IDs
and item dependencies within the plan, then publishes a task_plan_created event
after the in-memory plan lock is released.
Request:
curl -X POST http://localhost:8000/task-plans \
-H "Content-Type: application/json" \
-d '{
"plan_id": "plan-1",
"source_task_id": "task-1",
"items": [
{
"id": "item-1",
"title": "Implement feature X",
"verification": "Run pytest tests/unit/test_x.py"
},
{
"id": "item-2",
"title": "Review implementation",
"dependencies": ["item-1"],
"verification": "Code review passed"
}
]
}'Request Body:
{
"plan_id": "string (required, unique)",
"source_task_id": "string (required)",
"items": [
{
"id": "string (required)",
"title": "string (required)",
"verification": "string (required)",
"description": "string (optional)",
"dependencies": ["string"] (optional),
"assignee": "string (optional, agent_id)",
"required_skills": ["string"] (optional),
"workdir": "string (optional, relative path)"
}
]
}Response (201 Created):
{
"plan_id": "plan-1",
"source_task_id": "task-1",
"status": "draft",
"items": [
{
"id": "item-1",
"title": "Implement feature X",
"status": "pending_review",
"verification": "Run pytest tests/unit/test_x.py",
"dependencies": []
},
{
"id": "item-2",
"title": "Review implementation",
"status": "pending_review",
"verification": "Code review passed",
"dependencies": ["item-1"]
}
]
}Error Responses:
- 400 Bad Request: Plan already exists, item IDs are duplicated, or dependency references unknown item
Retrieve a task plan for review.
Request:
curl http://localhost:8000/task-plans/plan-1Response (200 OK):
{
"plan_id": "plan-1",
"status": "draft",
"items": [...]
}Error Responses:
- 404 Not Found: Plan does not exist
Edit task plan items, assignees, skills, or relative workdir. Blocked once plan is confirmed.
Request:
curl -X PUT http://localhost:8000/task-plans/plan-1 \
-H "Content-Type: application/json" \
-d '{
"items": [
{
"id": "item-1",
"title": "Updated title",
"assignee": "agent-worker-1",
"verification": "Run updated test suite"
}
]
}'Response (200 OK):
{
"plan_id": "plan-1",
"status": "draft",
"items": [
{
"id": "item-1",
"title": "Updated title",
"assignee": "agent-worker-1",
"status": "pending_review"
}
]
}Error Responses:
- 404 Not Found: Plan does not exist
- 400 Bad Request: Item IDs are duplicated, workdir is absolute/unsafe, or dependency references unknown item
- 409 Conflict: Plan already confirmed, edits are frozen
Freeze the task plan, validate all item verifications and dependencies, run
before_task_plan_confirm / after_task_plan_confirm hooks, and publish a
task_plan_confirmed event. Task-plan events are published after the plan lock is
released so synchronous event subscribers cannot deadlock the API path.
If a blocking before_task_plan_confirm hook fails, the plan remains in draft
state and the API publishes a task_plan_confirm_failed event.
Request:
curl -X POST http://localhost:8000/task-plans/plan-1/confirmResponse (200 OK):
{
"plan_id": "plan-1",
"status": "confirmed",
"items": [
{
"id": "item-1",
"status": "confirmed",
"assignee": "agent-worker-1",
"metadata": {
"agent_id": "agent-worker-1",
"plan_id": "plan-1"
}
}
]
}Error Responses:
- 400 Bad Request: Item missing verification, or dependency references unknown item
- 404 Not Found: Plan does not exist
- 409 Conflict: Plan already confirmed
- 500 Internal Server Error: Blocking confirmation hook failed
| Code | Meaning |
|---|---|
| 200 | OK - Request succeeded |
| 201 | Created - Resource created successfully |
| 400 | Bad Request - Invalid input or validation error |
| 404 | Not Found - Resource does not exist |
| 409 | Conflict - Resource state conflict (e.g., plan already confirmed) |
| 500 | Internal Server Error - Server error |
All errors return a JSON response with a detail field:
{
"detail": "Task task_1 not found"
}Common errors:
- "Task {id} already exists" - Duplicate task creation
- "Task {id} not found" - Task does not exist
- "Dependency not found: {id}" - Referenced dependency does not exist
- "Adding edge creates a cycle" - Circular dependency detected
- "Invalid transition: {from} → {to}" - Invalid state transition
Currently, no rate limiting is implemented. This will be added in Phase 2.
Currently, no pagination is implemented. This will be added in Phase 2 when dealing with large datasets.
API version is included in responses. Current version: 0.1.0
Future versions will be available at:
/v1/tasks(v1 endpoints)/v2/tasks(v2 endpoints)
WebSocket support for real-time event streaming will be added in Phase 2.
# 1. Create task_1
curl -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{"node_id":"task_1","task_type":"type1"}'
# 2. Create task_2 depending on task_1
curl -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{"node_id":"task_2","task_type":"type2","dependencies":["task_1"]}'
# 3. Check ready tasks (only task_1 is ready)
curl http://localhost:8000/tasks/ready
# 4. Complete task_1
curl -X POST http://localhost:8000/tasks/task_1/complete
# 5. Check ready tasks again (now task_2 is ready)
curl http://localhost:8000/tasks/ready
# 6. Complete task_2
curl -X POST http://localhost:8000/tasks/task_2/complete
# 7. Check status
curl http://localhost:8000/status- Verify the task ID is correct
- Check that the task was created successfully
- Ensure all dependency tasks exist
- Create dependencies before dependent tasks
- Check for circular dependencies
- Ensure task dependencies form a DAG (no cycles)
- Check current task status
- Verify the target status is valid for current status
Last Updated: 2026-05-24
API Version: 0.1.0
Status: Phase 1 Complete