Heterogeneous agent

From lobehub/lobehub · View interactive version

Heterogeneous agent is an AI agent skill from the GitHub repository lobehub/lobehub. Use for external-agent launchers and execution identity, Claude Code/Codex adapters, IPC, event mapping, sessions, persistence and tool-call chains.

How to use this skill

Skill file

Heterogeneous Agent Development

Use this skill when the bug or feature lives in the external CLI agent pipeline, not the normal server-side agent runtime.

Use This Skill For

Pipeline Map

  1. CLI raw stdout / JSONL
  2. Electron main spawns the CLI and broadcasts heteroAgentRawLine
  3. Adapter maps raw provider events into HeterogeneousAgentEvent
  4. executeHeterogeneousAgent persists assistant/tool messages and forwards stream events
  5. createGatewayEventHandler hydrates the UI
  6. Only after this path looks correct should you move on to agent-tracing or context-engine debugging

Read These Files First

Default Debug Order

  1. Prove whether the raw CLI output is correct before touching UI code. The app records every real session — read the most recent one via cat .heerogeneous-tracing/.last-live-trace rather than hand-rolling a claude -p repro (see references/debug-workflow\.md §2).
  2. If raw output is correct, compare it with adapter output. In dev, executeHeterogeneousAgent exposes window.__HETERO_AGENT_TRACE.
  3. If adapted events look correct, inspect persistToolBatch, persistToolResult, step transitions, and subagent routing.
  4. Turn the repro into a focused test before fixing.
  5. Only after the transport/adapter/executor path looks sound should you debug later-stage message processing.

Critical Invariants

Dispatched Run Identity

A connector or desktop process can itself run inside another Agent's conversation. Its inherited environment identifies the launcher, not the dispatched Agent.

Check all four launch surfaces when changing this contract or adding a launcher:

| Surface | Entry point |

| ----------------------- | -------------------------------------------------------------------------------------------------------------------- |

| CLI Agent dispatch | apps/cli/src/device/agentRun.ts — spawnHeteroAgentRun (Agent ID forwarded by apps/cli/src/commands/connect.ts) |

| CLI OpenClaw/Hermes | apps/cli/src/tools/heteroTask.ts — runHeteroTask |

| Desktop Agent dispatch | apps/desktop/src/main/controllers/HeterogeneousAgentImpl.ts — spawnLhHeteroExec |

| Desktop OpenClaw/Hermes | apps/desktop/src/main/controllers/GatewayConnectionCtr.ts — runHeteroTask |

Regression coverage must include a clean environment, conflicting ancestor identity, and missing current Agent/optional context. Check both OpenClaw and Hermes on CLI and Desktop, plus task comments after JWT fallback. Mocked spawn assertions verify environment construction, not end-to-end propagation through an external runtime.

Common Bug Patterns

check whether partial deltas and the later full assistant block are both being emitted.

check whether the adapter is cutting steps on every assistant event instead of only on message.id changes.

check whether type: 'user' tool_result blocks are being ignored because the code only inspects assistant events.

check whether synthesized pluginState.todos is being attached at tool-result time.

check parent_tool_use_id handling and whether subagent chunks are being forwarded to the main gateway handler.

first check whether the adapter emits a usable step boundary such as newStep or an equivalent turn-change signal.

first check step-transition ordering and whether persistToolBatch Phase 1 ran before tool message creation.

look for tool_result for unknown toolCallId and missing result_msg_id backfill.

check for subagent chunks reaching the main gateway handler.

a classifier is branching on a structured field whose mere presence isn't its meaning.

Grep the field across all event states in a real trace before trusting it — see

references/debug-workflow\.md §8 (CC rate_limit_info rides on status: "allowed" too).

References

user invocation of /testing-heterogeneous-agents in Claude Code or

$testing-heterogeneous-agents in Codex. Do not automatically load or run that

skill during diagnosis. Its failed-cell evidence can be used here for diagnosis

or a code fix.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.