mirror of
https://github.com/openai/codex.git
synced 2026-11-10 21:00:47 +00:00
## What changed Expose `literature_search_query` in standalone `web.run` when the active model lists it in `experimental_supported_tools`. Support query text, domain filters, and recency filters, and reject literature search calls for models without the capability. Pass the active model information to extensions for each step and report literature queries as search actions in web search events. ## Testing Add coverage for capability rejection, model-dependent schema exposure, app-server round trips with a turn-level model override, and a scenario that searches for a paper and opens the returned reference. GitOrigin-RevId: 87ef1fadd80ca7bfc2a7642c4e443f9b9f2e0e00
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
use codex_api::SearchCommands;
|
|
use schemars::r#gen::SchemaSettings;
|
|
use serde_json::Map;
|
|
use serde_json::Value;
|
|
|
|
pub(crate) const LITERATURE_SEARCH_QUERY: &str = "literature_search_query";
|
|
|
|
pub(crate) fn commands_schema(supports_literature_search: bool) -> Value {
|
|
let schema = SchemaSettings::draft2019_09()
|
|
.with(|settings| {
|
|
settings.inline_subschemas = true;
|
|
settings.option_add_null_type = false;
|
|
})
|
|
.into_generator()
|
|
.into_root_schema_for::<SearchCommands>();
|
|
let schema = match serde_json::to_value(schema) {
|
|
Ok(schema) => schema,
|
|
Err(err) => panic!("search commands schema should serialize: {err}"),
|
|
};
|
|
let Value::Object(mut schema) = schema else {
|
|
unreachable!("search commands schema must be an object");
|
|
};
|
|
if !supports_literature_search
|
|
&& let Some(Value::Object(properties)) = schema.get_mut("properties")
|
|
{
|
|
properties.remove(LITERATURE_SEARCH_QUERY);
|
|
}
|
|
|
|
let mut tool_schema = Map::new();
|
|
for key in [
|
|
"properties",
|
|
"required",
|
|
"type",
|
|
"additionalProperties",
|
|
"$defs",
|
|
"definitions",
|
|
] {
|
|
if let Some(value) = schema.remove(key) {
|
|
tool_schema.insert(key.to_string(), value);
|
|
}
|
|
}
|
|
Value::Object(tool_schema)
|
|
}
|