File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use codex_core::protocol::Event;
99use codex_core:: protocol:: EventMsg ;
1010use codex_core:: protocol:: InputItem ;
1111use codex_core:: protocol:: Op ;
12+ use codex_core:: protocol:: Submission ;
1213use codex_core:: protocol:: TaskCompleteEvent ;
1314use mcp_types:: CallToolResult ;
1415use mcp_types:: CallToolResultContent ;
@@ -66,14 +67,24 @@ pub async fn run_codex_tool_session(
6667 . send ( codex_event_to_notification ( & first_event) )
6768 . await ;
6869
69- if let Err ( e) = codex
70- . submit ( Op :: UserInput {
70+ // Use the original MCP request ID as the `sub_id` for the Codex submission so that
71+ // any events emitted for this tool-call can be correlated with the
72+ // originating `tools/call` request.
73+ let sub_id = match & id {
74+ RequestId :: String ( s) => s. clone ( ) ,
75+ RequestId :: Integer ( n) => n. to_string ( ) ,
76+ } ;
77+
78+ let submission = Submission {
79+ id : sub_id,
80+ op : Op :: UserInput {
7181 items : vec ! [ InputItem :: Text {
7282 text: initial_prompt. clone( ) ,
7383 } ] ,
74- } )
75- . await
76- {
84+ } ,
85+ } ;
86+
87+ if let Err ( e) = codex. submit_with_id ( submission) . await {
7788 tracing:: error!( "Failed to submit initial prompt: {e}" ) ;
7889 }
7990
You can’t perform that action at this time.
0 commit comments