mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
standalone websearch extension (#23823)
## Summary Add the extension-backed standalone `web.run` tool so Codex can call the standalone search endpoint through the `codex-api` search client and return its encrypted output to Responses. - gate the new tool behind `standalone_web_search` - install the extension in the app-server thread registry and hide hosted `web_search` when standalone search is enabled for OpenAI providers so the two paths stay mutually exclusive - build search context from persisted history using a small tail heuristic: previous user message, assistant text between the last two user turns capped at about 1k tokens, and current user message ## Test Plan - `cargo test -p codex-web-search-extension` - `cargo test -p codex-api` - `cargo test -p codex-core hosted_tools_follow_provider_auth_model_and_config_gates`
This commit is contained in:
1 parent
aad59a0916
commit
a22706dfae
26 files changed
+1238
-22
No files matched your search
@@ -0,0 +1,36 @@
|
||||
use codex_api::SearchCommands;
|
||||
use schemars::r#gen::SchemaSettings;
|
||||
use serde_json::Map;
|
||||
use serde_json::Value;
|
||||
|
||||
pub(crate) fn commands_schema() -> 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");
|
||||
};
|
||||
|
||||
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)
|
||||
}
|
||||
Reference in new issue
Block a user