mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Bind direct tool-call metadata to invocation outputs (#45185)
## Why Direct tool-call records need to stay associated with the invocation that produced each output, including when call IDs are reused. Completeness must describe the recorded call inventory, independently of tool success. ## What changed - Attach direct-call records to outputs before they enter history, and set `tool_calls_complete` when the invocation's arguments are fully recorded. - Bound pending recordings and retained metadata, release reservations on completion or cancellation, and invalidate pending records when capture is disabled. - Apply request budgets to direct metadata and strip it from inference and compaction inputs when capture is disabled. - Remove executed-call metadata from app-server raw response notifications and exclude its size from Guardian history retention budgets. - Track call IDs that bypass dispatch so their reuse cannot incorrectly establish Code Mode completeness. ## Testing Add regression coverage for direct-call attribution, malformed calls, metadata budgets, cancellation, configuration changes, compaction, notification filtering, and Guardian context isolation. GitOrigin-RevId: 2ebd39c7f141d04788736491495109841656b4c0
This commit is contained in:
1 parent
e61f381900
commit
1715e55076
24 files changed
+1760
-297
No files matched your search
@@ -748,7 +748,14 @@ mod tests {
|
||||
})
|
||||
);
|
||||
|
||||
// Reuse the direct invocation to catch recording placed after the Code Mode-only return.
|
||||
// Nested MCP result metadata still reaches the owning Code Mode cell.
|
||||
let cell_id = codex_code_mode::CellId::new("mcp-cell".to_string());
|
||||
recorder.start_cell(&cell_id, "exec-mcp-post");
|
||||
let mut invocation = invocation;
|
||||
invocation.source = ToolCallSource::CodeMode {
|
||||
cell_id: cell_id.as_str().to_string(),
|
||||
runtime_tool_call_id: "mcp-runtime-call".to_string(),
|
||||
};
|
||||
let mut output = output;
|
||||
output.result.meta = Some(json!({ "provider/custom": { "items": [1, null] } }));
|
||||
output.result_metadata_capture_allowed = true;
|
||||
@@ -763,9 +770,10 @@ mod tests {
|
||||
&invocation.step_context,
|
||||
);
|
||||
handler.on_tool_result_accepted(&invocation, &output);
|
||||
let mut items = [codex_protocol::models::ResponseItem::from(
|
||||
output.to_response_item(&invocation.call_id, &invocation.payload),
|
||||
)];
|
||||
let mut items = [serde_json::from_value(json!({
|
||||
"type": "custom_tool_call_output", "call_id": "exec-mcp-post", "output": "notes",
|
||||
}))
|
||||
.expect("Code Mode output")];
|
||||
recorder.attach_to_prompt(&mut items, &mut Default::default());
|
||||
assert_eq!(
|
||||
serde_json::to_value(items[0].executed_tool_call_metadata()).unwrap()["executed_tool_calls"],
|
||||
|
||||
Reference in new issue
Block a user