Skip to content

[Bug] acpx TypeError: Cannot use in operator to search for method in 1 #90404

Closed

Description

@VanadisGithub

Description

When calling sessions_spawn(runtime="acp", agentId="claude") to invoke Claude Code ACP, a TypeError occurs and the ACP session fails to execute properly.

Error

TypeError: Cannot use "in" operator to search for "method" in 1

Root Cause

  1. acpx runtime successfully created and registered
  2. TypeError occurs when processing ACP adapter messages
  3. Code expects { method: "...", params: {...} } format object
  4. Actually receives number 1 (likely ACK response or other non-object type)
  5. acpx does not properly handle this non-object type message

Environment

  • OpenClaw: 2026.6.1
  • Platform: macOS 14.1.2 (Darwin 23.1.0)
  • Node: v24.15.0
  • claude-agent-acp: 0.39.0
  • Claude CLI: 2.1.162
  • Gateway: local mode, WebSocket on 127.0.0.1:18789
  • Gateway service: LaunchAgent installed, loaded, running
  • Agents: 4 (main, xiaohong, hermes, claude)
  • Sessions: 90 active
  • Memory: enabled (plugin memory-core)

Steps to Reproduce

  1. Configure ACP agent (claude or hermes)
  2. Call sessions_spawn(runtime="acp", agentId="claude", task="...")
  3. Observe that the returned session has empty messages
  4. Check stability log and find TypeError

Stability Log Evidence

Unhandled rejection at runtime:
- acpx-runtime phases completed successfully
- TypeError: Cannot use "in" operator to search for "method" in 1
- Timestamp aligns with sessions_spawn calls

Suggested Fix

acpx should:

  1. Check if message is object type before using in operator
  2. Handle non-object type responses properly (e.g., ACK numbers)
  3. Add type guard before checking method field

Workaround

