mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
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:
1 parent
7c4aaf28c2
commit
908fe8ccc9
3 files changed
+35
-23
No files matched your search
@@ -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"
|
||||||
|
|||||||
@@ -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(
|
||||||
|
test_invocation(
|
||||||
Arc::clone(&session),
|
Arc::clone(&session),
|
||||||
Arc::clone(&turn),
|
Arc::clone(&turn),
|
||||||
"ok-call",
|
"ok-call",
|
||||||
ok_tool.clone(),
|
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(
|
||||||
|
test_invocation(
|
||||||
Arc::clone(&session),
|
Arc::clone(&session),
|
||||||
Arc::clone(&turn),
|
Arc::clone(&turn),
|
||||||
"failing-call",
|
"failing-call",
|
||||||
failing_tool.clone(),
|
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,17 +78,21 @@ 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(
|
||||||
|
test_invocation(
|
||||||
Arc::clone(&session),
|
Arc::clone(&session),
|
||||||
Arc::clone(&turn),
|
Arc::clone(&turn),
|
||||||
"direct-call",
|
"direct-call",
|
||||||
"test_tool",
|
"test_tool",
|
||||||
ToolCallSource::Direct,
|
ToolCallSource::Direct,
|
||||||
"{}",
|
"{}",
|
||||||
))
|
),
|
||||||
|
/*terminal_outcome_reached*/ None,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
registry
|
registry
|
||||||
.dispatch_any(test_invocation(
|
.dispatch_any_with_terminal_outcome(
|
||||||
|
test_invocation(
|
||||||
session,
|
session,
|
||||||
turn,
|
turn,
|
||||||
"code-mode-call",
|
"code-mode-call",
|
||||||
@@ -98,7 +102,9 @@ async fn dispatch_lifecycle_trace_records_direct_and_code_mode_requesters() -> a
|
|||||||
runtime_tool_call_id: "tool-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(
|
||||||
|
test_invocation(
|
||||||
session,
|
session,
|
||||||
turn,
|
turn,
|
||||||
"unsupported-call",
|
"unsupported-call",
|
||||||
"missing_tool",
|
"missing_tool",
|
||||||
ToolCallSource::Direct,
|
ToolCallSource::Direct,
|
||||||
"{}",
|
"{}",
|
||||||
))
|
),
|
||||||
|
/*terminal_outcome_reached*/ None,
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(matches!(result, Err(FunctionCallError::RespondToModel(_))));
|
assert!(matches!(result, Err(FunctionCallError::RespondToModel(_))));
|
||||||
@@ -189,7 +198,8 @@ 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(
|
||||||
|
test_invocation_with_payload(
|
||||||
session,
|
session,
|
||||||
turn,
|
turn,
|
||||||
"incompatible-call",
|
"incompatible-call",
|
||||||
@@ -198,7 +208,9 @@ async fn dispatch_lifecycle_trace_records_incompatible_payload_failures() -> any
|
|||||||
ToolPayload::Custom {
|
ToolPayload::Custom {
|
||||||
input: "{}".to_string(),
|
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(
|
||||||
|
test_invocation(
|
||||||
session,
|
session,
|
||||||
turn,
|
turn,
|
||||||
"wait-call",
|
"wait-call",
|
||||||
WAIT_TOOL_NAME,
|
WAIT_TOOL_NAME,
|
||||||
ToolCallSource::Direct,
|
ToolCallSource::Direct,
|
||||||
r#"{"cell_id":"noop","terminate":true}"#,
|
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())?)?;
|
||||||
|
|||||||
Reference in new issue
Block a user