mirror of
https://github.com/openai/codex.git
synced 2026-11-24 07:20:27 +00:00
Preserve user input when MCP startup is interrupted (#34839)
## Why Interrupting a turn while MCP tools were still starting could abort before the submitted user input was recorded in conversation history. ## What changed - Build and retain the MCP tool list and tool router as part of each step snapshot, using the turn cancellation token during tool discovery. - Record turn hooks and submitted input when cancellation occurs during startup prewarming, pre-sampling compaction, or first-step capture. - Reuse the captured router for sampling, compaction, and prompt debugging so advertised and executable tools share the same request-scoped view. ## Testing Add coverage that interrupts each affected MCP startup phase and verifies that the user prompt remains in history before the turn-aborted marker. GitOrigin-RevId: 6e96c6814357a55545d69b580e28f35933cfadf7
This commit is contained in:
1 parent
bd5b55e403
commit
d7e8f4c3dc
21 files changed
+359
-174
No files matched your search
@@ -112,7 +112,9 @@ async fn parallel_support_does_not_match_namespaced_local_tool_names() -> anyhow
|
||||
let turn = Arc::new(turn);
|
||||
let step_context = StepContext::for_test(Arc::clone(&turn));
|
||||
let router = ToolRouter::from_context(
|
||||
step_context.as_ref(),
|
||||
step_context.turn.as_ref(),
|
||||
&step_context.environments,
|
||||
step_context.mcp.as_ref(),
|
||||
ToolRouterParams {
|
||||
tool_suggest_candidates: None,
|
||||
tool_runtimes: Vec::new(),
|
||||
@@ -210,7 +212,9 @@ async fn mcp_parallel_support_uses_handler_data() -> anyhow::Result<()> {
|
||||
let turn = Arc::new(turn);
|
||||
let step_context = StepContext::for_test(Arc::clone(&turn));
|
||||
let router = ToolRouter::from_context(
|
||||
step_context.as_ref(),
|
||||
step_context.turn.as_ref(),
|
||||
&step_context.environments,
|
||||
step_context.mcp.as_ref(),
|
||||
ToolRouterParams {
|
||||
tool_suggest_candidates: None,
|
||||
tool_runtimes: vec![
|
||||
@@ -260,7 +264,9 @@ async fn tools_without_handlers_do_not_support_parallel() -> anyhow::Result<()>
|
||||
let turn = Arc::new(turn);
|
||||
let step_context = StepContext::for_test(Arc::clone(&turn));
|
||||
let router = ToolRouter::from_context(
|
||||
step_context.as_ref(),
|
||||
step_context.turn.as_ref(),
|
||||
&step_context.environments,
|
||||
step_context.mcp.as_ref(),
|
||||
ToolRouterParams {
|
||||
tool_suggest_candidates: None,
|
||||
tool_runtimes: Vec::new(),
|
||||
@@ -316,7 +322,9 @@ async fn specs_filter_deferred_dynamic_tools() -> anyhow::Result<()> {
|
||||
})];
|
||||
|
||||
let router = ToolRouter::from_context(
|
||||
step_context.as_ref(),
|
||||
step_context.turn.as_ref(),
|
||||
&step_context.environments,
|
||||
step_context.mcp.as_ref(),
|
||||
ToolRouterParams {
|
||||
tool_suggest_candidates: None,
|
||||
tool_runtimes: Vec::new(),
|
||||
@@ -330,7 +338,6 @@ async fn specs_filter_deferred_dynamic_tools() -> anyhow::Result<()> {
|
||||
namespace_function_names(&router.model_visible_specs(), "codex_app"),
|
||||
vec![visible_tool.to_string()]
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -387,7 +394,9 @@ async fn extension_tool_executors_are_model_visible_and_dispatchable() -> anyhow
|
||||
expected_history_item.set_turn_id_if_missing(&turn.sub_id);
|
||||
|
||||
let router = ToolRouter::from_context(
|
||||
step_context.as_ref(),
|
||||
step_context.turn.as_ref(),
|
||||
&step_context.environments,
|
||||
step_context.mcp.as_ref(),
|
||||
ToolRouterParams {
|
||||
tool_suggest_candidates: None,
|
||||
tool_runtimes: Vec::new(),
|
||||
|
||||
Reference in new issue
Block a user