# edem-ai/agentchord architecture

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

- Interactive diagram: https://gitdiagram.com/edem-ai/agentchord
- Repository: https://github.com/edem-ai/agentchord

## Overview

AgentChord is a recovery-aware robotic manipulation system built on the EmbodiChain runtime. Its primary workflow structures a nominal task graph from instructions and scene observations, adds predicted-failure monitors and recovery branches, compiles the result into interruptible behaviors, then executes them in simulation or on a real robot. The repository also includes EmbodiChain simulation, perception, robot-control, learning, and manipulation-toolkit capabilities. Some subsystem links are documented in the README; unsampled implementation details are not inferred as direct calls.

Main entry points: [`embodichain/deploy/robots/cobotmagic/controller.py`](https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/robots/cobotmagic/controller.py) (CobotMagic controller), [`embodichain/agents/hierarchy/compile_agent.py`](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/hierarchy/compile_agent.py) (Execution compilation), [`embodichain/agents/hierarchy/task_agent.py`](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/hierarchy/task_agent.py) (Task structuring), [`embodichain/lab/gym/envs/embodied_env.py`](https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/gym/envs/embodied_env.py) (Gym environments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["AgentChord planning"]
  node_task["Task structuring<br/>[task_agent.py]"]
  node_recovery["Recovery orchestration<br/>[recovery_agent.py]"]
  node_compiler["Execution compilation<br/>[compile_agent.py]"]
  node_graphspec["Graph specification<br/>[graph_spec.py]"]
  node_actions["Atomic actions<br/>[atom_actions.py]"]
  node_monitors["Failure monitors"]
end

subgraph group_runtime["Embodied runtime"]
  node_simrunner["Simulation runner<br/>[run_agent.py]"]
  node_environment["Gym environments<br/>[embodied_env.py]"]
  node_managers["Environment managers<br/>[manager_base.py]"]
  node_simulator["Simulation manager<br/>[sim_manager.py]"]
  node_simobjects["Simulation objects<br/>[articulation.py]"]
  node_simactions["Motion action engine<br/>[engine.py]"]
end

subgraph group_deployment["Robot deployment"]
  node_realrunner["Real-world runner"]
  node_controller["CobotMagic controller<br/>[controller.py]"]
  node_ros["ROS bridge<br/>[ros_bridge.py]"]
  node_perception["Pose perception<br/>[pose_estimation.py]"]
  node_sam["SAM mask detection<br/>[mask_detector.py]"]
end

subgraph group_capabilities["Supporting capabilities"]
  node_rl["RL training<br/>[train.py]"]
  node_data[("Dataset utilities<br/>[dataset.py]")]
  node_grasp["Grasp generation"]
  node_urdf["URDF assembly"]
  node_config["Configuration utilities<br/>[configclass.py]"]
  node_logging["Logging<br/>[logger.py]"]
end

node_user(("Task instruction"))
node_llm(("LLM endpoint"))

node_user -->|"provides task"| node_task
node_task -->|"builds graph"| node_graphspec
node_recovery -->|"adds branches"| node_graphspec
node_task -.->|"queries model"| node_llm
node_recovery -.->|"queries model"| node_llm
node_compiler -.->|"queries model"| node_llm
node_compiler -->|"compiles graph"| node_graphspec
node_compiler -->|"compiles behaviors"| node_actions
node_compiler -->|"compiles monitors"| node_monitors
node_simrunner -->|"runs agents"| node_compiler
node_simrunner -->|"runs in"| node_environment
node_environment -.->|"uses managers"| node_managers
node_environment -.->|"uses simulation"| node_simulator
node_simulator -->|"manages objects"| node_simobjects
node_simrunner -.->|"executes actions"| node_simactions
node_realrunner -->|"starts controller"| node_controller
node_controller -->|"uses bridge"| node_ros
node_controller -->|"estimates poses"| node_perception
node_perception -->|"requests masks"| node_sam
node_controller -->|"invokes agent"| node_task
node_controller -->|"invokes agent"| node_recovery
node_controller -->|"invokes agent"| node_compiler
node_rl -.->|"trains in"| node_environment
node_grasp -.->|"supports manipulation"| node_perception
node_urdf -.->|"supplies robot models"| node_simobjects
node_config -->|"configures managers"| node_managers
node_realrunner -.->|"loads data"| node_data

click node_task "https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/hierarchy/task_agent.py"
click node_recovery "https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/hierarchy/recovery_agent.py"
click node_compiler "https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/hierarchy/compile_agent.py"
click node_graphspec "https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/agentchord/graph_spec.py"
click node_actions "https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/agentchord/atom_actions.py"
click node_monitors "https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/agentchord/monitor_functions.py"
click node_simrunner "https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/scripts/run_agent.py"
click node_environment "https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/gym/envs/embodied_env.py"
click node_managers "https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/gym/envs/managers/manager_base.py"
click node_simulator "https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/sim/sim_manager.py"
click node_simobjects "https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/sim/objects/articulation.py"
click node_simactions "https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/sim/atomic_actions/engine.py"
click node_realrunner "https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/run_agent_realworld.py"
click node_controller "https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/robots/cobotmagic/controller.py"
click node_ros "https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/robots/cobotmagic/ros_bridge.py"
click node_perception "https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/perception/pose_estimation.py"
click node_sam "https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/tools/sam3/mask_detector.py"
click node_rl "https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/rl/train.py"
click node_data "https://github.com/edem-ai/agentchord/blob/main/embodichain/data/dataset.py"
click node_grasp "https://github.com/edem-ai/agentchord/blob/main/embodichain/toolkits/graspkit/pg_grasp/antipodal_generator.py"
click node_urdf "https://github.com/edem-ai/agentchord/blob/main/embodichain/toolkits/urdf_assembly/urdf_assembly_manager.py"
click node_config "https://github.com/edem-ai/agentchord/blob/main/embodichain/utils/configclass.py"
click node_logging "https://github.com/edem-ai/agentchord/blob/main/embodichain/utils/logger.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_task,node_recovery,node_compiler,node_graphspec,node_actions,node_monitors toneBlue
class node_simrunner,node_environment,node_managers,node_simulator,node_simobjects,node_simactions toneAmber
class node_realrunner,node_controller,node_ros,node_perception,node_sam toneMint
class node_rl,node_data,node_grasp,node_urdf,node_config,node_logging,node_user toneRose
class node_llm toneIndigo
```

## Components

### AgentChord planning

- [Task structuring](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/hierarchy/task_agent.py): `embodichain/agents/hierarchy/task_agent.py`
- [Recovery orchestration](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/hierarchy/recovery_agent.py): `embodichain/agents/hierarchy/recovery_agent.py`
- [Execution compilation](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/hierarchy/compile_agent.py): `embodichain/agents/hierarchy/compile_agent.py`
- [Graph specification](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/agentchord/graph_spec.py): `embodichain/agents/agentchord/graph_spec.py`
- [Atomic actions](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/agentchord/atom_actions.py): `embodichain/agents/agentchord/atom_actions.py`
- [Failure monitors](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/agentchord/monitor_functions.py): `embodichain/agents/agentchord/monitor_functions.py`

### Embodied runtime

- [Simulation runner](https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/scripts/run_agent.py): `embodichain/lab/scripts/run_agent.py`
- [Gym environments](https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/gym/envs/embodied_env.py): `embodichain/lab/gym/envs/embodied_env.py`
- [Environment managers](https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/gym/envs/managers/manager_base.py): `embodichain/lab/gym/envs/managers/manager_base.py`
- [Simulation manager](https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/sim/sim_manager.py): `embodichain/lab/sim/sim_manager.py`
- [Simulation objects](https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/sim/objects/articulation.py): `embodichain/lab/sim/objects/articulation.py`
- [Motion action engine](https://github.com/edem-ai/agentchord/blob/main/embodichain/lab/sim/atomic_actions/engine.py): `embodichain/lab/sim/atomic_actions/engine.py`

### Robot deployment

- [Real-world runner](https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/run_agent_realworld.py): `embodichain/deploy/run_agent_realworld.py`
- [CobotMagic controller](https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/robots/cobotmagic/controller.py): `embodichain/deploy/robots/cobotmagic/controller.py`
- [ROS bridge](https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/robots/cobotmagic/ros_bridge.py): `embodichain/deploy/robots/cobotmagic/ros_bridge.py`
- [Pose perception](https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/perception/pose_estimation.py): `embodichain/deploy/perception/pose_estimation.py`
- [SAM mask detection](https://github.com/edem-ai/agentchord/blob/main/embodichain/deploy/tools/sam3/mask_detector.py): `embodichain/deploy/tools/sam3/mask_detector.py`

### Supporting capabilities

- [RL training](https://github.com/edem-ai/agentchord/blob/main/embodichain/agents/rl/train.py): `embodichain/agents/rl/train.py`
- [Dataset utilities](https://github.com/edem-ai/agentchord/blob/main/embodichain/data/dataset.py): `embodichain/data/dataset.py`
- [Grasp generation](https://github.com/edem-ai/agentchord/blob/main/embodichain/toolkits/graspkit/pg_grasp/antipodal_generator.py): `embodichain/toolkits/graspkit/pg_grasp/antipodal_generator.py`
- [URDF assembly](https://github.com/edem-ai/agentchord/blob/main/embodichain/toolkits/urdf_assembly/urdf_assembly_manager.py): `embodichain/toolkits/urdf_assembly/urdf_assembly_manager.py`
- [Configuration utilities](https://github.com/edem-ai/agentchord/blob/main/embodichain/utils/configclass.py): `embodichain/utils/configclass.py`
- [Logging](https://github.com/edem-ai/agentchord/blob/main/embodichain/utils/logger.py): `embodichain/utils/logger.py`

### Other components

- **Task instruction**
- **LLM endpoint**

## Connections

- Task instruction → Task structuring: provides task
- Task structuring → Graph specification: builds graph
- Recovery orchestration → Graph specification: adds branches
- Task structuring → LLM endpoint: queries model
- Recovery orchestration → LLM endpoint: queries model
- Execution compilation → LLM endpoint: queries model
- Execution compilation → Graph specification: compiles graph (evidence: `embodichain/agents/hierarchy/compile_agent.py`)
- Execution compilation → Atomic actions: compiles behaviors
- Execution compilation → Failure monitors: compiles monitors
- Simulation runner → Execution compilation: runs agents
- Simulation runner → Gym environments: runs in
- Gym environments → Environment managers: uses managers
- Gym environments → Simulation manager: uses simulation
- Simulation manager → Simulation objects: manages objects (evidence: `embodichain/lab/sim/sim_manager.py`)
- Simulation runner → Motion action engine: executes actions
- Real-world runner → CobotMagic controller: starts controller (evidence: `embodichain/deploy/run_agent_realworld.py`)
- CobotMagic controller → ROS bridge: uses bridge (evidence: `embodichain/deploy/robots/cobotmagic/controller.py`)
- CobotMagic controller → Pose perception: estimates poses (evidence: `embodichain/deploy/robots/cobotmagic/controller.py`)
- Pose perception → SAM mask detection: requests masks (evidence: `embodichain/deploy/perception/pose_estimation.py`)
- CobotMagic controller → Task structuring: invokes agent (evidence: `embodichain/deploy/robots/cobotmagic/controller.py`)
- CobotMagic controller → Recovery orchestration: invokes agent (evidence: `embodichain/deploy/robots/cobotmagic/controller.py`)
- CobotMagic controller → Execution compilation: invokes agent (evidence: `embodichain/deploy/robots/cobotmagic/controller.py`)
- RL training → Gym environments: trains in
- Grasp generation → Pose perception: supports manipulation
- URDF assembly → Simulation objects: supplies robot models
- Configuration utilities → Environment managers: configures managers (evidence: `embodichain/lab/gym/envs/managers/cfg.py`)
- Real-world runner → Dataset utilities: loads data
