# agent-field/agentfield architecture

> Architecture diagram of the GitHub repository agent-field/agentfield, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agent-field/agentfield
- Repository: https://github.com/agent-field/agentfield
- Video tour (about a minute): https://gitdiagram.com/agent-field/agentfield/video

## Overview

#### 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: [`control-plane/internal/handlers/execute_lifecycle.go`](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/execute_lifecycle.go) (Execution lifecycle), [`sdk/python/agentfield/agent.py`](https://github.com/agent-field/agentfield/blob/main/sdk/python/agentfield/agent.py) (Agent mesh), [`control-plane/internal/server/server.go`](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/server/server.go) (API route groups), [`control-plane/internal/handlers/execute.go`](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/execute.go) (Request handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Operator &amp; client surfaces"]
  node_cli["af CLI<br/>Go CLI<br/>[main.go]"]
  node_tray["af tray<br/>macOS companion<br/>[main.go]"]
  node_dashboard["Web dashboard<br/>React/Vite UI<br/>[main.tsx]"]
end

subgraph group_control["Control plane"]
  node_server["Control-plane server<br/>Go service<br/>[main.go]"]
  node_routes["API route groups<br/>HTTP/gRPC routing<br/>[server.go]"]
  node_handlers["Request handlers<br/>API boundary<br/>[execute.go]"]
  node_execution["Execution lifecycle<br/>execution service"]
  node_workflow["Workflow DAG<br/>workflow service<br/>[workflow_dag.go]"]
  node_cancellation["Cancel dispatcher<br/>background service"]
  node_packages["Package manager<br/>agent package service<br/>[installer.go]"]
  node_deployment["Scalable deployment<br/>Kubernetes deployment"]
end

subgraph group_agents["Agent runtimes"]
  node_sdk_python["Python SDK runtime<br/>agent SDK<br/>[agent_server.py]"]
  node_sdk_go["Go SDK runtime<br/>agent SDK<br/>[router.go]"]
  node_sdk_ts["TypeScript SDK runtime<br/>agent SDK"]
  node_agent_mesh{{"Agent mesh<br/>remote agents<br/>[agent.py]"}}
end

subgraph group_data["State &amp; events"]
  node_storage[("Storage abstraction<br/>database layer<br/>[storage.go]")]
  node_workflow_schema[("Workflow run state<br/>database schema")]
  node_memory[("Scoped memory<br/>KV/vector memory<br/>[vector_store.go]")]
  node_events["Event bus<br/>in-process events<br/>[event_bus.go]"]
end

subgraph group_integrations["Identity &amp; ingress"]
  node_identity["DID &amp; credentials<br/>identity service<br/>[did_service.go]"]
  node_authorization["Authorization middleware<br/>security boundary<br/>[permission.go]"]
  node_triggers["Trigger ingress<br/>integration handlers<br/>[triggers.go]"]
end

node_server -->|"mounts"| node_routes
node_routes -->|"protects with"| node_authorization
node_routes -->|"routes to"| node_handlers
node_handlers -->|"starts and controls"| node_execution
node_handlers -->|"queries workflow state"| node_workflow
node_handlers -->|"accesses scoped memory"| node_memory
node_handlers -->|"accepts integration events"| node_triggers
node_execution -->|"dispatches calls"| node_agent_mesh
node_execution -->|"records lifecycle"| node_storage
node_execution -->|"creates child steps"| node_workflow
node_execution -->|"requests cancellation"| node_cancellation
node_execution -->|"publishes changes"| node_events
node_workflow -->|"persists runs and steps"| node_workflow_schema
node_cancellation -->|"sends cancel"| node_agent_mesh
node_triggers -->|"dispatches workflows"| node_execution
node_identity -->|"supplies DID identity"| node_authorization
node_identity -->|"stores identity and audit data"| node_storage
node_sdk_python -->|"hosts"| node_agent_mesh
node_sdk_go -->|"hosts"| node_agent_mesh
node_sdk_ts -->|"hosts"| node_agent_mesh
node_agent_mesh -->|"registers and reports to"| node_routes
node_agent_mesh -->|"reports status, logs, and usage"| node_execution
node_cli -->|"installs and manages"| node_packages
node_packages -->|"launches and registers"| node_agent_mesh
node_tray -->|"uses control APIs"| node_routes
node_dashboard -->|"uses UI APIs"| node_routes
node_dashboard -->|"consumes SSE updates"| node_events
node_deployment -->|"deploys"| node_server

click node_server "https://github.com/agent-field/agentfield/blob/main/control-plane/cmd/agentfield-server/main.go"
click node_routes "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/server/server.go"
click node_handlers "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/execute.go"
click node_execution "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/execute_lifecycle.go"
click node_workflow "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/workflow_dag.go"
click node_cancellation "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/services/cancel_dispatcher.go"
click node_cli "https://github.com/agent-field/agentfield/blob/main/control-plane/cmd/af/main.go"
click node_tray "https://github.com/agent-field/agentfield/blob/main/control-plane/cmd/af-tray/main.go"
click node_dashboard "https://github.com/agent-field/agentfield/blob/main/control-plane/web/client/src/main.tsx"
click node_packages "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/packages/installer.go"
click node_sdk_python "https://github.com/agent-field/agentfield/blob/main/sdk/python/agentfield/agent_server.py"
click node_sdk_go "https://github.com/agent-field/agentfield/blob/main/sdk/go/agent/router.go"
click node_sdk_ts "https://github.com/agent-field/agentfield/blob/main/sdk/typescript/src/context/ExecutionContext.ts"
click node_agent_mesh "https://github.com/agent-field/agentfield/blob/main/sdk/python/agentfield/agent.py"
click node_storage "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/storage/storage.go"
click node_workflow_schema "https://github.com/agent-field/agentfield/blob/main/control-plane/migrations/011_create_workflow_runs_and_steps.sql"
click node_memory "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/storage/vector_store.go"
click node_events "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/events/event_bus.go"
click node_identity "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/services/did_service.go"
click node_authorization "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/server/middleware/permission.go"
click node_triggers "https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/triggers.go"
click node_deployment "https://github.com/agent-field/agentfield/blob/main/deployments/helm/agentfield/templates/control-plane-deployment.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_tray,node_dashboard toneBlue
class node_server,node_routes,node_handlers,node_execution,node_workflow,node_cancellation,node_packages,node_deployment toneAmber
class node_sdk_python,node_sdk_go,node_sdk_ts,node_agent_mesh toneMint
class node_storage,node_workflow_schema,node_memory,node_events toneRose
class node_identity,node_authorization,node_triggers toneIndigo
```

## Components

### Operator & client surfaces

- [af CLI](https://github.com/agent-field/agentfield/blob/main/control-plane/cmd/af/main.go): Go CLI · Scaffolds, installs, runs, manages, and verifies agents. · `control-plane/cmd/af/main.go`
- [af tray](https://github.com/agent-field/agentfield/blob/main/control-plane/cmd/af-tray/main.go): macOS companion · `control-plane/cmd/af-tray/main.go`
- [Web dashboard](https://github.com/agent-field/agentfield/blob/main/control-plane/web/client/src/main.tsx): React/Vite UI · Manages fleet state and renders workflow DAGs over APIs and SSE. · `control-plane/web/client/src/main.tsx`

### Control plane

- [Control-plane server](https://github.com/agent-field/agentfield/blob/main/control-plane/cmd/agentfield-server/main.go): Go service · Assembles APIs, services, storage, and maintenance. · `control-plane/cmd/agentfield-server/main.go`
- [API route groups](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/server/server.go): HTTP/gRPC routing · Core, agentic, memory, trigger, governance, connector, and UI APIs. · `control-plane/internal/server/server.go`
- [Request handlers](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/execute.go): API boundary · Validate and authorize requests before invoking services. · `control-plane/internal/handlers/execute.go`
- [Execution lifecycle](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/execute_lifecycle.go): execution service · Resolves targets, records state, and supports lifecycle control. · `control-plane/internal/handlers/execute_lifecycle.go`
- [Workflow DAG](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/workflow_dag.go): workflow service · Persists parent-child execution relationships. · `control-plane/internal/handlers/workflow_dag.go`
- [Cancel dispatcher](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/services/cancel_dispatcher.go): background service · `control-plane/internal/services/cancel_dispatcher.go`
- [Package manager](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/packages/installer.go): agent package service · Acquires repositories, provisions runtimes and credentials, and registers processes. · `control-plane/internal/packages/installer.go`
- [Scalable deployment](https://github.com/agent-field/agentfield/blob/main/deployments/helm/agentfield/templates/control-plane-deployment.yaml): Kubernetes deployment · Stateless control plane scales behind a load balancer with PostgreSQL. · `deployments/helm/agentfield/templates/control-plane-deployment.yaml`

### Agent runtimes

- [Python SDK runtime](https://github.com/agent-field/agentfield/blob/main/sdk/python/agentfield/agent_server.py): agent SDK · Decorated endpoints, control-plane client, async, and serverless support. · `sdk/python/agentfield/agent_server.py`
- [Go SDK runtime](https://github.com/agent-field/agentfield/blob/main/sdk/go/agent/router.go): agent SDK · Hosts agent HTTP endpoints and control-plane calls. · `sdk/go/agent/router.go`
- [TypeScript SDK runtime](https://github.com/agent-field/agentfield/blob/main/sdk/typescript/src/context/ExecutionContext.ts): agent SDK · Propagates execution, workflow, and session context. · `sdk/typescript/src/context/ExecutionContext.ts`
- [Agent mesh](https://github.com/agent-field/agentfield/blob/main/sdk/python/agentfield/agent.py): remote agents · Registered agent nodes expose versions, reasoners, health, and capabilities. · `sdk/python/agentfield/agent.py`

### State & events

- [Storage abstraction](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/storage/storage.go): database layer · SQLite/PostgreSQL persistence, migrations, transactions, and locks. · `control-plane/internal/storage/storage.go`
- [Workflow run state](https://github.com/agent-field/agentfield/blob/main/control-plane/migrations/011_create_workflow_runs_and_steps.sql): database schema · Workflow runs and steps persist the execution DAG. · `control-plane/migrations/011_create_workflow_runs_and_steps.sql`
- [Scoped memory](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/storage/vector_store.go): KV/vector memory · Scoped key-value and vector memory with embedding integration. · `control-plane/internal/storage/vector_store.go`
- [Event bus](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/events/event_bus.go): in-process events · Distributes execution, node, reasoner, trigger, and memory changes. · `control-plane/internal/events/event_bus.go`

### Identity & ingress

- [DID & credentials](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/services/did_service.go): identity service · Establishes agent identity and signed provenance chains. · `control-plane/internal/services/did_service.go`
- [Authorization middleware](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/server/middleware/permission.go): security boundary · Enforces API, DID, permission, admin, rate, and connector-capability controls. · `control-plane/internal/server/middleware/permission.go`
- [Trigger ingress](https://github.com/agent-field/agentfield/blob/main/control-plane/internal/handlers/triggers.go): integration handlers · Authenticates external events before workflow dispatch. · `control-plane/internal/handlers/triggers.go`

## Connections

- 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
