Skip to content

Bound ACP harness without same-named configured agent bricks the chat #164609

Closed as not planned

Description

@jmar5439

Environment: OpenClaw 2026.9.7 (installed) / traced against 2026.9.8 sources, Linux, systemd user gateway, Telegram channel with multiple bot accounts (main, dev, ceo, …).

Error (gateway log, repeats per message, update stays pending forever):

[telegram] dispatch failed: Error: prepared reply dispatch runtime owner was not published for opencode
[telegram] spooled update 852364949 failed; keeping for retry: prepared reply dispatch runtime owner was not published for opencode

Repro:

  1. acp.allowedAgents includes opencode, but there is no opencode entry in agents.entries.
  2. On any Telegram DM: /acp spawn opencode --bind here (succeeds, ACP session is created).
  3. Send any message (Hi) → every turn fails with the error above. The spooled update never completes (retry storm). Even /acp close fails identically (failure happens before command parsing), so the chat cannot be recovered from the client. The bind had to be deleted manually from plugin_state_entries (plugin_id='telegram', namespace='telegram.thread-bindings').

Root cause:

  • src/channels/plugins/binding-routing.ts:197-219 — a bound conversation's route.agentId becomes the agent parsed from the bound session key (agent:opencode:acp:<uuid> → opencode).
  • src/agents/prepared-reply-dispatch-runtime.ts:115-151 — load({agentId}) throws PreparedModelRuntimeOwnerNotPublishedError when the id is absent from the publication, which only contains provenance === "configured" agents.
  • Net: binding a chat to a harness id with no same-named configured agent permanently poisons the conversation. codex bindings work only because a same-named agents.entries.codex happens to exist.

Why this looks like a bug: src/auto-reply/reply/dispatch-from-config.gather.ts:408-412 states the intent explicitly ("A bound ACP key names an external harness, not a configured model-runtime owner. Keep the source owner for Gateway dispatch..."), but the bound path still ends up demanding a configured owner named after the harness.

Complicating findings during triage (listed so nobody re-chases them):

  • The --bind here pin lives in the Telegram-native telegram.thread-bindings plugin-state store, not in current_conversation_bindings (which stays empty).
  • Stale agent:opencode:* conversation/session rows can linger in a deleted agent's sqlite (~/.openclaw/agents/opencode/agent/openclaw-agent.sqlite) and win ownership by recency — check per-agent DBs, not just the main state DB.
  • Adding a minimal agents.entries.opencode by hand is not a workaround: the gateway then refuses to start (Legacy workspace setup state requires migration for ~/.openclaw/workspace/opencode).

Expected: bound-harness turns fall back to the source route owner for Gateway dispatch (per the code comment above), or --bind to an owner-less harness id is rejected up front with a clear error instead of bricking the chat (and orphaning it from /acp close).

Suggested fix sketch: roster-guarded owner resolution — when the bound/ACP session key parses to an id absent from listAgentIds(cfg) (agents/agent-roster.ts), fall back to the source route session key's agent for the reply-dispatch load (dispatch-from-config.gather.ts ~:373-424 and the second load site at gateway/agent-turn/agent-run-admission-phase.ts:360). Unit-test the helper; regression-test route telegram:dev → developer + thread-binding to agent:opencode:acp:* with no opencode entry.

Activity

  1. added
    P1
    impact:message-loss
    on Oct 3, 2026
  2. clawsweeper commented on Oct 3, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

    This is a valid Telegram manifestation of the shared dispatch-owner defect already tracked at #146365. That open issue includes the same Matrix binding/recovery failure, and existing repair work explicitly covers Telegram; the bug remains unfixed on current main.

    Root-cause cluster
    Relationship: duplicate
    Canonical: #146365
    Summary: Telegram reproduces the same shared configured-owner versus ACP-harness mismatch already documented for Discord and Matrix.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Canonical path: Preserve the configured channel owner for Gateway dispatch while retaining ACP execution identity, and keep an authorized in-chat close or unbind recovery path available.

    So I’m closing this here and keeping the remaining discussion on #146365.

    Review details

    Best possible solution:

    Preserve the configured channel owner for Gateway dispatch while retaining ACP execution identity, and keep an authorized in-chat close or unbind recovery path available.

    Do we have a high-confidence way to reproduce the issue?

    Yes, from source: bind a configured Telegram route to an ACP harness absent from agents.entries, then send a follow-up; the rewritten harness ID reaches a configured-only runtime lookup. This review did not execute a current-main Telegram reproduction.

    Is this the best way to solve the issue?

    Yes—consolidating this shared failure under the existing canonical report avoids competing repairs; preserving the configured dispatch owner is narrower than adding dummy agents or renaming persisted ACP sessions.

    Security review:

    Security review: This report establishes a dispatch availability defect, with no demonstrated security-boundary violation.

    AGENTS.md: found and applied where relevant.

    What I checked:

    • Verified review revision and current-main delta: The clean checkout is main at 9b16ed0. GitHub confirms fetched main f42f774 has that exact parent and changes only portal tests and node-worker tunnel cleanup, leaving the inspected ACP routing and dispatch paths unchanged. (f42f774c8309)
    • Shared route rewrite: Runtime agent bindings replace both route.sessionKey and route.agentId with the bound target. Telegram invokes this shared resolver in conversation-route.ts and forwards the resulting route through its inbound-context builder. The route facts preserve fallbackAgentId, but the prepared-runtime lookup does not consume that fact. (src/channels/plugins/binding-routing.ts:209, 9b16ed050a69)
    • Failure before command execution: Gather resolves the purported source owner from sessionKey and ctx.AgentId, which already identify the bound harness on this path. resolveSessionAgentId prioritizes the parsed agent-scoped key. The published-runtime load occurs before later dispatch preparation and command execution. (src/auto-reply/reply/dispatch-from-config.gather.ts:410, 9b16ed050a69)
    • Configured-only publication: Reply dispatch publishes only configured runtime owners and throws the reported error when the requested harness ID has no matching publication. This failure occurs within OpenClaw before external harness I/O; no Codex dependency contract is needed to establish it. (src/agents/prepared-reply-dispatch-runtime.ts:143, 9b16ed050a69)
    • Documented existing contract: Current-conversation bindings route follow-up messages to the ACP session, while Gateway management commands remain local and /acp close removes the binding. Controls documentation separately distinguishes the OpenClaw session owner from the external harness. Public docs: docs/tools/acp-agents/bindings.md. (docs/tools/acp-agents/bindings.md:23, 9b16ed050a69)
    • Canonical report and corroborating discussion: [Bug]: Discord /acp spawn thread never dispatches: "prepared reply dispatch runtime owner was not published for claude" under agents.ownership explicit #146365 remains open and describes the identical route rewrite, configured-only publication, and dispatch error. Its Matrix comment independently reports persisted plugin_state_entries bindings, management commands producing no reply, and restart failing to recover the conversation. Telegram's transport-specific retry and storage observations add evidence to this shared defect rather than establishing a separate cause.

    Likely related people:

    • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    • jalehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

    Codex review notes: model internal, reasoning medium; reviewed against f42f774c8309.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1impact:message-loss

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions