AgentsServerComponentΒΆ
The AgentsServerComponent exposes agent metadata and control via HTTP endpoints, enabling programmatic access to agent information and execution history.
OverviewΒΆ
This component provides REST API endpoints for querying agent information, viewing agent subscriptions, checking execution history, and monitoring workflow status.
ConfigurationΒΆ
AgentsServerComponentConfigΒΆ
Fields: - prefix (str, default: "/api/v1/plugin/") - URL prefix for all endpoints - tags (list[str], default: ["Agents", "Public API"]) - OpenAPI documentation tags
UsageΒΆ
from flock import Flock
from flock.components.server import (
AgentsServerComponent,
AgentsServerComponentConfig
)
flock = Flock()
agents = AgentsServerComponent(
config=AgentsServerComponentConfig(
prefix="/api/v1",
tags=["Agents", "API"]
)
)
await flock.serve(components=[agents])
EndpointsΒΆ
GET /api/v1/plugin/agentsΒΆ
List all registered agents with their metadata.
Response:
{
"agents": [
{
"id": "pizza_master",
"name": "pizza_master",
"description": "Creates perfect pizzas from ideas",
"consumes": ["MyDreamPizza"],
"publishes": ["Pizza"],
"subscriptions": [...]
}
]
}
GET /api/v1/plugin/agents/{agent_id}/history-summaryΒΆ
Get execution history summary for a specific agent.
Query Parameters: - type_names (list[str]) - Filter by artifact types - produced_by (list[str]) - Filter by producer agents - correlation_id (str) - Filter by correlation ID - tags (list[str]) - Filter by tags - start (ISO datetime) - Start of time range - end (ISO datetime) - End of time range
Response:
{
"agent_id": "pizza_master",
"total_runs": 42,
"artifacts_consumed": [
{"type": "MyDreamPizza", "count": 42}
],
"artifacts_produced": [
{"type": "Pizza", "count": 42}
]
}
GET /api/v1/plugin/correlations/{correlation_id}/statusΒΆ
Get workflow status by correlation ID.
Response:
{
"correlation_id": "workflow-123",
"status": "completed",
"started_at": "2025-10-31T12:00:00Z",
"completed_at": "2025-10-31T12:00:05Z",
"artifacts": [
{
"id": "uuid-1",
"type": "Pizza",
"produced_by": "pizza_master"
}
]
}
Best PracticesΒΆ
1. Use with DashboardΒΆ
components = [
AgentsServerComponent(), # Provides agent metadata
WebSocketServerComponent(), # Real-time updates
]
2. Secure EndpointsΒΆ
from flock.components.server import AuthenticationComponent
auth = AuthenticationComponent(...)
agents = AgentsServerComponent()
# Agents endpoints now require authentication
3. Monitor WorkflowsΒΆ
# Track workflow progress via correlation ID
response = await client.get(f"/api/v1/plugin/correlations/{correlation_id}/status")
status = response.json()
if status["status"] == "completed":
print("Workflow finished!")
Component PropertiesΒΆ
- Name:
agents - Priority:
5 - Dependencies: None