Skip to content

fix(hook): preserve tool_input fields when rewriting commands - #6

Open
medicm wants to merge 1 commit into
pivanov:mainfrom
medicm:fix/hook-preserve-tool-input
Open

medicm wants to merge 1 commit into
pivanov:mainfrom
medicm:fix/hook-preserve-tool-input

Conversation

@medicm

@medicm medicm commented Oct 2, 2026

Copy link
Copy Markdown

Fixed

  • Every hook adapter (claude, codex, copilot VS Code, cursor, gemini) emitted a command-only updatedInput, and hosts like Claude Code replace the tool input with it instead of merging — so a rewritten Bash call lost run_in_background, timeout, description and dangerouslyDisableSandbox. In practice every background launch ran in the foreground (auto-backgrounded at 120s, killed at the 30min cap).

Added

  • toolInputWithCommand helper: builds updatedInput from the ORIGINAL tool_input object with only command replaced; every other key survives byte-for-byte with its JSON type, including unknown future keys.
  • Table-driven tests for run_in_background/timeout/description/dangerouslyDisableSandbox/unknown-key preservation and the no-rewrite passthrough (claude), plus preservation tests for codex, copilot VS Code, cursor and gemini.

Removed

  • The command-only claudeUpdatedInput/codexUpdatedInput/copilotUpdatedInput/cursorUpdatedInput/geminiUpdatedInput structs.

Verification: just check (fmt/vet/staticcheck/test/race/verify, 420 filter conformance tests) all pass; pipe test echo '{"tool_name":"Bash","tool_input":{"command":"... | tail -15","run_in_background":true,"timeout":5400000,"description":"d"}}' | ctx-wire hook claude now returns all fields in updatedInput.

Hosts replace the tool input with the hook's updatedInput rather than
merging it, and every adapter emitted a command-only object. For Claude
Bash that dropped run_in_background, timeout, description and
dangerouslyDisableSandbox: background launches silently ran in the
foreground (auto-backgrounded at 120s, killed at the 30min cap).

Rewrite updatedInput as the original tool_input with only the command
key replaced, so every other field survives byte-for-byte with its JSON
type, including unknown future keys. Applies to the claude, codex,
copilot (VS Code), cursor and gemini adapters; copilot CLI already
preserved args.
@vercel

vercel Bot commented Oct 2, 2026

Copy link
Copy Markdown

@medicm is attempting to deploy a commit to the Pavel Ivanov's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant