# microsoft/agensh architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/agensh
- Repository: https://github.com/microsoft/agensh

## Overview

Agensh is a decentralized multi-agent harness for completing repository tasks. Its principal workflow configures a project and task pack, launches workers, routes Gitea and Mattermost activity to each worker’s agent runtime, and shares context for asynchronous task claiming, verification, and integration. The map also includes quality gates and the project hooks used for preparation, synchronization, and evaluation. Relationships are limited to README statements and SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`agensh/team_run.py`](https://github.com/microsoft/agensh/blob/main/agensh/team_run.py) (Team driver), [`mini-router/src/main.ts`](https://github.com/microsoft/agensh/blob/main/mini-router/src/main.ts) (Router startup), [`agent/harness_config.py`](https://github.com/microsoft/agensh/blob/main/agent/harness_config.py) (Harness settings), [`agensh/project.py`](https://github.com/microsoft/agensh/blob/main/agensh/project.py) (Project configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_team["Team orchestration"]
  node_teamrun["Team driver<br/>[team_run.py]"]
  node_pack["Task pack<br/>[pack.py]"]
  node_allocation["Work allocation<br/>[allocate.py]"]
  node_backlog["Task backlog<br/>[backlog.py]"]
  node_schedule["Team schedule<br/>[schedule.py]"]
  node_quality["Quality gates<br/>[quality.py]"]
end

subgraph group_routing["Worker event routing"]
  node_router["Router startup<br/>[main.ts]"]
  node_gitea["Gitea listener<br/>[listener.ts]"]
  node_mattermost["Mattermost listener<br/>[listener.ts]"]
  node_dispatcher["Event dispatcher<br/>[dispatcher.ts]"]
  node_eventstate[("Event state<br/>[state.ts]")]
  node_acpchannel["ACP channel"]
end

subgraph group_context["Shared context"]
  node_boardclient["Board client<br/>[board_client.ts]"]
  node_boardservice["Board service<br/>[main.py]"]
  node_sharedlessons[("Shared lessons<br/>[shared_lessons.py]")]
  node_boardquery["Board search<br/>[gquery.py]"]
end

subgraph group_agents["Agent runtimes"]
  node_harnessconfig["Harness settings<br/>[harness_config.py]"]
  node_acpbridge["ACP bridge<br/>[acp_bridge.py]"]
  node_pi["Pi adapter<br/>[acp.py]"]
  node_codex["Codex adapter<br/>[acp.py]"]
  node_claude["Claude adapter<br/>[acp.py]"]
end

subgraph group_project["Project lifecycle"]
  node_project["Project configuration<br/>[project.py]"]
  node_hooks["Project hooks<br/>[common.py]"]
end

node_user(("Task owner"))
node_worker(("Agent worker"))
node_giteaservice[("Gitea workspace")]
node_mmservice["Mattermost messaging"]

node_user -->|"starts task"| node_teamrun
node_teamrun -->|"loads pack"| node_pack
node_teamrun -->|"coordinates work"| node_backlog
node_teamrun -->|"schedules workers"| node_schedule
node_teamrun -->|"evaluates results"| node_quality
node_teamrun -->|"seeds workspace"| node_giteaservice
node_teamrun -->|"posts kickoff"| node_mmservice
node_teamrun -->|"wakes workers"| node_worker
node_project -->|"loads pack"| node_pack
node_project -->|"uses allocation"| node_allocation
node_project -->|"reads settings"| node_harnessconfig
node_worker -->|"receives events"| node_router
node_router -->|"creates store"| node_eventstate
node_router -->|"creates dispatcher"| node_dispatcher
node_router -->|"creates channel"| node_acpchannel
node_router -->|"starts listener"| node_gitea
node_router -->|"starts listener"| node_mattermost
node_router -->|"configures client"| node_boardclient
node_gitea -->|"fetches activity"| node_giteaservice
node_mattermost -->|"receives messages"| node_mmservice
node_dispatcher -->|"reads events"| node_eventstate
node_dispatcher -->|"dispatches events"| node_acpchannel
node_boardclient -->|"fetches context"| node_boardservice
node_boardservice -->|"persists gists"| node_sharedlessons
node_boardservice -->|"uses query parser"| node_boardquery
node_worker -->|"shares workspace"| node_giteaservice
node_worker -->|"coordinates through"| node_mmservice
node_worker -->|"shares context"| node_boardservice
node_harnessconfig -->|"configures runtime"| node_pi
node_harnessconfig -->|"configures runtime"| node_codex
node_harnessconfig -->|"configures runtime"| node_claude
node_acpbridge -->|"bridges ACP"| node_worker
node_hooks -->|"uses project tools"| node_project

click node_teamrun "https://github.com/microsoft/agensh/blob/main/agensh/team_run.py"
click node_pack "https://github.com/microsoft/agensh/blob/main/agensh/pack.py"
click node_allocation "https://github.com/microsoft/agensh/blob/main/agensh/allocate.py"
click node_backlog "https://github.com/microsoft/agensh/blob/main/agensh/backlog.py"
click node_schedule "https://github.com/microsoft/agensh/blob/main/agensh/schedule.py"
click node_quality "https://github.com/microsoft/agensh/blob/main/agensh/quality.py"
click node_router "https://github.com/microsoft/agensh/blob/main/mini-router/src/main.ts"
click node_gitea "https://github.com/microsoft/agensh/blob/main/mini-router/src/listeners/gitea/listener.ts"
click node_mattermost "https://github.com/microsoft/agensh/blob/main/mini-router/src/listeners/mattermost/listener.ts"
click node_dispatcher "https://github.com/microsoft/agensh/blob/main/mini-router/src/dispatcher.ts"
click node_eventstate "https://github.com/microsoft/agensh/blob/main/mini-router/src/state.ts"
click node_acpchannel "https://github.com/microsoft/agensh/blob/main/mini-router/src/acp_socket_channel.ts"
click node_boardclient "https://github.com/microsoft/agensh/blob/main/mini-router/src/board_client.ts"
click node_boardservice "https://github.com/microsoft/agensh/blob/main/board-service/main.py"
click node_sharedlessons "https://github.com/microsoft/agensh/blob/main/board-service/shared_lessons.py"
click node_boardquery "https://github.com/microsoft/agensh/blob/main/board-service/gquery.py"
click node_project "https://github.com/microsoft/agensh/blob/main/agensh/project.py"
click node_hooks "https://github.com/microsoft/agensh/blob/main/tasks/software-project/hooks/common.py"
click node_harnessconfig "https://github.com/microsoft/agensh/blob/main/agent/harness_config.py"
click node_acpbridge "https://github.com/microsoft/agensh/blob/main/agent/acp_bridge.py"
click node_pi "https://github.com/microsoft/agensh/blob/main/agent/pi/acp.py"
click node_codex "https://github.com/microsoft/agensh/blob/main/agent/codex/acp.py"
click node_claude "https://github.com/microsoft/agensh/blob/main/agent/claude/acp.py"

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_teamrun,node_pack,node_allocation,node_backlog,node_schedule,node_quality toneBlue
class node_router,node_gitea,node_mattermost,node_dispatcher,node_eventstate,node_acpchannel,node_giteaservice toneAmber
class node_boardclient,node_boardservice,node_sharedlessons,node_boardquery toneMint
class node_harnessconfig,node_acpbridge,node_pi,node_codex,node_claude,node_user,node_worker toneRose
class node_project,node_hooks,node_mmservice toneIndigo
```

## Components

### Team orchestration

- [Team driver](https://github.com/microsoft/agensh/blob/main/agensh/team_run.py): `agensh/team_run.py`
- [Task pack](https://github.com/microsoft/agensh/blob/main/agensh/pack.py): `agensh/pack.py`
- [Work allocation](https://github.com/microsoft/agensh/blob/main/agensh/allocate.py): `agensh/allocate.py`
- [Task backlog](https://github.com/microsoft/agensh/blob/main/agensh/backlog.py): `agensh/backlog.py`
- [Team schedule](https://github.com/microsoft/agensh/blob/main/agensh/schedule.py): `agensh/schedule.py`
- [Quality gates](https://github.com/microsoft/agensh/blob/main/agensh/quality.py): `agensh/quality.py`

### Worker event routing

- [Router startup](https://github.com/microsoft/agensh/blob/main/mini-router/src/main.ts): `mini-router/src/main.ts`
- [Gitea listener](https://github.com/microsoft/agensh/blob/main/mini-router/src/listeners/gitea/listener.ts): `mini-router/src/listeners/gitea/listener.ts`
- [Mattermost listener](https://github.com/microsoft/agensh/blob/main/mini-router/src/listeners/mattermost/listener.ts): `mini-router/src/listeners/mattermost/listener.ts`
- [Event dispatcher](https://github.com/microsoft/agensh/blob/main/mini-router/src/dispatcher.ts): `mini-router/src/dispatcher.ts`
- [Event state](https://github.com/microsoft/agensh/blob/main/mini-router/src/state.ts): `mini-router/src/state.ts`
- [ACP channel](https://github.com/microsoft/agensh/blob/main/mini-router/src/acp_socket_channel.ts): `mini-router/src/acp_socket_channel.ts`

### Shared context

- [Board client](https://github.com/microsoft/agensh/blob/main/mini-router/src/board_client.ts): `mini-router/src/board_client.ts`
- [Board service](https://github.com/microsoft/agensh/blob/main/board-service/main.py): `board-service/main.py`
- [Shared lessons](https://github.com/microsoft/agensh/blob/main/board-service/shared_lessons.py): `board-service/shared_lessons.py`
- [Board search](https://github.com/microsoft/agensh/blob/main/board-service/gquery.py): `board-service/gquery.py`

### Agent runtimes

- [Harness settings](https://github.com/microsoft/agensh/blob/main/agent/harness_config.py): `agent/harness_config.py`
- [ACP bridge](https://github.com/microsoft/agensh/blob/main/agent/acp_bridge.py): `agent/acp_bridge.py`
- [Pi adapter](https://github.com/microsoft/agensh/blob/main/agent/pi/acp.py): `agent/pi/acp.py`
- [Codex adapter](https://github.com/microsoft/agensh/blob/main/agent/codex/acp.py): `agent/codex/acp.py`
- [Claude adapter](https://github.com/microsoft/agensh/blob/main/agent/claude/acp.py): `agent/claude/acp.py`

### Project lifecycle

- [Project configuration](https://github.com/microsoft/agensh/blob/main/agensh/project.py): `agensh/project.py`
- [Project hooks](https://github.com/microsoft/agensh/blob/main/tasks/software-project/hooks/common.py): `tasks/software-project/hooks/common.py`

### Other components

- **Task owner**
- **Agent worker**
- **Gitea workspace**
- **Mattermost messaging**

## Connections

- Task owner → Team driver: starts task (evidence: `README.md`)
- Team driver → Task pack: loads pack (evidence: `agensh/team_run.py`)
- Team driver → Task backlog: coordinates work (evidence: `agensh/team_run.py`)
- Team driver → Team schedule: schedules workers (evidence: `agensh/team_run.py`)
- Team driver → Quality gates: evaluates results (evidence: `agensh/team_run.py`)
- Team driver → Gitea workspace: seeds workspace (evidence: `agensh/team_run.py`)
- Team driver → Mattermost messaging: posts kickoff (evidence: `agensh/team_run.py`)
- Team driver → Agent worker: wakes workers (evidence: `agensh/team_run.py`)
- Project configuration → Task pack: loads pack (evidence: `agensh/project.py`)
- Project configuration → Work allocation: uses allocation (evidence: `agensh/project.py`)
- Project configuration → Harness settings: reads settings (evidence: `agensh/project.py`)
- Agent worker → Router startup: receives events (evidence: `README.md`)
- Router startup → Event state: creates store (evidence: `mini-router/src/main.ts`)
- Router startup → Event dispatcher: creates dispatcher (evidence: `mini-router/src/main.ts`)
- Router startup → ACP channel: creates channel (evidence: `mini-router/src/main.ts`)
- Router startup → Gitea listener: starts listener (evidence: `mini-router/src/main.ts`)
- Router startup → Mattermost listener: starts listener (evidence: `mini-router/src/main.ts`)
- Router startup → Board client: configures client (evidence: `mini-router/src/main.ts`)
- Gitea listener → Gitea workspace: fetches activity (evidence: `README.md`)
- Mattermost listener → Mattermost messaging: receives messages (evidence: `README.md`)
- Event dispatcher → Event state: reads events (evidence: `mini-router/src/dispatcher.ts`)
- Event dispatcher → ACP channel: dispatches events (evidence: `mini-router/src/dispatcher.ts`)
- Board client → Board service: fetches context (evidence: `mini-router/src/board_client.ts`)
- Board service → Shared lessons: persists gists (evidence: `board-service/main.py`)
- Board service → Board search: uses query parser (evidence: `board-service/main.py`)
- Agent worker → Gitea workspace: shares workspace (evidence: `README.md`)
- Agent worker → Mattermost messaging: coordinates through (evidence: `README.md`)
- Agent worker → Board service: shares context (evidence: `README.md`)
- Harness settings → Pi adapter: configures runtime (evidence: `agent/pi/acp.py`)
- Harness settings → Codex adapter: configures runtime (evidence: `agent/codex/acp.py`)
- Harness settings → Claude adapter: configures runtime (evidence: `agent/claude/acp.py`)
- ACP bridge → Agent worker: bridges ACP (evidence: `README.md`)
- Project hooks → Project configuration: uses project tools (evidence: `tasks/software-project/hooks/common.py`)
