Skip to content

Harness tools with needsApproval run without approval through the sandbox tool bridge #1854

Closed

Description

@tombeckenham

TanStack AI version

main and t3/prepare-v1-release (1.0.0). @tanstack/ai-sandbox.

Framework/Library version

Any. Server side, with a harness adapter (@tanstack/ai-claude-code, -codex, -opencode, -grok-build, -acp).

Describe the bug and the steps to reproduce it

A tool marked needsApproval: true runs with no approval when a harness adapter calls it through the sandbox tool bridge.

createToolBridgeCore().callTool (packages/ai-sandbox/src/tool-bridge.ts, about line 162) looks up the tool and calls tool.execute() directly. It never reads needsApproval. The harness adapters bridge every chat() tool (packages/ai-claude-code/src/adapters/text.ts, toolsForChoice, about line 155).

Steps:

  1. Define a server tool with needsApproval: true and an execute() that logs.
  2. Pass it to chat({ adapter: claudeCodeText(...), tools: [tool], middleware: [withSandbox(sandbox)] }).
  3. Ask the agent to call the tool.
  4. The log line prints. No tool-approval interrupt is raised.

Expected: the run pauses with a tool-approval interrupt, as it does for a normal chat() adapter. Or the bridge refuses tools with needsApproval with a clear error.

Found in the full review of #1840. docs/structured-outputs/harnesses.md now describes the current behavior.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

See the steps above. The bypass is visible in callTool in packages/ai-sandbox/src/tool-bridge.ts.

Do you intend to try to help solve this bug with your own PR?

Yes, I am also opening a PR that solves the problem this issue identifies.

Activity

  1. added
    bug
    on Oct 22, 2026
  2. added a commit that references this issue on Oct 22, 2026
    410b966
  3. added a commit that references this issue on Oct 22, 2026
    8fa5927
  4. added a commit that references this issue on Oct 22, 2026
    f1b3f65
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions