Track Code Mode tool call metadata completeness (#41058)

## Why

Executed-tool metadata for a Code Mode cell can span its `exec` and `wait`
outputs. Consumers need to know whether that metadata contains the cell's full
tool call inventory or only a partial record.

## What changed

- Associate recorded tool calls with the originating Code Mode cell across
  `exec` and `wait` outputs.
- Add a host-owned `tool_calls_complete` marker when recording finishes without
  dropped or truncated calls. The marker describes inventory completeness, not
  tool success.
- Preserve the cell metadata through replay and pruning, and clear the
  completeness marker when prompt budgeting makes the record incomplete.

## Testing

Add coverage for multi-wait cells, retries, interruptions, recording limits,
argument truncation, prompt budgeting, and rejection of input-forged metadata.

GitOrigin-RevId: 377014edec06aab42aadab78b8b5dccc0a1c83ba
This commit is contained in:
ningyi-oai authored and copyberry committed 2026-08-27 06:03:29 +00:00
1 parent f1433fc71f
commit d5caceccb1
12 files changed
+808 -93

No files matched your search

+2 -1
View File
@@ -1428,10 +1428,11 @@ impl Session {
session_configuration.parent_thread_id,
),
),
executed_tool_calls,
executed_tool_calls: executed_tool_calls.clone(),
code_mode_service: crate::tools::code_mode::CodeModeService::new(
Arc::clone(&code_mode_session_provider),
&config.code_mode,
executed_tool_calls,
),
tool_search_handler_cache: Default::default(),
turn_environments: Arc::clone(&turn_environments),
+4 -2
View File
@@ -6336,10 +6336,11 @@ pub(crate) async fn make_session_and_context() -> (Session, TurnContext) {
/*attestation_provider*/ None,
config.http_client_factory(),
),
executed_tool_calls,
executed_tool_calls: executed_tool_calls.clone(),
code_mode_service: crate::tools::code_mode::CodeModeService::new(
Arc::new(codex_code_mode::DisabledCodeModeSessionProvider),
&config.code_mode,
executed_tool_calls,
),
tool_search_handler_cache: Default::default(),
turn_environments: Arc::clone(&turn_environments),
@@ -8614,10 +8615,11 @@ where
/*attestation_provider*/ None,
config.http_client_factory(),
),
executed_tool_calls,
executed_tool_calls: executed_tool_calls.clone(),
code_mode_service: crate::tools::code_mode::CodeModeService::new(
Arc::new(codex_code_mode::DisabledCodeModeSessionProvider),
&config.code_mode,
executed_tool_calls,
),
tool_search_handler_cache: Default::default(),
turn_environments: Arc::clone(&turn_environments),