How agent-field/agentfield works
Purpose and entry points
AgentField is an AI-agent control plane: application-defined Python, Go, or TypeScript agents register callable capabilities; the platform routes calls, manages durable execution, governance, memory, and observability. Main binaries are the server (control-plane/cmd/agentfield-server/main.go), CLI (control-plane/cmd/af/main.go), and macOS tray companion (control-plane/cmd/af-tray/main.go). SDK entry surfaces are sdk/python/agentfield/agent.py, sdk/go/agent/agent.go, and sdk/typescript/src/agent/Agent.ts.
Control-plane composition and API boundary
The Go server assembles storage, services, background maintenance, authentication, and HTTP/gRPC routing. Route groups separate core execution, agentic/discovery, memory, triggers, governance, connector, and UI APIs: control-plane/internal/server/server.go, control-plane/internal/server/routes_core.go, control-plane/internal/server/routes_agentic.go. HTTP handlers are the ingress boundary; they validate/authorize requests and invoke shared services rather than exposing storage directly: control-plane/internal/handlers/execute.go, control-plane/internal/handlers/route_registrar.go.
Agent mesh and execution lifecycle
Agents auto-register nodes, versions, reasoners, and health with the control plane. An execution request resolves a target/version, applies admission and policy guards, records lifecycle state, dispatches to the remote agent, and supports sync, async, cancellation, pause/approval, restart, status, logs, and SSE. Workflow parent-child relationships form the persisted DAG. Core paths: control-plane/internal/handlers/execute_lifecycle.go, control-plane/internal/handlers/workflow_dag.go, control-plane/internal/services/cancel_dispatcher.go.
SDK-hosted agent runtime
SDKs turn decorated functions into agent HTTP endpoints and provide the outbound control-plane client. They propagate execution/workflow/session context for nested app.call() fan-out, report status/logs/usage, and implement local reasoner routing. Python additionally has async and serverless runtimes. Relevant paths: sdk/python/agentfield/agent_server.py, sdk/python/agentfield/connection_manager.py, sdk/go/agent/router.go; sdk/typescript/src/context/ExecutionContext.ts.
Persistence, memory, and eventing
The platform uses a local database abstraction with SQLite and PostgreSQL support, schema migrations, transactions/locks, execution records, triggers, identity data, and workflow state. It provides scoped key-value/vector memory and embedding-provider integration; in-process events distribute execution/node/reasoner/trigger/memory changes. Key paths: control-plane/internal/storage/storage.go, control-plane/internal/storage/vector_store.go, control-plane/migrations/011_create_workflow_runs_and_steps.sql; control-plane/internal/events/event_bus.go.
Identity, authorization, and integration ingress
DID and verifiable-credential services establish agent identity and signed audit/provenance chains. Middleware enforces API, DID, permission, privileged/admin, rate-limit, and connector-capability boundaries. Trigger sources ingest and authenticate cron, GitHub, Slack, Stripe, Databricks, Linear, Sentry, and Snowflake events before dispatching workflows. Paths: control-plane/internal/services/did_service.go, control-plane/internal/services/vc_service.go, control-plane/internal/server/middleware/permission.go; control-plane/internal/handlers/triggers.go.
Operator surfaces and deployment
The CLI scaffolds, installs, runs, manages and verifies agent packages; package services handle repository acquisition, language runtimes, credentials, process control, and registration. A React/Vite dashboard consumes UI APIs and SSE to manage fleet state and render workflow DAGs. Deployments target Docker Compose, Kubernetes/Helm, and PostgreSQL; the stateless control plane can scale behind a load balancer. Paths: control-plane/internal/cli/root.go, control-plane/internal/packages/installer.go; control-plane/web/client/src/main.tsx, control-plane/web/client/src/components/WorkflowDAG/index.tsx; deployments/helm/agentfield/templates/control-plane-deployment.yaml.
Main entry points: execute_lifecycle.go Execution lifecycle · agent.py Agent mesh · server.go API route groups · execute.go Request handlers
Components 22
Operator & client surfaces
- af CLI · Scaffolds, installs, runs, manages, and verifies agents.
control-plane/cmd/af/main.go - af tray
control-plane/cmd/af-tray/main.go - Web dashboard · Manages fleet state and renders workflow DAGs over APIs and SSE.
control-plane/web/client/src/main.tsx
Control plane
- Control-plane server · Assembles APIs, services, storage, and maintenance.
control-plane/cmd/agentfield-server/main.go - API route groups · Core, agentic, memory, trigger, governance, connector, and UI APIs.
control-plane/internal/server/server.go - Request handlers · Validate and authorize requests before invoking services.
control-plane/internal/handlers/execute.go - Execution lifecycle · Resolves targets, records state, and supports lifecycle control.
control-plane/internal/handlers/execute_lifecycle.go - Workflow DAG · Persists parent-child execution relationships.
control-plane/internal/handlers/workflow_dag.go - Cancel dispatcher
control-plane/internal/services/cancel_dispatcher.go - Package manager · Acquires repositories, provisions runtimes and credentials, and registers processes.
control-plane/internal/packages/installer.go - Scalable deployment · Stateless control plane scales behind a load balancer with PostgreSQL.
deployments/helm/agentfield/templates/control-plane-deployment.yaml
Agent runtimes
- Python SDK runtime · Decorated endpoints, control-plane client, async, and serverless support.
sdk/python/agentfield/agent_server.py - Go SDK runtime · Hosts agent HTTP endpoints and control-plane calls.
sdk/go/agent/router.go - TypeScript SDK runtime · Propagates execution, workflow, and session context.
sdk/typescript/src/context/ExecutionContext.ts - Agent mesh · Registered agent nodes expose versions, reasoners, health, and capabilities.
sdk/python/agentfield/agent.py
State & events
- Storage abstraction · SQLite/PostgreSQL persistence, migrations, transactions, and locks.
control-plane/internal/storage/storage.go - Workflow run state · Workflow runs and steps persist the execution DAG.
control-plane/migrations/011_create_workflow_runs_and_steps.sql - Scoped memory · Scoped key-value and vector memory with embedding integration.
control-plane/internal/storage/vector_store.go - Event bus · Distributes execution, node, reasoner, trigger, and memory changes.
control-plane/internal/events/event_bus.go
Identity & ingress
- DID & credentials · Establishes agent identity and signed provenance chains.
control-plane/internal/services/did_service.go - Authorization middleware · Enforces API, DID, permission, admin, rate, and connector-capability controls.
control-plane/internal/server/middleware/permission.go - Trigger ingress · Authenticates external events before workflow dispatch.
control-plane/internal/handlers/triggers.go
Connections 28
- Control-plane server → API route groups: mounts
- API route groups → Authorization middleware: protects with
- API route groups → Request handlers: routes to
- Request handlers → Execution lifecycle: starts and controls
- Request handlers → Workflow DAG: queries workflow state
- Request handlers → Scoped memory: accesses scoped memory
- Request handlers → Trigger ingress: accepts integration events
- Execution lifecycle → Agent mesh: dispatches calls
- Execution lifecycle → Storage abstraction: records lifecycle
- Execution lifecycle → Workflow DAG: creates child steps
- Execution lifecycle → Cancel dispatcher: requests cancellation
- Execution lifecycle → Event bus: publishes changes
- Workflow DAG → Workflow run state: persists runs and steps
- Cancel dispatcher → Agent mesh: sends cancel
- Trigger ingress → Execution lifecycle: dispatches workflows
- DID & credentials → Authorization middleware: supplies DID identity
- DID & credentials → Storage abstraction: stores identity and audit data
- Python SDK runtime → Agent mesh: hosts
- Go SDK runtime → Agent mesh: hosts
- TypeScript SDK runtime → Agent mesh: hosts
- Agent mesh → API route groups: registers and reports to
- Agent mesh → Execution lifecycle: reports status, logs, and usage
- af CLI → Package manager: installs and manages
- Package manager → Agent mesh: launches and registers
- af tray → API route groups: uses control APIs
- Web dashboard → API route groups: uses UI APIs
- Web dashboard → Event bus: consumes SSE updates
- Scalable deployment → Control-plane server: deploys