mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
refactor(codex): 移除 envelope/request_patching 层,用 context var 统一 compact 状态判断
- 删除 CodexOAuthEnvelope 和 request_patching 模块,Codex 不再需要 envelope 层 - 移除 _aether_compact 请求体内部标记,改用 is_codex_compact_request() 集中查询 - 简化 OpenAI CLI adapter,移除 Codex 专用的 get_cli_extra_headers/build_test_request_body 逻辑 - 移除 Codex behavior variant 注册(same_format/cross_format) - normalizer patch_same_format_request 对 codex 变为 no-op - 更新相关测试适配新的架构
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from src.services.provider.adapters.codex.context import (
|
||||
CodexRequestContext,
|
||||
set_codex_request_context,
|
||||
)
|
||||
from src.services.provider.prompt_cache import (
|
||||
build_stable_codex_prompt_cache_key,
|
||||
build_stable_openai_prompt_cache_key,
|
||||
@@ -103,7 +107,7 @@ def test_maybe_patch_request_with_prompt_cache_key_for_codex_openai_cli() -> Non
|
||||
|
||||
|
||||
def test_maybe_patch_request_with_prompt_cache_key_skips_official_compact() -> None:
|
||||
req = {"model": "gpt-5", "input": [], "_aether_compact": True}
|
||||
req = {"model": "gpt-5", "input": []}
|
||||
|
||||
out = maybe_patch_request_with_prompt_cache_key(
|
||||
req,
|
||||
@@ -117,16 +121,20 @@ def test_maybe_patch_request_with_prompt_cache_key_skips_official_compact() -> N
|
||||
assert "prompt_cache_key" not in out
|
||||
|
||||
|
||||
def test_maybe_patch_request_with_prompt_cache_key_skips_codex_compact_marker() -> None:
|
||||
req = {"model": "gpt-5", "input": [], "_aether_compact": True}
|
||||
def test_maybe_patch_request_with_prompt_cache_key_skips_legacy_codex_compact_context() -> None:
|
||||
req = {"model": "gpt-5", "input": []}
|
||||
|
||||
out = maybe_patch_request_with_prompt_cache_key(
|
||||
req,
|
||||
provider_api_format="openai:cli",
|
||||
provider_type="codex",
|
||||
base_url="https://chatgpt.com/backend-api/codex",
|
||||
user_api_key_id="user-key-123",
|
||||
)
|
||||
try:
|
||||
set_codex_request_context(CodexRequestContext(is_compact=True))
|
||||
out = maybe_patch_request_with_prompt_cache_key(
|
||||
req,
|
||||
provider_api_format="openai:cli",
|
||||
provider_type="codex",
|
||||
base_url="https://chatgpt.com/backend-api/codex",
|
||||
user_api_key_id="user-key-123",
|
||||
)
|
||||
finally:
|
||||
set_codex_request_context(None)
|
||||
|
||||
assert out is req
|
||||
assert "prompt_cache_key" not in out
|
||||
|
||||
Reference in New Issue
Block a user