mirror of
https://github.com/openai/codex.git
synced 2026-11-18 15:01:48 +00:00
Route Guardian requests through /responses with identifying headers (#45736)
## What changed - Replace dedicated Guardian endpoints with `/responses`, sending `x-codex-guardian: reviewer` or `x-codex-guardian: classifier` for eligible Codex backend requests over HTTP and WebSocket. - Add model-scoped thread headers, recheck backend authentication on each request attempt, and reconnect WebSockets when the applicable headers change. - Retain `features.guardianv2.free_guardian` for configuration compatibility while removing its routing gate; the backend now controls Guardian billing. ## Testing Update tests for reviewer and classifier headers, model and authentication scoping, HTTP fallback, WebSocket reuse, and parent-response metadata across retries. GitOrigin-RevId: 1c2b3c458ab77fb40aae4ee6784f6d827c60e76c
This commit is contained in:
1 parent
d4e11a9b97
commit
eeded5ba1a
22 files changed
+246
-286
No files matched your search
@@ -12,7 +12,6 @@ use codex_api::Compression;
|
||||
use codex_api::Provider;
|
||||
use codex_api::ResponsesApiRequest;
|
||||
use codex_api::ResponsesClient;
|
||||
use codex_api::ResponsesEndpoint;
|
||||
use codex_api::ResponsesOptions;
|
||||
use codex_client::HttpTransport;
|
||||
use codex_client::Request;
|
||||
@@ -308,22 +307,28 @@ async fn responses_client_uses_responses_path() -> Result<()> {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn responses_client_uses_guardian_path() -> Result<()> {
|
||||
async fn responses_client_sends_extra_headers() -> Result<()> {
|
||||
let state = RecordingState::default();
|
||||
let transport = RecordingTransport::new(state.clone());
|
||||
let client = ResponsesClient::new(transport, provider("openai"), Arc::new(NoAuth))
|
||||
.with_endpoint(ResponsesEndpoint::Guardian);
|
||||
|
||||
let client = ResponsesClient::new(transport, provider("openai"), Arc::new(NoAuth));
|
||||
let headers = HeaderMap::from_iter([(
|
||||
http::HeaderName::from_static("x-custom-request"),
|
||||
HeaderValue::from_static("example"),
|
||||
)]);
|
||||
let _stream = client
|
||||
.stream(
|
||||
serde_json::json!({ "echo": true }),
|
||||
HeaderMap::new(),
|
||||
headers,
|
||||
Compression::None,
|
||||
/*turn_state*/ None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert_path_ends_with(&state.take_stream_requests(), "/guardian");
|
||||
let requests = state.take_stream_requests();
|
||||
assert_path_ends_with(&requests, "/responses");
|
||||
assert_eq!(
|
||||
requests[0].headers.get("x-custom-request"),
|
||||
Some(&HeaderValue::from_static("example")),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user