mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
Configure Guardian sampling for responses lite (#38527)
## What changed - Opt Guardian V2 Luna sampler WebSocket connections into responses lite. - Send `reasoning.context` as `all_turns` on sampling requests. ## Testing - Extend sampler and extension tests to verify the connection header and reasoning context. GitOrigin-RevId: 4b0263c01b8259ed5268c222dcf7559912baba8c
This commit is contained in:
@@ -147,6 +147,7 @@ async fn contributor_samples_tool_calls_with_the_existing_luna_pool() -> Result<
|
||||
assert_eq!(request["client_metadata"]["thread_id"], "thread-1");
|
||||
assert_eq!(request["client_metadata"]["turn_id"], "turn-1");
|
||||
assert_eq!(request["reasoning"]["effort"], "low");
|
||||
assert_eq!(request["reasoning"]["context"], "all_turns");
|
||||
assert_eq!(request["text"]["format"]["strict"], true);
|
||||
assert_eq!(
|
||||
request["text"]["format"]["schema"]["properties"]["scores"]["properties"]["action_risk"],
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::time::Instant;
|
||||
|
||||
use codex_api::ApiError;
|
||||
use codex_api::Reasoning;
|
||||
use codex_api::ReasoningContext;
|
||||
use codex_api::ResponseEvent;
|
||||
use codex_api::ResponsesApiRequest;
|
||||
use codex_api::ResponsesWebsocketClient;
|
||||
@@ -171,6 +172,10 @@ impl LunaSampler {
|
||||
"openai-beta",
|
||||
HeaderValue::from_static(RESPONSES_WEBSOCKETS_BETA),
|
||||
);
|
||||
headers.insert(
|
||||
"x-openai-internal-codex-responses-lite",
|
||||
HeaderValue::from_static("true"),
|
||||
);
|
||||
if let Some(originator) = self.config.originator.as_deref() {
|
||||
add_originator_header(&mut headers, originator);
|
||||
}
|
||||
@@ -292,7 +297,7 @@ impl LunaSampler {
|
||||
reasoning: Some(Reasoning {
|
||||
effort: Some(request.reasoning_effort),
|
||||
summary: None,
|
||||
context: None,
|
||||
context: Some(ReasoningContext::AllTurns),
|
||||
}),
|
||||
store: false,
|
||||
stream: true,
|
||||
|
||||
@@ -131,6 +131,10 @@ async fn preconnected_sampler_reuses_authenticated_websocket_for_structured_requ
|
||||
handshake.header("OpenAI-Beta"),
|
||||
Some("responses_websockets=2026-02-06".to_owned())
|
||||
);
|
||||
assert_eq!(
|
||||
handshake.header("x-openai-internal-codex-responses-lite"),
|
||||
Some("true".to_owned())
|
||||
);
|
||||
assert_eq!(handshake.header("session-id"), Some("session-1".to_owned()));
|
||||
assert_eq!(handshake.header("thread-id"), Some("thread-1".to_owned()));
|
||||
assert_eq!(
|
||||
@@ -196,6 +200,7 @@ async fn preconnected_sampler_reuses_authenticated_websocket_for_structured_requ
|
||||
assert!(request.get("tools").is_none());
|
||||
let effort = if index == 0 { "none" } else { "medium" };
|
||||
assert_eq!(request["reasoning"]["effort"], effort);
|
||||
assert_eq!(request["reasoning"]["context"], "all_turns");
|
||||
assert_eq!(
|
||||
request["client_metadata"]["turn_id"],
|
||||
format!("turn-{}", index + 1)
|
||||
|
||||
Reference in New Issue
Block a user