# s-toufik/agent-orchestrator architecture

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

- Interactive diagram: https://gitdiagram.com/s-toufik/agent-orchestrator
- Repository: https://github.com/s-toufik/agent-orchestrator

## Overview

agent-orchestrator is an HTTP-served conversational agent. A client streams a message; the agent interprets it, may clarify or propose a tool plan for approval, executes approved work through MCP tools, reviews the answer, and streams the result as SSE. It also exposes model-list and health/info endpoints. The README documents the workflow and integrations; sampled controller, DI, domain, and routing sources support the implementation links. Several step implementations are unsampled, so their detailed internal calls are not shown.

Main entry points: [`src/agent_orchestrator/adapter/outbound/langgraph/langgraph_workflow_runner.py`](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/langgraph/langgraph_workflow_runner.py) (Workflow runner), [`src/agent_orchestrator/domain/turn/turn.py`](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/domain/turn/turn.py) (Turn and conversation), [`src/agent_orchestrator/adapter/inbound/web/controller/stream_agent_controller.py`](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/inbound/web/controller/stream_agent_controller.py) (Stream API), [`src/agent_orchestrator/application/step/plan_step.py`](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/plan_step.py) (Plan step)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP interface"]
  node_stream_api["Stream API"]
  node_sse["SSE presenter<br/>[sse_presenter.py]"]
  node_models_api["Model listing"]
  node_health["Health and info<br/>[actuator_router.py]"]
end

subgraph group_workflow["Agent workflow"]
  node_handle["Message use case<br/>[handle_message.py]"]
  node_graph["Workflow runner"]
  node_policy["Turn policy<br/>[turn_policy.py]"]
  node_understand["Understand step<br/>[understand_step.py]"]
  node_plan["Plan step<br/>[plan_step.py]"]
  node_clarify["Clarify step<br/>[clarify_step.py]"]
  node_act["Act step<br/>[act_step.py]"]
  node_run_tools["Run tools step<br/>[run_tools_step.py]"]
  node_review["Review step<br/>[review_step.py]"]
  node_feedback["Feedback step<br/>[feedback_step.py]"]
  node_finish["Finish step<br/>[finish_step.py]"]
  node_summarize["Summarize step<br/>[summarize_step.py]"]
end

subgraph group_models["Model services"]
  node_catalog["Model catalog<br/>[model_catalog.py]"]
  node_llm["LLM adapters<br/>[chat_models.py]"]
  node_reviewer["Answer reviewer<br/>[reviewer.py]"]
end

subgraph group_tools["Tool execution"]
  node_toolbox["Toolbox<br/>[toolbox.py]"]
  node_mcp["MCP tools"]
end

subgraph group_state["Conversation state"]
  node_domain["Turn and conversation<br/>[turn.py]"]
  node_events["Turn event stream"]
  node_checkpoint[("Checkpoint storage<br/>[agent_di.py]")]
end

node_client(("Client"))
node_model_server{{"Model server"}}
node_mcp_server{{"MCP server"}}
node_databases[("MongoDB / SQLite")]

node_client -->|"sends message"| node_stream_api
node_stream_api -->|"handles request"| node_handle
node_stream_api -->|"reads events"| node_events
node_stream_api -->|"formats events"| node_sse
node_sse -->|"streams SSE"| node_client
node_client -->|"lists models"| node_models_api
node_models_api -.->|"returns models"| node_catalog
node_client -->|"checks status"| node_health
node_handle -.->|"runs workflow"| node_graph
node_graph -->|"routes turns"| node_policy
node_graph -.->|"dispatches steps"| node_understand
node_graph -.->|"dispatches steps"| node_plan
node_graph -.->|"dispatches steps"| node_clarify
node_graph -.->|"dispatches steps"| node_act
node_graph -.->|"dispatches steps"| node_run_tools
node_graph -.->|"dispatches steps"| node_review
node_graph -.->|"dispatches steps"| node_feedback
node_graph -.->|"dispatches steps"| node_finish
node_graph -.->|"dispatches steps"| node_summarize
node_policy -->|"evaluates turn"| node_domain
node_understand -.->|"updates understanding"| node_domain
node_plan -.->|"records plan"| node_domain
node_act -.->|"records draft"| node_domain
node_run_tools -.->|"executes calls"| node_toolbox
node_review -->|"requests review"| node_reviewer
node_reviewer -->|"calls model"| node_llm
node_llm -->|"selects model"| node_catalog
node_llm -->|"sends prompts"| node_model_server
node_plan -.->|"reads tool catalog"| node_toolbox
node_toolbox -.->|"provides tools"| node_mcp
node_mcp -->|"calls tools"| node_mcp_server
node_graph -.->|"persists state"| node_checkpoint
node_checkpoint -->|"stores checkpoints"| node_databases
node_graph -.->|"publishes events"| node_events
node_finish -.->|"concludes turn"| node_domain

