mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve parent cache affinity for ephemeral forks (#44862)
## Why ChatGPT derives Responses cache affinity from the `session-id` header. Ephemeral forks need to reuse their parent's cache routing while retaining their own session and thread identities. ## What changed - Inherit the parent session ID as the `prompt_cache_key` for ephemeral root forks. - Use the prompt cache key for root-agent Responses `session-id` headers, including WebSocket handshakes. Preserve the actual session identity in turn metadata and leave non-root-agent routing unchanged. - Keep enabled goal tool definitions visible on ephemeral threads, but reject execution with `Goal tools require a persistent thread.` and disable automatic goal continuation without persistent state. ## Testing Add regression coverage for inherited cache routing with distinct fork identities, matching parent and fork tool definitions, WebSocket session headers, and rejection of ephemeral goal tool execution. GitOrigin-RevId: d235e97630068b27f7ebd562dd23ac6266ebc1b9
This commit is contained in:
1 parent
0818b6550b
commit
bc5957eac9
8 files changed
+167
-22
No files matched your search
@@ -1276,9 +1276,13 @@ fn guardian_reviewer_uses_dedicated_endpoint_only_with_codex_backend_auth() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test_case::test_case(/*cache_key*/ None; "own_cache")]
|
||||
#[test_case::test_case(Some("parent-session"); "inherited_cache")]
|
||||
#[tokio::test]
|
||||
async fn websocket_handshake_includes_attestation_for_chatgpt_codex_responses() {
|
||||
let (model_client, attestation_calls) =
|
||||
async fn websocket_handshake_includes_attestation_for_chatgpt_codex_responses(
|
||||
cache_key: Option<&str>,
|
||||
) {
|
||||
let (mut model_client, attestation_calls) =
|
||||
model_client_with_counting_attestation(/*include_attestation*/ true);
|
||||
let responses_metadata = test_responses_metadata_for_client(
|
||||
&model_client,
|
||||
@@ -1288,6 +1292,7 @@ async fn websocket_handshake_includes_attestation_for_chatgpt_codex_responses()
|
||||
TestCodexResponsesRequestKind::WebsocketConnection,
|
||||
);
|
||||
|
||||
model_client.prompt_cache_key_override = cache_key.map(str::to_string);
|
||||
let headers = model_client
|
||||
.build_websocket_headers(&responses_metadata)
|
||||
.await;
|
||||
@@ -1299,6 +1304,11 @@ async fn websocket_handshake_includes_attestation_for_chatgpt_codex_responses()
|
||||
Some("v1.header-1"),
|
||||
);
|
||||
assert_eq!(attestation_calls.load(Ordering::Relaxed), 1);
|
||||
assert_eq!(
|
||||
headers["session-id"],
|
||||
cache_key.unwrap_or(&responses_metadata.session_id)
|
||||
);
|
||||
assert_eq!(headers["thread-id"], responses_metadata.thread_id);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in new issue
Block a user