th-72288b: tool-hook seam on the Python server (polyglot parity) - #322
Merged
Conversation
The Rust server installs ToolHooks on each turn's registry via tools.add_hook(...) in runner.rs. This adds the equivalent seam to the Python server's TurnRunner, now that the Python engine has the ToolHook lifecycle. - turn_runner.py: TurnRunner gains a `tool_hooks: list[Any]` param; each turn threads them into AgentOptions(tool_hooks=...) so every hook's pre_call gates each tool (raise → block) and post_call may redact the result in place. Feature-detected against the PINNED published core (_CORE_SUPPORTS_HOOKS) — same release-ordering as the ceiling clamp: the core ships + publishes first, and the seam activates automatically once a core with tool_hooks is released. Empty hooks (the default) thread nothing → behavior unchanged on any core. - test_tool_hooks_seam.py: drives a real TurnRunner turn on MockLlmProvider with a scripted tool call — a spy+redact hook fires pre+post and its redaction reaches the model end-to-end (skipif on a pre-hooks core, mirroring test_starvation_defaults' ceiling test); plus the no-hooks default path. Verified both ways: pinned published core 1.3.2 → 156 passed, 1 skipped (feature-detect off, CI-equivalent); local core with tool_hooks → 157 passed (hook fires + redacts live). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01USBgWKcgpkWAugmHPE7Bc9
|
brentrager
enabled auto-merge (squash)
July 22, 2026 23:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Polyglot ToolHook seam parity.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ji3rA65cTfU9vPQh9HAASJ