click node_stream_api "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/inbound/web/controller/stream_agent_controller.py"
click node_sse "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/inbound/web/sse_presenter.py"
click node_models_api "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/inbound/web/controller/list_models_controller.py"
click node_health "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/bootstrap/router/actuator/actuator_router.py"
click node_handle "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/use_case/handle_message.py"
click node_graph "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/langgraph/langgraph_workflow_runner.py"
click node_policy "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/domain/workflow/turn_policy.py"
click node_understand "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/understand_step.py"
click node_plan "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/plan_step.py"
click node_clarify "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/clarify_step.py"
click node_act "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/act_step.py"
click node_run_tools "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/run_tools_step.py"
click node_review "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/review_step.py"
click node_feedback "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/feedback_step.py"
click node_finish "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/finish_step.py"
click node_summarize "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/summarize_step.py"
click node_domain "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/domain/turn/turn.py"
click node_events "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/event/queue_turn_event_stream.py"
click node_checkpoint "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/bootstrap/di/agent_di.py"
click node_catalog "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/llm/model_catalog.py"
click node_llm "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/llm/langchain/chat_models.py"
click node_reviewer "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/llm/langchain/reviewer.py"
click node_toolbox "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/tool/toolbox.py"
click node_mcp "https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/tool/mcp/mcp_tool_provider.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_stream_api,node_sse,node_models_api,node_health,node_client toneBlue
class node_handle,node_graph,node_policy,node_understand,node_plan,node_clarify,node_act,node_run_tools,node_review,node_feedback,node_finish,node_summarize,node_databases toneAmber
class node_catalog,node_llm,node_reviewer,node_model_server,node_mcp_server toneMint
class node_toolbox,node_mcp toneRose
class node_domain,node_events,node_checkpoint toneIndigo
```

## Components

### HTTP interface

- [Stream API](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/inbound/web/controller/stream_agent_controller.py): `src/agent_orchestrator/adapter/inbound/web/controller/stream_agent_controller.py`
- [SSE presenter](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/inbound/web/sse_presenter.py): `src/agent_orchestrator/adapter/inbound/web/sse_presenter.py`
- [Model listing](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/inbound/web/controller/list_models_controller.py): `src/agent_orchestrator/adapter/inbound/web/controller/list_models_controller.py`
- [Health and info](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/bootstrap/router/actuator/actuator_router.py): `src/bootstrap/router/actuator/actuator_router.py`

### Agent workflow

- [Message use case](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/use_case/handle_message.py): `src/agent_orchestrator/application/use_case/handle_message.py`
- [Workflow runner](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/langgraph/langgraph_workflow_runner.py): `src/agent_orchestrator/adapter/outbound/langgraph/langgraph_workflow_runner.py`
- [Turn policy](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/domain/workflow/turn_policy.py): `src/agent_orchestrator/domain/workflow/turn_policy.py`
- [Understand step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/understand_step.py): `src/agent_orchestrator/application/step/understand_step.py`
- [Plan step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/plan_step.py): `src/agent_orchestrator/application/step/plan_step.py`
- [Clarify step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/clarify_step.py): `src/agent_orchestrator/application/step/clarify_step.py`
- [Act step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/act_step.py): `src/agent_orchestrator/application/step/act_step.py`
- [Run tools step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/run_tools_step.py): `src/agent_orchestrator/application/step/run_tools_step.py`
- [Review step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/review_step.py): `src/agent_orchestrator/application/step/review_step.py`
- [Feedback step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/feedback_step.py): `src/agent_orchestrator/application/step/feedback_step.py`
- [Finish step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/finish_step.py): `src/agent_orchestrator/application/step/finish_step.py`
- [Summarize step](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/application/step/summarize_step.py): `src/agent_orchestrator/application/step/summarize_step.py`

### Model services

- [Model catalog](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/llm/model_catalog.py): `src/agent_orchestrator/adapter/outbound/llm/model_catalog.py`
- [LLM adapters](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/llm/langchain/chat_models.py): `src/agent_orchestrator/adapter/outbound/llm/langchain/chat_models.py`
- [Answer reviewer](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/llm/langchain/reviewer.py): `src/agent_orchestrator/adapter/outbound/llm/langchain/reviewer.py`

### Tool execution

- [Toolbox](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/tool/toolbox.py): `src/agent_orchestrator/adapter/outbound/tool/toolbox.py`
- [MCP tools](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/tool/mcp/mcp_tool_provider.py): `src/agent_orchestrator/adapter/outbound/tool/mcp/mcp_tool_provider.py`

### Conversation state

- [Turn and conversation](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/domain/turn/turn.py): `src/agent_orchestrator/domain/turn/turn.py`
- [Turn event stream](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/agent_orchestrator/adapter/outbound/event/queue_turn_event_stream.py): `src/agent_orchestrator/adapter/outbound/event/queue_turn_event_stream.py`
- [Checkpoint storage](https://github.com/s-toufik/agent-orchestrator/blob/develop/src/bootstrap/di/agent_di.py): `src/bootstrap/di/agent_di.py`

### Other components

- **Client**
- **Model server**
- **MCP server**
- **MongoDB / SQLite**

## Connections

- Client → Stream API: sends message
- Stream API → Message use case: handles request (evidence: `src/agent_orchestrator/adapter/inbound/web/controller/stream_agent_controller.py`)
- Stream API → Turn event stream: reads events (evidence: `src/agent_orchestrator/adapter/inbound/web/controller/stream_agent_controller.py`)
- Stream API → SSE presenter: formats events (evidence: `src/agent_orchestrator/adapter/inbound/web/controller/stream_agent_controller.py`)
- SSE presenter → Client: streams SSE
- Client → Model listing: lists models
- Model listing → Model catalog: returns models
- Client → Health and info: checks status
- Message use case → Workflow runner: runs workflow
- Workflow runner → Turn policy: routes turns
- Workflow runner → Understand step: dispatches steps
- Workflow runner → Plan step: dispatches steps
- Workflow runner → Clarify step: dispatches steps
- Workflow runner → Act step: dispatches steps
- Workflow runner → Run tools step: dispatches steps
- Workflow runner → Review step: dispatches steps
- Workflow runner → Feedback step: dispatches steps
- Workflow runner → Finish step: dispatches steps
- Workflow runner → Summarize step: dispatches steps
- Turn policy → Turn and conversation: evaluates turn (evidence: `src/agent_orchestrator/domain/workflow/turn_policy.py`)
- Understand step → Turn and conversation: updates understanding
- Plan step → Turn and conversation: records plan
- Act step → Turn and conversation: records draft
- Run tools step → Toolbox: executes calls
- Review step → Answer reviewer: requests review (evidence: `src/agent_orchestrator/application/step/review_step.py`)
- Answer reviewer → LLM adapters: calls model (evidence: `src/agent_orchestrator/adapter/outbound/llm/langchain/reviewer.py`)
- LLM adapters → Model catalog: selects model (evidence: `src/agent_orchestrator/adapter/outbound/llm/langchain/reviewer.py`)
- LLM adapters → Model server: sends prompts
- Plan step → Toolbox: reads tool catalog
- Toolbox → MCP tools: provides tools
- MCP tools → MCP server: calls tools
- Workflow runner → Checkpoint storage: persists state (evidence: `src/bootstrap/di/agent_di.py`)
- Checkpoint storage → MongoDB / SQLite: stores checkpoints
- Workflow runner → Turn event stream: publishes events
- Finish step → Turn and conversation: concludes turn
