mirror of
https://github.com/openai/codex.git
synced 2026-09-14 11:57:03 +00:00
change-web-search
This commit is contained in:
@@ -123,7 +123,6 @@ async fn compact_resume_and_fork_preserve_model_history_view() {
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
let tool_calls = requests[0]["tools"].clone();
|
||||
let tool_choice = requests[0]["tool_choice"].clone();
|
||||
let prompt_cache_key = requests[0]["prompt_cache_key"]
|
||||
.as_str()
|
||||
@@ -170,7 +169,6 @@ async fn compact_resume_and_fork_preserve_model_history_view() {
|
||||
]
|
||||
}
|
||||
],
|
||||
"tools": tool_calls,
|
||||
"tool_choice": tool_choice,
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
@@ -304,7 +302,6 @@ SUMMARY_ONLY_CONTEXT"
|
||||
]
|
||||
}
|
||||
],
|
||||
"tools": tool_calls,
|
||||
"tool_choice": tool_choice,
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
@@ -389,7 +386,6 @@ SUMMARY_ONLY_CONTEXT"
|
||||
]
|
||||
}
|
||||
],
|
||||
"tools": tool_calls,
|
||||
"tool_choice": tool_choice,
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
@@ -474,7 +470,6 @@ SUMMARY_ONLY_CONTEXT"
|
||||
]
|
||||
}
|
||||
],
|
||||
"tools": tool_calls,
|
||||
"tool_choice": tool_choice,
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
|
||||
@@ -258,6 +258,11 @@ async fn prompt_tools_are_consistent_across_requests() {
|
||||
serde_json::json!(expected_instructions),
|
||||
);
|
||||
assert_tool_names(&body1, expected_tools_names);
|
||||
assert_eq!(
|
||||
body1.get("tool_choice"),
|
||||
body0.get("tool_choice"),
|
||||
"tool_choice should remain consistent across requests"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
|
||||
@@ -473,22 +473,17 @@ async fn web_search_allowed_when_other_tool_disabled() -> Result<()> {
|
||||
.and_then(Value::as_array)
|
||||
.cloned()
|
||||
.expect("allowed tools array");
|
||||
let allowed_names = allowed
|
||||
.iter()
|
||||
.filter_map(|tool| tool.get("name").and_then(Value::as_str))
|
||||
.collect::<Vec<_>>();
|
||||
assert!(
|
||||
allowed
|
||||
.iter()
|
||||
.any(|tool| tool.get("name").and_then(Value::as_str) == Some("web_search")),
|
||||
allowed_names.contains(&"web_search"),
|
||||
"expected web_search to remain allowed: {allowed:?}"
|
||||
);
|
||||
assert!(
|
||||
!allowed
|
||||
.iter()
|
||||
.any(|tool| tool.get("name").and_then(Value::as_str) == Some("view_image")),
|
||||
"expected view_image to be excluded: {allowed:?}"
|
||||
);
|
||||
let tools = tool_names(&body);
|
||||
assert!(
|
||||
tools.iter().any(|name| name == "web_search"),
|
||||
"expected tools list to include web_search: {tools:?}"
|
||||
!allowed_names.contains(&"view_image"),
|
||||
"expected view_image to be excluded from allowed_tools: {allowed:?}"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
@@ -550,19 +545,10 @@ async fn override_enables_web_search() -> Result<()> {
|
||||
.await;
|
||||
|
||||
let body = mock.single_request().body_json();
|
||||
let choice = body
|
||||
.get("tool_choice")
|
||||
.expect("tool_choice field should be present");
|
||||
assert_eq!(
|
||||
choice.as_str(),
|
||||
Some("auto"),
|
||||
"expected unrestricted tool choice to be auto: {choice:?}"
|
||||
);
|
||||
|
||||
let tools = tool_names(&body);
|
||||
assert!(
|
||||
tools.iter().any(|name| name == "web_search"),
|
||||
"expected tools list to include web_search: {tools:?}"
|
||||
body.get("tool_choice"),
|
||||
Some(&Value::String("auto".to_string())),
|
||||
"expected unrestricted tool choice to be auto"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user