fix(codex): 移除 Responses Lite 请求中的 context_management

This commit is contained in:
ZheFox
2026-07-16 11:25:11 +08:00
parent 85854e4476
commit 3976652942
3 changed files with 14 additions and 1 deletions
@@ -56,6 +56,7 @@ async fn gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_r
reasoning_effort: String,
reasoning_context: String,
has_compaction_trigger: bool,
has_context_management: bool,
}
#[derive(Debug, Clone)]
@@ -498,6 +499,10 @@ async fn gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_r
== Some("compaction_trigger")
})
}),
has_context_management: payload
.get("body")
.and_then(|value| value.get("json_body"))
.is_some_and(|body| body.get("context_management").is_some()),
});
let frames = concat!(
"{\"type\":\"headers\",\"payload\":{\"kind\":\"headers\",\"status_code\":200,\"headers\":{\"content-type\":\"text/event-stream\"}}}\n",
@@ -587,7 +592,7 @@ async fn gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_r
)
.header(TRACE_ID_HEADER, "trace-codex-cli-stream-local-123")
.body(
r#"{"model":"gpt-5.6-sol","instructions":"Use the configured tools.","input":[{"type":"message","role":"user","content":[{"type":"input_text","text":"compact"}]},{"type":"compaction_trigger"}],"tools":[{"type":"function","name":"lookup","parameters":{"type":"object"}}],"parallel_tool_calls":true,"prompt_cache_key":"thread-codex-stream-local-123","client_metadata":{"session_id":"session-codex-stream-local-123","thread_id":"thread-codex-stream-local-123"},"stream":true}"#,
r#"{"model":"gpt-5.6-sol","instructions":"Use the configured tools.","input":[{"type":"message","role":"user","content":[{"type":"input_text","text":"compact"}]},{"type":"compaction_trigger"}],"tools":[{"type":"function","name":"lookup","parameters":{"type":"object"}}],"context_management":[{"type":"compaction","compact_threshold":128000}],"parallel_tool_calls":true,"prompt_cache_key":"thread-codex-stream-local-123","client_metadata":{"session_id":"session-codex-stream-local-123","thread_id":"thread-codex-stream-local-123"},"stream":true}"#,
)
.send()
.await
@@ -711,6 +716,7 @@ async fn gateway_executes_codex_cli_stream_via_local_decision_gate_after_oauth_r
"all_turns"
);
assert!(seen_execution_runtime_request.has_compaction_trigger);
assert!(!seen_execution_runtime_request.has_context_management);
let stored_candidates = request_candidate_repository
.list_by_request_id("trace-codex-cli-stream-local-123")
@@ -607,6 +607,10 @@ mod tests {
}
}
}],
"context_management": [{
"type": "compaction",
"compact_threshold": 128000
}],
"parallel_tool_calls": true
});
@@ -629,6 +633,7 @@ mod tests {
assert_eq!(body, first);
assert!(body.get("instructions").is_none());
assert!(body.get("tools").is_none());
assert!(body.get("context_management").is_none());
assert_eq!(body["input"][0]["type"], "additional_tools");
assert_eq!(body["input"][0]["role"], "developer");
assert_eq!(body["input"][0]["tools"][0]["name"], "lookup");
@@ -1298,6 +1298,8 @@ fn apply_codex_responses_lite_body_contract(
return;
}
body_object.remove("context_management");
let tools_are_valid = body_object
.get("tools")
.is_none_or(|tools| tools.is_null() || tools.is_array());