mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Forward turn metadata in standalone web search (#32835)
## What changed - Add optional serialized Codex turn metadata to extension tool calls. - Populate it from the current turn context and send it as the `x-codex-turn-metadata` header on standalone web search requests. ## Testing - Extend the app-server web search integration test to verify that client metadata, including the model ID, reaches the standalone search request. GitOrigin-RevId: c0950108d89a1d317ac94ccd23efcee72fffc6f0
This commit is contained in:
1 parent
2e156cbe31
commit
19a000259d
7 files changed
+80
-8
No files matched your search
@@ -4,6 +4,7 @@ use codex_api::SearchCommands;
|
||||
use codex_api::SearchQuery;
|
||||
use codex_api::SearchRequest;
|
||||
use codex_api::SearchSettings;
|
||||
use codex_core::X_CODEX_TURN_METADATA_HEADER;
|
||||
use codex_core::web_search_action_detail;
|
||||
use codex_extension_api::ExtensionTurnItem;
|
||||
use codex_extension_api::FunctionCallError;
|
||||
@@ -28,6 +29,7 @@ use codex_tools::ResponsesApiNamespaceTool;
|
||||
use codex_tools::ToolExposure;
|
||||
use codex_tools::default_namespace_description;
|
||||
use http::HeaderMap;
|
||||
use http::HeaderValue;
|
||||
use url::Url;
|
||||
|
||||
use crate::history::recent_input;
|
||||
@@ -113,6 +115,12 @@ impl WebSearchTool {
|
||||
u64::try_from(call.truncation_policy.token_budget()).unwrap_or(u64::MAX),
|
||||
),
|
||||
};
|
||||
let mut extra_headers = HeaderMap::new();
|
||||
if let Some(turn_metadata) = call.codex_turn_metadata.as_deref()
|
||||
&& let Ok(header_value) = HeaderValue::from_str(turn_metadata)
|
||||
{
|
||||
extra_headers.insert(X_CODEX_TURN_METADATA_HEADER, header_value);
|
||||
}
|
||||
call.turn_item_emitter
|
||||
.emit_started(extension_turn_item(
|
||||
WebSearchItem {
|
||||
@@ -126,7 +134,7 @@ impl WebSearchTool {
|
||||
))
|
||||
.await;
|
||||
let response = client
|
||||
.search(&request, HeaderMap::new())
|
||||
.search(&request, extra_headers)
|
||||
.await
|
||||
.map_err(|err| FunctionCallError::Fatal(err.to_string()))?;
|
||||
let legacy_action = match &command_action {
|
||||
|
||||
Reference in new issue
Block a user