feat: Return conversation ID in initial Codex mcp-server tool responses for session continuity #4745
MarjovanLier
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, when clients invoke the Codex tool via mcp-server, there is no structured way to capture the conversation ID from the initial response. This makes it difficult for clients to maintain conversation continuity when using the codex-reply tool for follow-up interactions.
I propose modifying codex_tool_runner.rs to add conversation ID tracking by introducing conversation_id and is_initial_call parameters to run_codex_tool_session_inner. The conversation ID would be returned in the structured_content field for initial calls only (not for replies), and would be applied consistently across all response paths, including success responses, error events, and general errors.
The implementation conditionally includes the conversation ID in the structured_content field of CallToolResult when is_initial_call is true. This maintains backwards compatibility whilst providing clients with the necessary information to continue sessions. The change enables proper conversation threading in MCP clients, facilitates multi-turn Codex interactions, and provides a consistent response structure across all code paths.
I have implemented this feature in a fork and can provide a pull request if this aligns with the project's roadmap. The implementation adds approximately 30 lines of code with minimal complexity.
Beta Was this translation helpful? Give feedback.
All reactions