Use subagent mode instead of ACP mode: sessions_spawn(runtime="subagent", agentId="xiaohong", task="...")

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 7:37 AM ET / 11:37 UTC.

    Summary
    Keep open: current main and the latest release still expose the ACPX primitive-frame failure path, and #95130 is the active open candidate fix that uses closing syntax for this issue.

    Reproducibility: yes. Source inspection shows current main still lets primitive JSON stdout frames reach acpx, acpx enqueues them, and the pinned ACP SDK applies "method" in message before object narrowing; I did not run a live credentialed Claude ACP session.

    Root-cause cluster
    Relationship: canonical
    Canonical: #90404
    Summary: This issue is the canonical report for the ACPX primitive-frame TypeError; the active open PR is the current candidate fix and the older closed PR attempted the same root-cause area.

    Members:

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

    Next step
    An open linked PR already uses closing syntax and owns the candidate fix, so a new repair lane should not start.

    Review details

    Best possible solution:

    Review and land or revise #95130; if that PR is rejected, fix the object-shape validation at the acpx/ACP SDK boundary with regression coverage for primitive, null, string, array, request, response, and notification frames.

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

    Yes. Source inspection shows current main still lets primitive JSON stdout frames reach acpx, acpx enqueues them, and the pinned ACP SDK applies "method" in message before object narrowing; I did not run a live credentialed Claude ACP session.

    Is this the best way to solve the issue?

    Yes on direction, not yet on completion. The narrow maintainable end state is object-shape validation before ACP dispatch; the active question is whether maintainers accept the OpenClaw wrapper mitigation in #95130 or require the guard in acpx/ACP SDK.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The fix is not on current main or v2026.6.9; the open linked PR still needs maintainer review for wrapper-layer filtering versus moving the guard into acpx/ACP SDK.
    • I did not run a live credentialed Claude ACP session in this read-only review; the reproduction is source-level against the pinned dependency path.

    Codex review notes: model internal, reasoning high; reviewed against d1cbe29f3d52.

    Label changes

    Label changes:

    • remove clawsweeper:needs-maintainer-review: Current issue advisory state no longer selects this label.

    Label justifications:

    • P1: A released ACP sessions_spawn workflow can fail before delivering Claude ACP output for affected users.
    • impact:message-loss: The reported TypeError leaves the spawned ACP session with empty messages instead of returning runtime output.
    Evidence reviewed

    What I checked:

    • Repository policy applied: Root AGENTS.md plus extensions/AGENTS.md and extensions/acpx/AGENTS.md were read; the scoped ACPX guide treats reusable ACP runtime behavior as belonging in openclaw/acpx unless the wrapper change is OpenClaw-specific glue. (extensions/acpx/AGENTS.md:7, d1cbe29f3d52)
    • Current main wrapper path: Generated Claude ACP wrapper spawns the child with stdout inherited, so current main does not filter primitive stdout frames before the dependency reads them. (extensions/acpx/src/codex-auth-bridge.ts:434, d1cbe29f3d52)
    • Current main custom command gap: Custom Claude ACP commands return the configured command unchanged when not recognized as a package runner, leaving a bypass around the generated wrapper. (extensions/acpx/src/codex-auth-bridge.ts:728, d1cbe29f3d52)
    • sessions_spawn reaches ACP manager: The reported sessions_spawn ACP path initializes through getAcpSessionManager().initializeSession with the configured ACP backend. (src/agents/acp-spawn.ts:1089, d1cbe29f3d52)
    • ACPX service prepares wrapper config: The ACPX runtime service resolves plugin config and calls prepareAcpxCodexAuthConfig before constructing runtime behavior, placing the wrapper/dependency boundary on the live ACP backend path. (extensions/acpx/src/service.ts:357, d1cbe29f3d52)
    • Pinned dependency versions: Current main pins @agentclientprotocol/claude-agent-acp 0.39.0 and acpx 0.10.0; the lock also resolves @agentclientprotocol/sdk 0.22.1. (extensions/acpx/package.json:11, d1cbe29f3d52)

    Likely related people:

    • vincentkoc: Current blame points to Vincent Koc on the affected wrapper and service lines, and recent history includes ACPX runtime/package work. (role: recent area contributor; confidence: high; commits: c9758bf2a090, dfb44912ed28, 6774e7f25918; files: extensions/acpx/src/codex-auth-bridge.ts, extensions/acpx/src/service.ts, extensions/acpx/src/runtime.ts)
    • steipete: Recent GitHub history shows repeated ACPX wrapper, service, runtime, dependency, and documentation work in the affected paths. (role: wrapper and runtime feature contributor; confidence: high; commits: 44765cfabe1b, 05c3325b0acc, bac84c5858c5; files: extensions/acpx/src/codex-auth-bridge.ts, extensions/acpx/src/service.ts, extensions/acpx/src/runtime.ts)
    • osolmaz: Commit 154a7ed moved the ACPX extension to the upstream acpx runtime library, which is the boundary implicated by primitive stdout parsing. (role: runtime library boundary contributor; confidence: medium; commits: 154a7edb7cad; files: extensions/acpx/src/runtime.ts, extensions/acpx/package.json, extensions/acpx/AGENTS.md)
    • 91wan: Commit a35d259 added the Codex ACP config-isolation wrapper in the same generated-wrapper file that is now the likely OpenClaw-side mitigation surface. (role: introduced adjacent wrapper behavior; confidence: medium; commits: a35d259719cc; files: extensions/acpx/src/codex-auth-bridge.ts, extensions/acpx/src/codex-auth-bridge.test.ts)
    • leoge007: Commit 99a6b1c changed ACPX wrapper diagnostics and parent stream dispatch tests near the affected wrapper/runtime surface. (role: adjacent diagnostic contributor; confidence: medium; commits: 99a6b1c5a886; files: extensions/acpx/src/codex-auth-bridge.ts, extensions/acpx/src/runtime.ts, src/agents/acp-spawn.test.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jun 4, 2026
  3. YingzuoLiu commented on Jun 5, 2026

    @YingzuoLiu

    Adding one thought from a runtime/protocol-boundary angle.

    I agree with the earlier review that the clean fix may need to happen at the ACP SDK / acpx boundary rather than only catching the exception inside OpenClaw. The part that stands out to me is that this failure is not just a local TypeError: a primitive or malformed inbound message can escape shape validation and bring down the ACP dispatch path, leaving the spawned session with empty messages.

    A useful regression test might explicitly cover the dispatcher boundary with several message shapes:

    • a normal request-like { method: ... } message
    • a response-like { id: ... } message
    • a primitive payload such as 1
    • malformed payloads such as null, string, or array values

    The expected behavior would be that only valid protocol objects reach the method dispatcher. Primitive or malformed payloads should either be ignored if they are valid control/ACK messages for the protocol, or surfaced as structured protocol errors, rather than throwing from "method" in message.

  4. joelnishanth commented on Jun 16, 2026

    @joelnishanth
    Contributor

    Working on a fix for this. Will have a PR up shortly.

    — Joel Nishanth · offlyn.AI

  5. added
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jun 19, 2026
  6. vincentkoc commented on Jun 23, 2026

    @vincentkoc
    Member

    acpx now has the upstream parser fix in draft openclaw/acpx#403. The NDJSON boundary drops top-level primitives/null/arrays before the ACP SDK dispatcher, with regression coverage. OpenClaw PR #95130 remains useful as a mitigation for bundled older acpx versions, but the shared fix belongs upstream.

  7. vincentkoc commented on Jun 23, 2026

    @vincentkoc
    Member

    Update: the shared acpx parser fix is merged in openclaw/acpx#403 (de042d1, released on acpx main). OpenClaw still needs to bump its bundled acpx dependency; the wrapper mitigation in #95130 can then be reconsidered against the released upstream guard.

  8. vincentkoc commented on Jun 23, 2026

    @vincentkoc
    Member

    Resolved by the merged ACPX inbound-frame fix in openclaw/acpx#403 and consumed by OpenClaw in #96068. ACPX now ignores non-object frames before protocol inspection, so the in operator TypeError path is gone. Closing with the canonical fix.

  9. locked as resolved and limited conversation to collaborators on Jul 12, 2026
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

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions