# copilotkit/opentag architecture

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

- Interactive diagram: https://gitdiagram.com/copilotkit/opentag
- Repository: https://github.com/copilotkit/opentag

## Overview

OpenTag is a self-hosted knowledge-work agent for Slack and Microsoft Teams. A user starts work in a channel thread or with a slash command; the Channels runtime forwards the request to the Python LangGraph agent, which can research, use connected apps, or perform coding work. Results return as thread replies and generative UI. Mutating connected-app actions can pause for human approval and resume. The README documents the major capabilities; some subsystem links below rely on that documentation because their implementation was not sampled.

Main entry points: [`agent/agent.py`](https://github.com/copilotkit/opentag/blob/main/agent/agent.py) (Knowledge agent), [`agent/composio_tools/tools.py`](https://github.com/copilotkit/opentag/blob/main/agent/composio_tools/tools.py) (Composio tools), [`agent/coding/repository_tools.py`](https://github.com/copilotkit/opentag/blob/main/agent/coding/repository_tools.py) (Repository tools), [`app/runtime-host.ts`](https://github.com/copilotkit/opentag/blob/main/app/runtime-host.ts) (Node runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_channel["Channel Experience"]
  node_channel["Channel lifecycle<br/>[channel.tsx]"]
  node_commands["Slash commands<br/>[index.ts]"]
  node_runtime["Node runtime<br/>[runtime-host.ts]"]
end

subgraph group_agent["Agent Workflow"]
  node_agentapi["Agent API<br/>[main.py]"]
  node_graph["Knowledge agent<br/>[agent.py]"]
  node_research["Web research<br/>[web_search.py]"]
  node_internal["Internal sources"]
end

subgraph group_integrations["Connected Capabilities"]
  node_coding["Coding agent<br/>[subagent.py]"]
  node_repository["Repository tools"]
  node_sandbox["Coding sandbox<br/>[sandbox.py]"]
  node_composio["Composio tools<br/>[tools.py]"]
  node_composio_state["Actor identity<br/>[state.py]"]
  node_composio_sessions["Composio sessions<br/>[sessions.py]"]
  node_arcade["Arcade tools<br/>[tools.py]"]
end

subgraph group_interaction["Human Interaction"]
  node_approval["Write approval gate"]
  node_approval_ui["Approval UI<br/>[confirm-write.tsx]"]
  node_generative["Generative UI<br/>[block-catalog.tsx]"]
end

node_user(("Channel user"))
node_slackteams(("Slack / Teams"))
node_web{{"Web search provider"}}
node_appservices{{"Connected app services"}}
node_github{{"GitHub"}}

node_user -->|"messages in"| node_slackteams
node_slackteams -->|"delivers events"| node_channel
node_channel -->|"runs channel"| node_runtime
node_user -->|"invokes command"| node_commands
node_commands -->|"starts agent run"| node_runtime
node_runtime -->|"forwards run"| node_agentapi
node_agentapi -->|"serves graph"| node_graph
node_graph -->|"uses research tools"| node_research
node_research -.->|"searches web"| node_web
node_graph -->|"uses source tools"| node_internal
node_graph -->|"delegates coding"| node_coding
node_coding -->|"uses repository tools"| node_repository
node_repository -->|"executes in"| node_sandbox
node_graph -->|"registers tools"| node_composio
node_graph -->|"registers tools"| node_arcade
node_composio -->|"reads actor"| node_composio_state
node_composio -->|"uses sessions"| node_composio_sessions
node_composio -.->|"executes actions"| node_appservices
node_arcade -.->|"executes actions"| node_appservices
node_graph -->|"gates writes"| node_approval
node_approval -->|"requests confirmation"| node_approval_ui
node_approval_ui -->|"resumes run"| node_graph
node_graph -.->|"returns native UI"| node_generative
node_repository -->|"publishes changes"| node_github

click node_channel "https://github.com/copilotkit/opentag/blob/main/app/channel.tsx"
click node_commands "https://github.com/copilotkit/opentag/blob/main/app/commands/index.ts"
click node_runtime "https://github.com/copilotkit/opentag/blob/main/app/runtime-host.ts"
click node_agentapi "https://github.com/copilotkit/opentag/blob/main/agent/main.py"
click node_graph "https://github.com/copilotkit/opentag/blob/main/agent/agent.py"
click node_research "https://github.com/copilotkit/opentag/blob/main/agent/prompts/web_search.py"
click node_internal "https://github.com/copilotkit/opentag/blob/main/agent/internal_sources.py"
click node_coding "https://github.com/copilotkit/opentag/blob/main/agent/coding/subagent.py"
click node_repository "https://github.com/copilotkit/opentag/blob/main/agent/coding/repository_tools.py"
click node_sandbox "https://github.com/copilotkit/opentag/blob/main/agent/coding/sandbox.py"
click node_composio "https://github.com/copilotkit/opentag/blob/main/agent/composio_tools/tools.py"
click node_composio_state "https://github.com/copilotkit/opentag/blob/main/agent/composio_tools/state.py"
click node_composio_sessions "https://github.com/copilotkit/opentag/blob/main/agent/composio_tools/sessions.py"
click node_arcade "https://github.com/copilotkit/opentag/blob/main/agent/arcade_tools/tools.py"
click node_approval "https://github.com/copilotkit/opentag/blob/main/agent/write_confirmation.py"
click node_approval_ui "https://github.com/copilotkit/opentag/blob/main/app/human-in-the-loop/confirm-write.tsx"
click node_generative "https://github.com/copilotkit/opentag/blob/main/app/tools/block-catalog.tsx"

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_channel,node_commands,node_runtime,node_user toneBlue
class node_agentapi,node_graph,node_research,node_internal toneAmber
class node_coding,node_repository,node_sandbox,node_composio,node_composio_state,node_composio_sessions,node_arcade toneMint
class node_approval,node_approval_ui,node_generative toneRose
class node_slackteams,node_web,node_appservices,node_github toneIndigo
```

## Components

### Channel Experience

- [Channel lifecycle](https://github.com/copilotkit/opentag/blob/main/app/channel.tsx): `app/channel.tsx`
- [Slash commands](https://github.com/copilotkit/opentag/blob/main/app/commands/index.ts): `app/commands/index.ts`
- [Node runtime](https://github.com/copilotkit/opentag/blob/main/app/runtime-host.ts): `app/runtime-host.ts`

### Agent Workflow

- [Agent API](https://github.com/copilotkit/opentag/blob/main/agent/main.py): `agent/main.py`
- [Knowledge agent](https://github.com/copilotkit/opentag/blob/main/agent/agent.py): `agent/agent.py`
- [Web research](https://github.com/copilotkit/opentag/blob/main/agent/prompts/web_search.py): `agent/prompts/web_search.py`
- [Internal sources](https://github.com/copilotkit/opentag/blob/main/agent/internal_sources.py): `agent/internal_sources.py`

### Connected Capabilities

- [Coding agent](https://github.com/copilotkit/opentag/blob/main/agent/coding/subagent.py): `agent/coding/subagent.py`
- [Repository tools](https://github.com/copilotkit/opentag/blob/main/agent/coding/repository_tools.py): `agent/coding/repository_tools.py`
- [Coding sandbox](https://github.com/copilotkit/opentag/blob/main/agent/coding/sandbox.py): `agent/coding/sandbox.py`
- [Composio tools](https://github.com/copilotkit/opentag/blob/main/agent/composio_tools/tools.py): `agent/composio_tools/tools.py`
- [Actor identity](https://github.com/copilotkit/opentag/blob/main/agent/composio_tools/state.py): `agent/composio_tools/state.py`
- [Composio sessions](https://github.com/copilotkit/opentag/blob/main/agent/composio_tools/sessions.py): `agent/composio_tools/sessions.py`
- [Arcade tools](https://github.com/copilotkit/opentag/blob/main/agent/arcade_tools/tools.py): `agent/arcade_tools/tools.py`

### Human Interaction

- [Write approval gate](https://github.com/copilotkit/opentag/blob/main/agent/write_confirmation.py): `agent/write_confirmation.py`
- [Approval UI](https://github.com/copilotkit/opentag/blob/main/app/human-in-the-loop/confirm-write.tsx): `app/human-in-the-loop/confirm-write.tsx`
- [Generative UI](https://github.com/copilotkit/opentag/blob/main/app/tools/block-catalog.tsx): `app/tools/block-catalog.tsx`

### Other components

- **Channel user**
- **Slack / Teams**
- **Web search provider**
- **Connected app services**
- **GitHub**

## Connections

- Channel user → Slack / Teams: messages in
- Slack / Teams → Channel lifecycle: delivers events
- Channel lifecycle → Node runtime: runs channel
- Channel user → Slash commands: invokes command (evidence: `app/commands/index.ts`)
- Slash commands → Node runtime: starts agent run (evidence: `app/commands/index.ts`)
- Node runtime → Agent API: forwards run
- Agent API → Knowledge agent: serves graph (evidence: `agent/main.py`)
- Knowledge agent → Web research: uses research tools (evidence: `agent/agent.py`)
- Web research → Web search provider: searches web
- Knowledge agent → Internal sources: uses source tools (evidence: `agent/agent.py`)
- Knowledge agent → Coding agent: delegates coding (evidence: `agent/agent.py`)
- Coding agent → Repository tools: uses repository tools (evidence: `agent/coding/repository_tools.py`)
- Repository tools → Coding sandbox: executes in (evidence: `agent/coding/repository_tools.py`)
- Knowledge agent → Composio tools: registers tools (evidence: `agent/agent.py`)
- Knowledge agent → Arcade tools: registers tools (evidence: `agent/agent.py`)
- Composio tools → Actor identity: reads actor (evidence: `agent/composio_tools/tools.py`)
- Composio tools → Composio sessions: uses sessions (evidence: `agent/composio_tools/sessions.py`)
- Composio tools → Connected app services: executes actions
- Arcade tools → Connected app services: executes actions
- Knowledge agent → Write approval gate: gates writes (evidence: `agent/write_confirmation.py`)
- Write approval gate → Approval UI: requests confirmation
- Approval UI → Knowledge agent: resumes run
- Knowledge agent → Generative UI: returns native UI
- Repository tools → GitHub: publishes changes (evidence: `agent/coding/repository_tools.py`)
