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

+12
View File
@@ -937,11 +937,23 @@ pub struct InternalChatMessageMetadataPassthrough {
#[schemars(skip)]
#[ts(skip)]
pub content_item_kinds: Option<Vec<ContentItemKind>>,
// Ignore input values so requests cannot fake tool call records.
/// Host-owned Code Mode cell shared by its `exec` and subsequent `wait` outputs.
#[serde(default, skip_deserializing, skip_serializing_if = "Option::is_none")]
#[schemars(skip)]
#[ts(skip)]
pub cell_id: Option<String>,
/// Warehouse-only Responses metadata, not part of the public app-server protocol.
#[serde(default, skip_deserializing, skip_serializing_if = "Option::is_none")]
#[schemars(skip)]
#[ts(skip)]
pub executed_tool_calls: Option<Vec<ExecutedToolCall>>,
/// Whether the host finished recording this cell's calls without losing calls or arguments.
/// This describes the call inventory across the cell's outputs, not tool success.
#[serde(default, skip_deserializing, skip_serializing_if = "Option::is_none")]
#[schemars(skip)]
#[ts(skip)]
pub tool_calls_complete: Option<bool>,
}
impl InternalChatMessageMetadataPassthrough {