Encapsulate executed tool call metadata recording (#44002)

## What changed

Introduce `ExecutedToolCalls` to own optional shared recorder state and centralize feature checks, call recording, and accepted result source lookup. Update session, tool runtime, MCP, and Code Mode callers to use this interface.

Move prompt attachment, retry handling, and metadata budgeting into the `request_metadata` module, preserving existing recording and request behavior.

## Testing

Add coverage for all session and turn feature combinations, lazy result source lookup, and unchanged prompts when recording is disabled. Retain the existing metadata budget and cell completeness tests in the new module.

GitOrigin-RevId: bc19f34317232b6599c7ec71c15db4a80123ff6f
This commit is contained in:
ningyi-oai authored and copyberry committed 2026-09-09 02:33:17 +00:00
1 parent b831057106
commit 0d46c252b3
16 files changed
+450 -299

No files matched your search

+5 -6
View File
@@ -284,12 +284,11 @@ impl CoreToolRuntime for McpHandler {
}
fn on_tool_result_accepted(&self, invocation: &ToolInvocation, result: &dyn ToolOutput) {
// Direct calls also record sources, before the Code Mode-only evidence path below.
if let Some(recorder) = invocation.session.services.executed_tool_calls.as_ref()
&& let Some(sources) = result.tool_result_sources()
{
recorder.record_tool_result_sources(&invocation.source, &invocation.call_id, sources);
}
invocation
.session
.services
.executed_tool_calls
.record_accepted_result(&invocation.source, &invocation.call_id, result);
let ToolCallSource::CodeMode { cell_id, .. } = &invocation.source else {
return;
};