Skip to content

th-72288b: tool-hook seam on the Python server (polyglot parity) - #322

Merged
brentrager merged 1 commit into
mainfrom
th-72288b-py-hookseam
Jul 22, 2026
Merged

th-72288b: tool-hook seam on the Python server (polyglot parity)#322
brentrager merged 1 commit into
mainfrom
th-72288b-py-hookseam

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Polyglot ToolHook seam parity.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ji3rA65cTfU9vPQh9HAASJ

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
@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8d6ea1f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@brentrager
brentrager enabled auto-merge (squash) July 22, 2026 23:01
@brentrager
brentrager merged commit ac270dd into main Jul 22, 2026
2 checks passed
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