# openjiuwen-ai/agent-runtime architecture

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

- Interactive diagram: https://gitdiagram.com/openjiuwen-ai/agent-runtime
- Repository: https://github.com/openjiuwen-ai/agent-runtime

## Overview

openJiuwen Agent Runtime deploys and manages isolated agent instances, then exposes their own service endpoints for conversations and health checks. The main workflow is management REST request → deployment manager and selected strategy → running agent service. The repository also includes tenant context handling, persistent deployment records, and concrete A2A and workflow-IR applications. The README documents the deployment modes and service capabilities; edges into unsampled deployer and agent implementations are limited to those documented relationships.

Main entry points: [`server/openjiuwen_runtime/server/main.py`](https://github.com/openjiuwen-ai/agent-runtime/blob/main/server/openjiuwen_runtime/server/main.py) (Management REST), [`management/openjiuwen_runtime/management/manager.py`](https://github.com/openjiuwen-ai/agent-runtime/blob/main/management/openjiuwen_runtime/management/manager.py) (Deployment Manager), [`applications/a2a_service/app.py`](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/app.py) (A2A Service), [`applications/ir_execution_service/ir_execution_service/ir_execution_service_app.py`](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/ir_execution_service_app.py) (IR Execution API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Management API"]
  node_server["Management REST<br/>[main.py]"]
  node_tenant["Tenant Context<br/>[tenant.py]"]
end

subgraph group_deploy["Deployment Lifecycle"]
  node_manager["Deployment Manager<br/>[manager.py]"]
  node_deployers["Deployment Strategies"]
  node_sessions["Service Lifecycle<br/>[service_manager.py]"]
end

subgraph group_foundation["Runtime Foundation"]
  node_records[("Deployment Records")]
  node_db["Database Handlers<br/>[handler.py]"]
  node_ports["Port Allocation<br/>[port_utils.py]"]
end

subgraph group_services["Agent Services"]
  node_agent_service["Agent Service API<br/>[agent_app.py]"]
  node_base_app["App Abstractions<br/>[base_app.py]"]
end

subgraph group_apps["Agent Applications"]
  node_a2a["A2A Service<br/>[app.py]"]
  node_router["Conversation Router<br/>[user_router.py]"]
  node_executor["A2A Executor<br/>[executor.py]"]
  node_redis[("A2A Task Store")]
  node_adapter["Versatile Adapter<br/>[app.py]"]
  node_adapter_runner["Adapter Runner<br/>[runner.py]"]
  node_ir_service["IR Execution API"]
  node_invoke["Invoke Execution<br/>[invoke_api.py]"]
  node_stream["Stream Execution<br/>[stream_api.py]"]
  node_memory["Memory Engine"]
end

node_client(("Runtime Client"))

node_client -->|"calls management API"| node_server
node_server -->|"reads tenant context"| node_tenant
node_server -->|"requests deployment actions"| node_manager
node_manager -->|"selects strategy"| node_deployers
node_manager -->|"persists deployments"| node_db
node_db -->|"stores records"| node_records
node_deployers -->|"starts agent instance"| node_agent_service
node_manager -.->|"manages instances"| node_sessions
node_server -->|"allocates ports"| node_ports
node_client -->|"calls agent endpoints"| node_agent_service
node_agent_service -->|"extends app base"| node_base_app
node_a2a -->|"routes conversations"| node_router
node_router -->|"dispatches execution"| node_executor
node_a2a -->|"uses task store"| node_redis
node_a2a -->|"calls internal A2A service"| node_adapter
node_adapter -->|"creates runner"| node_adapter_runner
node_ir_service -->|"routes invoke requests"| node_invoke
node_ir_service -->|"routes stream requests"| node_stream
node_ir_service -->|"extends app base"| node_base_app

click node_server "https://github.com/openjiuwen-ai/agent-runtime/blob/main/server/openjiuwen_runtime/server/main.py"
click node_tenant "https://github.com/openjiuwen-ai/agent-runtime/blob/main/server/openjiuwen_runtime/server/middleware/tenant.py"
click node_manager "https://github.com/openjiuwen-ai/agent-runtime/blob/main/management/openjiuwen_runtime/management/manager.py"
click node_deployers "https://github.com/openjiuwen-ai/agent-runtime/tree/main/management/openjiuwen_runtime/management/deployments"
click node_sessions "https://github.com/openjiuwen-ai/agent-runtime/blob/main/management/openjiuwen_runtime/management/session/service_manager.py"
click node_records "https://github.com/openjiuwen-ai/agent-runtime/blob/main/foundation/openjiuwen_runtime/foundation/db/sqlalchemy_handler.py"
click node_db "https://github.com/openjiuwen-ai/agent-runtime/blob/main/foundation/openjiuwen_runtime/foundation/db/handler.py"
click node_ports "https://github.com/openjiuwen-ai/agent-runtime/blob/main/foundation/openjiuwen_runtime/foundation/port_utils.py"
click node_agent_service "https://github.com/openjiuwen-ai/agent-runtime/blob/main/service/openjiuwen_runtime/service/app/agent_app.py"
click node_base_app "https://github.com/openjiuwen-ai/agent-runtime/blob/main/service/openjiuwen_runtime/service/app/base_app.py"
click node_a2a "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/app.py"
click node_router "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/orchestrator/user_router.py"
click node_executor "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/orchestrator/executor.py"
click node_redis "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/common/redis_task_store.py"
click node_adapter "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/versatile_adapter/app.py"
click node_adapter_runner "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/versatile_adapter/dispatcher/runner.py"
click node_ir_service "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/ir_execution_service_app.py"
click node_invoke "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/invoke_api.py"
click node_stream "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/stream_api.py"
click node_memory "https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/runtime_support/memory_engine_start.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_server,node_tenant,node_client toneBlue
class node_manager,node_deployers,node_sessions toneAmber
class node_records,node_db,node_ports toneMint
class node_agent_service,node_base_app toneRose
class node_a2a,node_router,node_executor,node_redis,node_adapter,node_adapter_runner,node_ir_service,node_invoke,node_stream,node_memory toneIndigo
```

## Components

### Management API

- [Management REST](https://github.com/openjiuwen-ai/agent-runtime/blob/main/server/openjiuwen_runtime/server/main.py): `server/openjiuwen_runtime/server/main.py`
- [Tenant Context](https://github.com/openjiuwen-ai/agent-runtime/blob/main/server/openjiuwen_runtime/server/middleware/tenant.py): `server/openjiuwen_runtime/server/middleware/tenant.py`

### Deployment Lifecycle

- [Deployment Manager](https://github.com/openjiuwen-ai/agent-runtime/blob/main/management/openjiuwen_runtime/management/manager.py): `management/openjiuwen_runtime/management/manager.py`
- [Deployment Strategies](https://github.com/openjiuwen-ai/agent-runtime/tree/main/management/openjiuwen_runtime/management/deployments): `management/openjiuwen_runtime/management/deployments`
- [Service Lifecycle](https://github.com/openjiuwen-ai/agent-runtime/blob/main/management/openjiuwen_runtime/management/session/service_manager.py): `management/openjiuwen_runtime/management/session/service_manager.py`

### Runtime Foundation

- [Deployment Records](https://github.com/openjiuwen-ai/agent-runtime/blob/main/foundation/openjiuwen_runtime/foundation/db/sqlalchemy_handler.py): `foundation/openjiuwen_runtime/foundation/db/sqlalchemy_handler.py`
- [Database Handlers](https://github.com/openjiuwen-ai/agent-runtime/blob/main/foundation/openjiuwen_runtime/foundation/db/handler.py): `foundation/openjiuwen_runtime/foundation/db/handler.py`
- [Port Allocation](https://github.com/openjiuwen-ai/agent-runtime/blob/main/foundation/openjiuwen_runtime/foundation/port_utils.py): `foundation/openjiuwen_runtime/foundation/port_utils.py`

### Agent Services

- [Agent Service API](https://github.com/openjiuwen-ai/agent-runtime/blob/main/service/openjiuwen_runtime/service/app/agent_app.py): `service/openjiuwen_runtime/service/app/agent_app.py`
- [App Abstractions](https://github.com/openjiuwen-ai/agent-runtime/blob/main/service/openjiuwen_runtime/service/app/base_app.py): `service/openjiuwen_runtime/service/app/base_app.py`

### Agent Applications

- [A2A Service](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/app.py): `applications/a2a_service/app.py`
- [Conversation Router](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/orchestrator/user_router.py): `applications/a2a_service/orchestrator/user_router.py`
- [A2A Executor](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/orchestrator/executor.py): `applications/a2a_service/orchestrator/executor.py`
- [A2A Task Store](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/a2a_service/common/redis_task_store.py): `applications/a2a_service/common/redis_task_store.py`
- [Versatile Adapter](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/versatile_adapter/app.py): `applications/versatile_adapter/app.py`
- [Adapter Runner](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/versatile_adapter/dispatcher/runner.py): `applications/versatile_adapter/dispatcher/runner.py`
- [IR Execution API](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/ir_execution_service_app.py): `applications/ir_execution_service/ir_execution_service/ir_execution_service_app.py`
- [Invoke Execution](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/invoke_api.py): `applications/ir_execution_service/ir_execution_service/invoke_api.py`
- [Stream Execution](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/stream_api.py): `applications/ir_execution_service/ir_execution_service/stream_api.py`
- [Memory Engine](https://github.com/openjiuwen-ai/agent-runtime/blob/main/applications/ir_execution_service/ir_execution_service/runtime_support/memory_engine_start.py): `applications/ir_execution_service/ir_execution_service/runtime_support/memory_engine_start.py`

### Other components

- **Runtime Client**

## Connections

- Runtime Client → Management REST: calls management API (evidence: `README.md`)
- Management REST → Tenant Context: reads tenant context (evidence: `server/openjiuwen_runtime/server/main.py`)
- Management REST → Deployment Manager: requests deployment actions (evidence: `server/openjiuwen_runtime/server/main.py`)
- Deployment Manager → Deployment Strategies: selects strategy (evidence: `management/openjiuwen_runtime/management/manager.py`)
- Deployment Manager → Database Handlers: persists deployments (evidence: `management/openjiuwen_runtime/management/manager.py`)
- Database Handlers → Deployment Records: stores records (evidence: `foundation/openjiuwen_runtime/foundation/db/sqlalchemy_handler.py`)
- Deployment Strategies → Agent Service API: starts agent instance (evidence: `README.md`)
- Deployment Manager → Service Lifecycle: manages instances
- Management REST → Port Allocation: allocates ports (evidence: `server/openjiuwen_runtime/server/main.py`)
- Runtime Client → Agent Service API: calls agent endpoints (evidence: `README.md`)
- Agent Service API → App Abstractions: extends app base (evidence: `service/openjiuwen_runtime/service/app/agent_app.py`)
- A2A Service → Conversation Router: routes conversations (evidence: `applications/a2a_service/app.py`)
- Conversation Router → A2A Executor: dispatches execution (evidence: `applications/a2a_service/orchestrator/user_router.py`)
- A2A Service → A2A Task Store: uses task store (evidence: `applications/a2a_service/app.py`)
- A2A Service → Versatile Adapter: calls internal A2A service (evidence: `applications/a2a_service/app.py`)
- Versatile Adapter → Adapter Runner: creates runner (evidence: `applications/versatile_adapter/app.py`)
- IR Execution API → Invoke Execution: routes invoke requests (evidence: `applications/ir_execution_service/ir_execution_service/ir_execution_service_app.py`)
- IR Execution API → Stream Execution: routes stream requests (evidence: `applications/ir_execution_service/ir_execution_service/ir_execution_service_app.py`)
- IR Execution API → App Abstractions: extends app base (evidence: `applications/ir_execution_service/ir_execution_service/ir_execution_service_app.py`)
