Skip to content

[Bug] Kiro requests fail with DataCloneError when Advisor is enabled (structuredClone(parsed)) #7974

Closed

Description

@igomq

Client or integration

Codex App (OpenCodex route; log shows wireClient: "ide").

Provider or upstream service

Kiro / claude-opus-5.5 (region: us-east-1).

OpenCodex version

2.94.0 (confirmed)

Operating system

  • OS: Oracle Linux Server release 9.7
  • Architecture: aarch64 (ARM64)

Environment

  • OpenCodex: 2.94.0
  • OS: Oracle Linux Server release 9.7 (aarch64)
  • Client: Codex App (wireClient: ide)
  • Provider/model: Kiro / claude-opus-5.5 (us-east-1)

Summary

With Advisor enabled, requests routed to Kiro fail immediately with invalid_request_error: The object can not be cloned. This happens even with a simple Hi prompt.

Disabling Advisor fixes the issue immediately with the same Kiro route/model. This appears to be an OpenCodex request-snapshot/Advisor interoperability bug, not a Kiro model or account error.

Steps to reproduce

  1. Configure an OpenCodex route using Kiro and claude-opus-5.5.
  2. Enable Advisor.
  3. Start a new Codex App session and send a simple prompt, e.g. Hi.
  4. Observe the clone error.
  5. Run ocx advisor off (and restart OpenCodex if necessary), then retry the same Kiro route.
  6. The request now succeeds.

Actual behavior

The client displays:

{
  "error": {
    "message": "The object can not be cloned.",
    "type": "invalid_request_error",
    "code": "invalid_request_error"
  }
}

The corresponding request diagnostic is:

[ocx:kiro:request] {"region":"us-east-1","requestedModel":"claude-opus-5.5","completionMode":"required","bodyBytes":112753,"messageCount":7,"toolCount":6,"hasProfileArn":true,"wireClient":"ide","hasPreviousResponseId":false}

Expected behavior

Kiro requests should complete normally when Advisor is enabled, or the adapter should handle Advisor-specific, non-cloneable request metadata without failing the entire request.

Likely root cause

The Kiro adapter snapshots the entire parsed request in buildRequest:

https://github.com/lidge-jun/opencodex/blob/main/src/adapters/kiro/adapter.ts

requestSnapshot = structuredClone(parsed);

Advisor attaches a function to that same request object:

https://github.com/lidge-jun/opencodex/blob/main/src/advisor/runtime.ts

attachGuard: parsed => {
  parsed._advisorGuard = createAdvisorGuard(plan);
},

The _advisorGuard field is declared as a function in src/types/request.ts. Functions are not structured-cloneable. Thus, when the guard is attached before the Kiro adapter's snapshot, structuredClone(parsed) can throw a DataCloneError.

This matches both the exact error and the observed Advisor ON/OFF behavior. The precise exception stack has not yet been captured, so this is a strong source-backed hypothesis, not a runtime-confirmed stack trace.

Suggested fix / regression coverage

  • Snapshot only the serializable fields needed by Kiro's fallback/rebuild path, or explicitly omit non-cloneable runtime-only fields like _advisorGuard while preserving any required runtime behavior.
  • Add a Kiro adapter regression test where an Advisor-like function guard is attached to OcxParsedRequest, and verify buildRequest does not throw.

Workaround

ocx advisor off

After disabling Advisor, claude-opus-5.5 through Kiro works again.

Activity

  1. added
    bugSomething isn't working
    providerProvider adapters, OpenAI-compat presets, upstream API quirks
    on Oct 30, 2026
  2. github-actions commented on Oct 30, 2026

    @github-actions
    Contributor

    Issue reopened

    The report now contains the information required by the automated check. Thanks for updating it.

  3. lidge-jun commented on Oct 30, 2026

    @lidge-jun
    Owner

    Fixed on dev by #7981 (squash merge 4fc8700): the Kiro retry snapshot now excludes top-level runtime callbacks such as the Advisor guard, so Advisor-enabled Kiro requests no longer fail with DataCloneError, and the original request keeps its guard for delivery. It will ship in the next release.

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

    bugSomething isn't workingproviderProvider adapters, OpenAI-compat presets, upstream API quirks

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions