Agent runtime abstraction layer — clean interface, orchestration UX, and end-to-end testing for Cursor/Windsurf/Codex
Summary
Define and own the AgentRuntime abstraction layer that makes Cursor, Windsurf, Codex, and any future IDE agent a pluggable runtime in the orchestration graph. Ensure CodeGhost21's Cursor and Windsurf wrappers confirm to this interface. Validate end-to-end that OpenHuman can see, route to, and log all three agents from a single orchestrator view. Keep an eye on further runtimes (Claude Code, OpenClaw/OpenCode, etc.) so the abstraction scales.
Step 1 — Define the AgentRuntime interface
Every IDE agent integration (Codex, Cursor, Windsurf, future) must implement one clean interface. Adding a new runtime later should require only: one adapter file + configuration — no rewrite of orchestration logic.
Proposed interface (align with CodeGhost21 before finalising):
interface AgentRuntime {
readonly id: string // e.g. "cursor", "windsurf", "codex"
readonly sessionId: string
// Lifecycle
start_session(opts?: SessionOptions): Promise<void>
shutdown(): Promise<void>
// Messaging
send_message(prompt: string, opts?: MessageOptions): Promise<void>
receive_events(): AsyncIterable<AgentEvent>
// Orchestration
get_status(): Promise<SessionStatus>
tag_session(label: string): Promise<void>
register_tools(tools: ToolManifest[]): Promise<void>
}
Requirements:
- Codex must be refactored to implement this interface if it doesn't already — so all three runtimes are truly equivalent.
- The session registry (#4418) stores
AgentRuntime-conformant records; the session ID maps to a tiny.place contact edge from theagent_orchestrationpairing store (PR #4400). - The interface must work whether the runtime is local (subprocess) or remote (IDE extension bridge).
Step 2 — Architecture review of Cursor + Windsurf wrappers
Review each wrapper for:
- Interface conformance — Does it fully implement
AgentRuntime? Are there any custom methods that should be pushed into the shared interface instead? - Event normalisation — Is
AgentEvent { session_id, seq, role, speaker, body, ts, kind }consistent between Codex, Cursor, and Windsurf? Seq must be monotonic per session; deduplication must be idempotent on(session_id, seq). - Transport consistency — All three runtimes should use the same
POST /orchestration/v1/eventspath (or socket) and the same durable queue on disconnect. - Thin wrapper rule — No brain/routing logic inside wrappers. Raise a review comment if any wrapper is making orchestration decisions locally.
- Pairing flow — Each runtime pairs via the
agent_orchestrationstore (PR #4400) before events flow. Verify this is wired consistently.
Step 3 — Future runtime coverage
Keep an eye on runtimes beyond the initial three. Ensure the abstraction scales to:
| Runtime | Status | Notes |
|---|---|---|
| Codex | Existing (reference) | Refactor to AgentRuntime interface |
| Cursor | CodeGhost21 implementing | |
| Windsurf | CodeGhost21implementing | |
| Claude Code | Future | claude_agent_sdk subprocess provider (PR #2746) already exists — adapter should be straightforward |
| OpenClaw / OpenCode | Future | Check interface requirements; should be config + one adapter file |
Document what a new runtime adapter needs to provide — this becomes the onboarding guide for adding future runtimes.
Step 4 — Orchestration UX
Validate and improve the Brain tab / orchestrator view so it correctly represents all three runtimes:
- [ ] Session list — Codex, Cursor, and Windsurf sessions appear as named nodes in the agent graph (Brain tab). Each shows: runtime type, status (idle / running / awaiting), last message preview.
- [ ] Task routing — From the orchestrator master chat, the user can say "send this to Cursor session 1" and it routes correctly via
cursor_send_message. - [ ] Message stream log — All agent messages (from all runtimes) appear in a unified orchestration timeline, tagged by
session_idandruntime. - [ ] Session lifecycle controls — Start, tag, inspect, and terminate any runtime session from the orchestrator UI.
- [ ] Multi-agent coordination — The UI can display a flow where Codex + Cursor + Windsurf work in parallel on sub-tasks routed from the orchestrator.
Step 5 — End-to-end testing
Own the E2E validation across all three runtimes:
Orchestration tests
- [ ] From OpenHuman, spawn a Cursor session → send a prompt → receive a reply → verify it appears in the orchestration timeline.
- [ ] Repeat for Windsurf.
- [ ] Route the same task to Codex, Cursor, and Windsurf simultaneously — verify all three respond and their streams are correctly attributed.
- [ ] Disconnect one runtime mid-task — verify the orchestrator detects the loss, retries or reroutes, and does not drop events.
Runtime consistency tests
- [ ] All three runtimes produce
AgentEventpayloads with identical schema. - [ ]
(session_id, seq)deduplication works across reconnects for all three. - [ ] Error states (runtime crash, network loss, tool timeout) are logged consistently across all three — no silent failures.
Staging demo
- [ ] End-to-end demo on staging: OpenHuman orchestrator coordinates Codex + Cursor + Windsurf on a real coding task. All sessions visible, all message streams logged and linked to the orchestration timeline.
Acceptance criteria
- [ ]
AgentRuntimeinterface defined — Clean, documented interface that Codex, Cursor, and Windsurf all implement. Adding a new runtime = one adapter file + config. - [ ] Codex refactored — Existing Codex integration conforms to the new interface (no special-casing).
- [ ] Architecture review signed off — Cursor and Windsurf wrappers reviewed for interface conformance, event normalisation consistency, thin-wrapper rule, and pairing flow.
- [ ] Orchestration UX complete — Brain tab shows all three runtimes as graph nodes; task routing, message stream log, and session controls all work.
- [ ] E2E tests passing — All runtime consistency + orchestration tests green on staging.
- [ ] Multi-agent demo — Staging demo of Codex + Cursor + Windsurf coordinated from one OpenHuman orchestrator session.
- [ ] Future runtime doc — Short doc (or README section) explaining what a new runtime adapter needs to implement.
- [ ] Diff coverage ≥ 80%.
Related
- Cursor/Windsurf wrapper implementation*(see companion)*
- Codex pairing foundation (the reference pattern): PR #4400
- Multi-agent session registry + orchestrator routing: #4418
- Backend orchestration migration (wrappers must stay thin): #4729
- Claude Agent SDK provider (future Claude Code runtime): PR #2746
Implementation Plan
Triage Assessment
- The issue proposes a formal
AgentRuntimetrait/interface for pluggable IDE-agent integration into the orchestration graph. - No such abstraction exists today. The existing Codex integration lives in
src/openhuman/agent_orchestration/andsrc/openhuman/agent/harness/, wired directly without a shared runtime trait. - User impact: enables OpenHuman to coordinate Cursor, Windsurf, Codex (and future Claude Code, OpenClaw, etc.) from a single orchestrator view — a core product capability.
- Maintainer oxoxDev confirmed scope with sub-issue slices (#4828, #4829).
Proposed Scope
- In-scope:
- Define a Rust
AgentRuntimetrait insrc/openhuman/agent_orchestration/runtime.rswith lifecycle (start/stop), messaging (send/receive events), and orchestration (status, tag, tools) methods. - Refactor existing Codex integration (
src/openhuman/agent_orchestration/pairing.rs,subagent_events.rs) to implement the trait. - Define the shared
AgentEventschema (session_id, seq, role, speaker, body, ts, kind) and enforce it across all three runtimes. - Wire the session registry (
src/openhuman/agent_orchestration/running_subagents.rs) to storeAgentRuntime-conformant records. - Update the Brain tab UI (
app/src/pages/brain/) to show all runtime sessions as graph nodes with status and last-message preview. - Add task routing from orchestrator chat to specific runtime sessions via
cursor_send_message/windsurf_send_message/ codex. - Implement E2E tests via
scripts/test-rust-with-mock.shcovering happy-path lifecycle, concurrent routing, and disconnect recovery.
- Define a Rust
- Explicit non-goals:
- Not implementing the Cursor/Windsurf wrappers themselves (handled by CodeGhost21).
- Not doing Claude Code / OpenClaw / OpenCode adapters (future work).
- Not changing the orchestration internal dispatch beyond the trait boundary.
Implementation Steps
src/openhuman/agent_orchestration/runtime.rs— Define theAgentRuntimetrait withasync fnmethods forstart_session,shutdown,send_message,receive_events,get_status,tag_session,register_tools. UseAsyncIterableor a channel-basedReceiver<AgentEvent>for the event stream.src/openhuman/agent_orchestration/mod.rs— Addpub mod runtime;and re-export the trait andAgentEventschema type.- Codex adapter — Create
src/openhuman/agent_orchestration/adapters/codex.rsimplementingAgentRuntimeby wrapping the existing pairing store (pairing.rs) and event handling (subagent_events.rs). ThesessionIdmaps to the tiny.place contact edge from PR #4400. - Event schema — Define
AgentEvent { session_id, seq: u64, role, speaker, body, ts, kind }insrc/openhuman/agent_orchestration/runtime.rs. Enforce monotonicseqper session and idempotent deduplication on(session_id, seq). - Session registry update — In
src/openhuman/agent_orchestration/running_subagents.rs, storedyn AgentRuntime + Send + Syncalongside existing session records so the orchestrator can enumerate and dispatch to all run sessions. - Orchestrator tool wiring — Add runtime-registration tools (
register_runtime,list_runtimes) insrc/openhuman/agent_orchestration/tools.rsso the orchestrator agent can discover and route to runtimes dynamically. - UI: Brain tab — Update
app/src/pages/brain/components to fetch runtime sessions from a newbrain.list_runtimesRPC and render each as a graph node with type icon (Cursor/Windsurf/Codex), status badge, last-message preview. - UI: Task routing — Add a
brain.send_to_runtimeRPC method that accepts{session_id, message}and dispatches throughAgentRuntime::send_message. Wire from the orchestrator master chat UI. - E2E tests — Extend
tests/json_rpc_e2e.rswith test cases for: spawn→send→receive lifecycle, concurrent routing to two runtimes, and mid-task disconnect recovery. Run viabash scripts/test-rust-with-mock.sh --test json_rpc_e2e. - Documentation — Add
docs/agent-runtime-adapter-guide.mdexplaining the trait, required methods, and the one-adapter-file + config pattern for adding a new runtime.
Verification
cargo test --lib openhuman::agent_orchestration::runtime::tests— unit tests for trait methods, event schema, deduplication.bash scripts/test-rust-with-mock.sh --test json_rpc_e2e— E2E orchestration tests.pnpm test:rust— full Rust test suite (must be green).- Vitest tests for new/modified UI components in
app/src/pages/brain/. - Manual verification against the existing Codex integration before adding other runtimes.
Risks and Open Questions
- The Cursor/Windsurf wrappers are being implemented by CodeGhost21 separately; the trait definition must be stabilized before those wrappers land, or the wrappers will need retrofitting.
- What is the exact
SessionOptions/MessageOptionspayload shape? Needs agreement with the wrapper implementations. - Should
receive_eventsuse a tokiompsc::Receiveror a polling-basedasync fn poll_event()? Channel is simpler for in-process; polling is needed if the runtime is remote. register_toolsimplies a tool registry cross-wiring — this needs alignment with the existingagent_registryandtoolsdomains.
Acceptance Criteria
AgentRuntimetrait is defined and documented insrc/openhuman/agent_orchestration/runtime.rs, with Codex as the reference implementation.- All three target runtimes (Codex, Cursor, Windsurf) implement the trait (wrappers landed by CodeGhost21).
- Brain tab shows all runtime sessions as graph nodes with status, message preview, and lifecycle controls.
- E2E test covers spawn→send→receive for at least one runtime.
- Diff coverage >= 80%.
Two further-runtime slices scoped + filed under this epic (both clean-room, reference-pattern only; harness plumbing lands in the vendored tiny.place SDK first, then a vendor/tinyplace submodule bump):
- Model + thinking/effort-level selection — tracking #4828 · impl tinyhumansai/tiny.place#254
- Shared ACP transport (hermes/kimi/kiro/qoder/trae — 5 agents, one JSON-RPC-over-stdio client) — tracking #4829 · impl tinyhumansai/tiny.place#255
Sequenced model-selection → ACP (ACP's session/set_model consumes the per-task model field the first slice adds). Complements the cursor/windsurf recognition slice (#4775) and the headless coding-agent daemon already merged in tiny.place (medulla-tinyplace/1).
Status check — the OpenHuman-side surface of this epic no longer exists in the repository
Verified on main (6be58a9ab). Flagging because two tracking issues under this epic (#4828, #4829) are in the same position, and anyone picking up the epic will hit this immediately.
TinyPlace was removed from core and app on 2026-08-30 — commit a54c4e7d5, "refactor: remove TinyPlace from core and app", which drops the .gitmodules entry along with the orchestration UI (HarnessGlyph.tsx, InstanceCard.tsx, AttentionQueue*.tsx, the AppRoutes.tsx wiring). Separately, src/openhuman/orchestration/ was retired earlier in e5c6507cc (2026-07-09) — "refactor(orchestration): hosted-only brain — retire the client local orchestration engine (Phase 4) (#4738)".
Against the epic's three steps:
| epic element | status on main |
|---|---|
AgentRuntime interface |
absent — no such type anywhere |
| Cursor / Windsurf / Codex wrappers | absent — grep -rIln "windsurf|Windsurf" over src/ and app/src/ finds only an unrelated MCP protocol test |
POST /orchestration/v1/events transport |
absent |
| Session registry (#4418) / pairing store (PR #4400) | not present in this tree |
vendor/tinyplace submodule |
not in .gitmodules (15 submodules remain, none of them tinyplace) |
One disambiguation, because a grep will mislead: agent_orchestration still appears throughout src/openhuman/agent/orchestration/ (ops.rs, delegation.rs, background_delivery.rs, run_ledger_finalize.rs). That is sub-agent orchestration — spawning, delegating to and reaping this app's own child agents. It is a different subsystem from the IDE-agent runtime layer this epic is about, and it is alive and well. Do not mistake it for surviving epic surface.
What this epic needs
A decision on whether TinyPlace returns to OpenHuman. Until that is answered, none of the three steps can be attempted here:
- If yes — the epic needs a Step 0 ("re-introduce the TinyPlace submodule and orchestration surface"), and #4828/#4829 re-sequence behind it.
- If no — the epic's title promise ("orchestration UX … for Cursor/Windsurf/Codex") is no longer deliverable in this repo, and it should be re-scoped to the SDK. The two tracking issues under it would close, and the live work would be tinyhumansai/tiny.place#254 and #255, which remain open and unaffected.
Worth noting the sub-issues are further along than this epic implies: both #4828 and #4829 have complete, well-specified acceptance criteria — they are blocked on the missing submodule rather than on design.
Leaving open; this is a maintainer call, not something to resolve by editing code. Same comment posted on #4828 and #4829 so the blocker is visible from whichever one someone opens first.
Triage: needs opinion — “Agent runtime abstraction layer — clean interface, orchestration UX, and end-to-end testing for Cursor/Windsurf/Codex” needs a maintainer decision on product scope/priority or fresh reproduction evidence before its status can be settled. Please advise whether to pursue, narrow, or close it.
Thanks for this. The OpenHuman side of the agent runtime abstraction epic no longer exists: TinyPlace and the coding-agent orchestration surface were removed from the app and core in #5847 (2026-08-30). If this work continues, it belongs in the tiny.place project rather than here, so we're closing this issue in this repository. (docs/gitbooks/en/overview/roadmap.md still lists this epic and can be updated.)