Run tool start callbacks after pre-tool hooks (#38568)

## What changed

- Invoke `ToolLifecycleContributor::on_tool_start` only after pre-tool hooks
  have finalized the invocation.
- Pass hook-rewritten arguments and the post-hook conversation snapshot to the
  callback.
- Skip the start callback when a hook denies execution or supplies input that
  cannot be applied.

## Testing

Add lifecycle tests covering rewritten input, hook-added context, denied tool
calls, and invalid rewritten input.

GitOrigin-RevId: 936efaf4a8c35321f9982ff2a33bb8bece1ebf39
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-08-14 12:21:08 +00:00
1 parent aa905bb962
commit d40dfcc3c7
4 files changed
+197 -8

No files matched your search

@@ -60,11 +60,11 @@ pub struct ToolStartInput<'a> {
pub call_id: &'a str,
/// Tool name as routed by the host.
pub tool_name: &'a ToolName,
/// Tool arguments before any pre-tool-use hook rewrites.
/// Finalized tool arguments, including any pre-tool-use hook rewrites.
///
/// Payloads can contain sensitive plaintext and must not be logged.
pub payload: &'a ToolPayload,
/// Shared read-only snapshot of the conversation when the tool started.
/// Shared read-only snapshot taken after pre-tool hooks have completed.
pub conversation_history: Arc<dyn ConversationHistorySnapshot>,
/// Source that issued the tool call.
pub source: ToolCallSource,