mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Add session and originating window IDs to MCP request metadata (#45409)
## What changed Include `sessionId` and the originating `windowId` alongside `threadId` and optional `itemId` in MCP request metadata. Retain the originating item and window for code-mode cells across waits and compaction, including the window when no matching history item is found. ## Testing Extend metadata assertions for direct and nested MCP calls. Add a regression test verifying that a code-mode cell retains its original item and window IDs when it resumes after compaction. GitOrigin-RevId: 5e3cf761f2bed4c16565334c94654496367325fd
This commit is contained in:
1 parent
d77ebc7223
commit
d761097734
11 files changed
+228
-40
No files matched your search
@@ -70,18 +70,28 @@ pub struct ToolInvocation {
|
||||
pub payload: ToolPayload,
|
||||
}
|
||||
|
||||
/// Identity of the model call that started a tool invocation, retained across code-mode waits.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct ToolCallOrigin {
|
||||
/// Best-effort lookup: invocations without a matching history item still
|
||||
/// retain their known window ID.
|
||||
pub(crate) item_id: Option<ResponseItemId>,
|
||||
pub(crate) window_id: String,
|
||||
}
|
||||
|
||||
impl ToolInvocation {
|
||||
/// Returns the Responses item that requested this call or started its code-mode cell.
|
||||
pub(crate) async fn originating_item_id(&self) -> Option<ResponseItemId> {
|
||||
/// Returns the item and window that requested this call or started its code-mode cell.
|
||||
pub(crate) async fn originating_call(&self) -> Option<ToolCallOrigin> {
|
||||
if let ToolCallSource::CodeMode { cell_id, .. } = &self.source {
|
||||
return self
|
||||
.session
|
||||
.services
|
||||
.code_mode_service
|
||||
.cell_originating_item_id(&codex_code_mode::CellId::new(cell_id.clone()));
|
||||
.cell_originating_call(&codex_code_mode::CellId::new(cell_id.clone()));
|
||||
}
|
||||
|
||||
self.session
|
||||
let item_id = self
|
||||
.session
|
||||
.clone_history()
|
||||
.await
|
||||
.raw_items()
|
||||
@@ -94,7 +104,11 @@ impl ToolInvocation {
|
||||
id.clone()
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
});
|
||||
Some(ToolCallOrigin {
|
||||
item_id,
|
||||
window_id: self.session.current_window_id().await,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user