Remove the redundant tool dispatch wrapper (#33866)

## What changed

- Remove `ToolRegistry::dispatch_any`, which always forwarded a missing terminal outcome.
- Update registry and dispatch trace tests to call `dispatch_any_with_terminal_outcome` with `None` explicitly.

GitOrigin-RevId: aa3acb2ed480fd452bc25301a351f46e759bbfab
This commit is contained in:
jif authored and copyberry committed 2026-07-17 16:21:04 +00:00
1 parent 7c4aaf28c2
commit 908fe8ccc9
3 files changed
+78 -66

No files matched your search

-9
View File
@@ -392,15 +392,6 @@ impl ToolRegistry {
Some(tool.waits_for_runtime_cancellation()) Some(tool.waits_for_runtime_cancellation())
} }
#[allow(dead_code)]
pub(crate) async fn dispatch_any(
&self,
invocation: ToolInvocation,
) -> Result<AnyToolResult, FunctionCallError> {
self.dispatch_any_with_terminal_outcome(invocation, /*terminal_outcome_reached*/ None)
.await
}
#[expect( #[expect(
clippy::await_holding_invalid_type, clippy::await_holding_invalid_type,
reason = "tool dispatch must keep active-turn accounting atomic" reason = "tool dispatch must keep active-turn accounting atomic"
+18 -12
View File
@@ -399,20 +399,26 @@ async fn dispatch_notifies_tool_lifecycle_contributors() -> anyhow::Result<()> {
let turn = Arc::new(turn); let turn = Arc::new(turn);
registry registry
.dispatch_any(test_invocation( .dispatch_any_with_terminal_outcome(
Arc::clone(&session), test_invocation(
Arc::clone(&turn), Arc::clone(&session),
"ok-call", Arc::clone(&turn),
ok_tool.clone(), "ok-call",
)) ok_tool.clone(),
),
/*terminal_outcome_reached*/ None,
)
.await?; .await?;
let err = match registry let err = match registry
.dispatch_any(test_invocation( .dispatch_any_with_terminal_outcome(
Arc::clone(&session), test_invocation(
Arc::clone(&turn), Arc::clone(&session),
"failing-call", Arc::clone(&turn),
failing_tool.clone(), "failing-call",
)) failing_tool.clone(),
),
/*terminal_outcome_reached*/ None,
)
.await .await
{ {
Ok(_) => panic!("failing handler should return an error"), Ok(_) => panic!("failing handler should return an error"),
@@ -78,27 +78,33 @@ async fn dispatch_lifecycle_trace_records_direct_and_code_mode_requesters() -> a
let turn = Arc::new(turn); let turn = Arc::new(turn);
registry registry
.dispatch_any(test_invocation( .dispatch_any_with_terminal_outcome(
Arc::clone(&session), test_invocation(
Arc::clone(&turn), Arc::clone(&session),
"direct-call", Arc::clone(&turn),
"test_tool", "direct-call",
ToolCallSource::Direct, "test_tool",
"{}", ToolCallSource::Direct,
)) "{}",
),
/*terminal_outcome_reached*/ None,
)
.await?; .await?;
registry registry
.dispatch_any(test_invocation( .dispatch_any_with_terminal_outcome(
session, test_invocation(
turn, session,
"code-mode-call", turn,
"test_tool", "code-mode-call",
ToolCallSource::CodeMode { "test_tool",
cell_id: "cell-1".to_string(), ToolCallSource::CodeMode {
runtime_tool_call_id: "tool-1".to_string(), cell_id: "cell-1".to_string(),
}, runtime_tool_call_id: "tool-1".to_string(),
"{}", },
)) "{}",
),
/*terminal_outcome_reached*/ None,
)
.await?; .await?;
let replayed = codex_rollout_trace::replay_bundle(single_bundle_dir(temp.path())?)?; let replayed = codex_rollout_trace::replay_bundle(single_bundle_dir(temp.path())?)?;
@@ -157,14 +163,17 @@ async fn dispatch_lifecycle_trace_records_unsupported_tool_failures() -> anyhow:
let turn = Arc::new(turn); let turn = Arc::new(turn);
let result = registry let result = registry
.dispatch_any(test_invocation( .dispatch_any_with_terminal_outcome(
session, test_invocation(
turn, session,
"unsupported-call", turn,
"missing_tool", "unsupported-call",
ToolCallSource::Direct, "missing_tool",
"{}", ToolCallSource::Direct,
)) "{}",
),
/*terminal_outcome_reached*/ None,
)
.await; .await;
assert!(matches!(result, Err(FunctionCallError::RespondToModel(_)))); assert!(matches!(result, Err(FunctionCallError::RespondToModel(_))));
@@ -189,16 +198,19 @@ async fn dispatch_lifecycle_trace_records_incompatible_payload_failures() -> any
let turn = Arc::new(turn); let turn = Arc::new(turn);
let result = registry let result = registry
.dispatch_any(test_invocation_with_payload( .dispatch_any_with_terminal_outcome(
session, test_invocation_with_payload(
turn, session,
"incompatible-call", turn,
codex_tools::ToolName::plain("test_tool"), "incompatible-call",
ToolCallSource::Direct, codex_tools::ToolName::plain("test_tool"),
ToolPayload::Custom { ToolCallSource::Direct,
input: "{}".to_string(), ToolPayload::Custom {
}, input: "{}".to_string(),
)) },
),
/*terminal_outcome_reached*/ None,
)
.await; .await;
assert!(matches!(result, Err(FunctionCallError::Fatal(_)))); assert!(matches!(result, Err(FunctionCallError::Fatal(_))));
@@ -221,14 +233,17 @@ async fn missing_code_mode_wait_traces_only_the_wait_tool_call() -> anyhow::Resu
let turn = Arc::new(turn); let turn = Arc::new(turn);
registry registry
.dispatch_any(test_invocation( .dispatch_any_with_terminal_outcome(
session, test_invocation(
turn, session,
"wait-call", turn,
WAIT_TOOL_NAME, "wait-call",
ToolCallSource::Direct, WAIT_TOOL_NAME,
r#"{"cell_id":"noop","terminate":true}"#, ToolCallSource::Direct,
)) r#"{"cell_id":"noop","terminate":true}"#,
),
/*terminal_outcome_reached*/ None,
)
.await?; .await?;
let replayed = codex_rollout_trace::replay_bundle(single_bundle_dir(temp.path())?)?; let replayed = codex_rollout_trace::replay_bundle(single_bundle_dir(temp.path())?)?;