mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Support all types of search actions (#7061)
Fixes the
```
{
"error": {
"message": "Invalid value: 'other'. Supported values are: 'search', 'open_page', and 'find_in_page'.",
"type": "invalid_request_error",
"param": "input[150].action.type",
"code": "invalid_value"
}
```
error.
The actual-actual fix here is supporting absent `query` parameter.
This commit is contained in:
1 parent
767b66f407
commit
ab5972d447
3 files changed
+86
-4
No files matched your search
@@ -117,7 +117,7 @@ pub fn parse_turn_item(item: &ResponseItem) -> Option<TurnItem> {
|
|||||||
..
|
..
|
||||||
} => Some(TurnItem::WebSearch(WebSearchItem {
|
} => Some(TurnItem::WebSearch(WebSearchItem {
|
||||||
id: id.clone().unwrap_or_default(),
|
id: id.clone().unwrap_or_default(),
|
||||||
query: query.clone(),
|
query: query.clone().unwrap_or_default(),
|
||||||
})),
|
})),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
@@ -306,7 +306,7 @@ mod tests {
|
|||||||
id: Some("ws_1".to_string()),
|
id: Some("ws_1".to_string()),
|
||||||
status: Some("completed".to_string()),
|
status: Some("completed".to_string()),
|
||||||
action: WebSearchAction::Search {
|
action: WebSearchAction::Search {
|
||||||
query: "weather".to_string(),
|
query: Some("weather".to_string()),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -992,7 +992,7 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
|
|||||||
id: Some("web-search-id".into()),
|
id: Some("web-search-id".into()),
|
||||||
status: Some("completed".into()),
|
status: Some("completed".into()),
|
||||||
action: WebSearchAction::Search {
|
action: WebSearchAction::Search {
|
||||||
query: "weather".into(),
|
query: Some("weather".into()),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
prompt.input.push(ResponseItem::FunctionCall {
|
prompt.input.push(ResponseItem::FunctionCall {
|
||||||
|
|||||||
@@ -230,8 +230,24 @@ pub struct LocalShellExecAction {
|
|||||||
#[serde(tag = "type", rename_all = "snake_case")]
|
#[serde(tag = "type", rename_all = "snake_case")]
|
||||||
pub enum WebSearchAction {
|
pub enum WebSearchAction {
|
||||||
Search {
|
Search {
|
||||||
query: String,
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
#[ts(optional)]
|
||||||
|
query: Option<String>,
|
||||||
},
|
},
|
||||||
|
OpenPage {
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
#[ts(optional)]
|
||||||
|
url: Option<String>,
|
||||||
|
},
|
||||||
|
FindInPage {
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
#[ts(optional)]
|
||||||
|
url: Option<String>,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
#[ts(optional)]
|
||||||
|
pattern: Option<String>,
|
||||||
|
},
|
||||||
|
|
||||||
#[serde(other)]
|
#[serde(other)]
|
||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
@@ -634,6 +650,72 @@ mod tests {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn roundtrips_web_search_call_actions() -> Result<()> {
|
||||||
|
let cases = vec![
|
||||||
|
(
|
||||||
|
r#"{
|
||||||
|
"type": "web_search_call",
|
||||||
|
"status": "completed",
|
||||||
|
"action": {
|
||||||
|
"type": "search",
|
||||||
|
"query": "weather seattle"
|
||||||
|
}
|
||||||
|
}"#,
|
||||||
|
WebSearchAction::Search {
|
||||||
|
query: Some("weather seattle".into()),
|
||||||
|
},
|
||||||
|
Some("completed".into()),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r#"{
|
||||||
|
"type": "web_search_call",
|
||||||
|
"status": "open",
|
||||||
|
"action": {
|
||||||
|
"type": "open_page",
|
||||||
|
"url": "https://example.com"
|
||||||
|
}
|
||||||
|
}"#,
|
||||||
|
WebSearchAction::OpenPage {
|
||||||
|
url: Some("https://example.com".into()),
|
||||||
|
},
|
||||||
|
Some("open".into()),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r#"{
|
||||||
|
"type": "web_search_call",
|
||||||
|
"status": "in_progress",
|
||||||
|
"action": {
|
||||||
|
"type": "find_in_page",
|
||||||
|
"url": "https://example.com/docs",
|
||||||
|
"pattern": "installation"
|
||||||
|
}
|
||||||
|
}"#,
|
||||||
|
WebSearchAction::FindInPage {
|
||||||
|
url: Some("https://example.com/docs".into()),
|
||||||
|
pattern: Some("installation".into()),
|
||||||
|
},
|
||||||
|
Some("in_progress".into()),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (json_literal, expected_action, expected_status) in cases {
|
||||||
|
let parsed: ResponseItem = serde_json::from_str(json_literal)?;
|
||||||
|
let expected = ResponseItem::WebSearchCall {
|
||||||
|
id: None,
|
||||||
|
status: expected_status.clone(),
|
||||||
|
action: expected_action.clone(),
|
||||||
|
};
|
||||||
|
assert_eq!(parsed, expected);
|
||||||
|
|
||||||
|
let serialized = serde_json::to_value(&parsed)?;
|
||||||
|
let original_value: serde_json::Value = serde_json::from_str(json_literal)?;
|
||||||
|
assert_eq!(serialized, original_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize_shell_tool_call_params() -> Result<()> {
|
fn deserialize_shell_tool_call_params() -> Result<()> {
|
||||||
let json = r#"{
|
let json = r#"{
|
||||||
|
|||||||
Reference in new issue
Block a user