Add synchronous ACP harness tool interception - #2372
Conversation
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds a substantial new feature: synchronous tool interception for multiple agent harnesses (Bash, Claude Code, Codex, Pi). It introduces new JavaScript hook files, new session state tracking with locking, new error handling paths, and significant changes to request interception logic. The scope and complexity warrant human review. You can add or adjust custom eligibility rules. Learn more. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4edcd30858
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
4edcd30 to
68941f5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68941f52ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
68941f5 to
e34d4e0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e34d4e0758
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
e34d4e0 to
df227d6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df227d6ee3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
df227d6 to
cccba87
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cccba87422
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
cccba87 to
4726f72
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4726f72bce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
4726f72 to
a6d70fd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6d70fd828
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a6d70fd to
38186a5
Compare
bfc6b6d to
90bb79a
Compare
90bb79a to
f251c8a
Compare
beaf9f6 to
e167ed4
Compare
💡 Codex ReviewFor a successful Bash command that writes to stderr, this sends only ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
be008d1 to
4050c7f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4050c7f1b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a04144d22
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
412a3f1 to
d22f55d
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
d22f55d to
f1dbb9a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cc17ea5. Configure here.

Overview
Add synchronous native tool interception to ACP-backed coding harnesses while retaining Bash as the built-in reference path. Task request policies can block proposed tools before execution and replace completed results before the harness advances to the next model turn.
Details
Note
High Risk
Changes authentication boundaries, synchronous tool gating, and trace commit ordering across multiple agent harnesses; mis-sequencing or credential exposure could block rollouts or leak secrets into model-controlled subprocesses.
Overview
Adds synchronous native tool interception so task request interceptors and stops run at real tool boundaries—before execution and before the harness advances to the next model turn—not only on model HTTP traffic.
The interception server now issues a separate
tool_secret(fourth slot capability) forPOST /tool, with serialized handling,fatal_errorfor non-retryable tool failures, and stricter sequencing inRolloutSession.handle_tool(assistant-node keyed state, before/after phases, allow/rewrite/stop).Harness wiring:
tool_interceptionis a(url, secret)tuple passed through sessions. Bash delivers the tool bearer viarun_with_inputon stdin instead of argv/env. Pi installstool_hook.mjswith one-shot credential files. Claude Code and Codex addwrapper.mjs/tool_hook.mjsbridges; ACPLiveACPClientroutes permission requests to/tool.require_terminal_tool_statusfails ACP runs that end with unfinished tool calls.Rollouts enable the path only when the harness advertises
SUPPORTS_TOOL_INTERCEPTIONand request policies exist; after each turn they verify terminal tool calls were observed. Node is bumped to 22.21 for env-proxy support.Reviewed by Cursor Bugbot for commit d22f55d. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add synchronous ACP harness tool interception
SUPPORTS_PRE_TOOL_INTERCEPTIONandSUPPORTS_POST_TOOL_INTERCEPTIONflags to harnesses, replacing the single interception capability flag.configure_tool_interceptionfor Codex, Pi, Claude Code, and Bash harnesses, installing hooks or wrappers that route tool calls and results to an external policy endpoint.RolloutSessionin session.py to track native tool approvals per tool call, enforce pre/post sequencing invariants, and surface unrecoverable errors viafatal_error./toolendpoint andtool_secretprovisioning toInterceptionServerin server.py, and arun_with_inputmethod toRuntimein base.py to securely pass secrets via stdin.Slotin base.py expands from a 3-tuple to a 4-tuple to includetool_secret; Node.js requirement bumped to 22.21.0 in node.py.Macroscope summarized 3325ab5.