feat(codex): 拆分openai:compact为独立端点,简化Codex请求为透传模式

- 新增openai:compact端点类型(EndpointKind.COMPACT),独立于openai:cli
- OpenAICompactAdapter继承OpenAICliAdapter,自动标记compact模式
- Codex请求补丁改为纯透传:仅清理内部标记,不再修改客户端payload
- stream_policy支持openai:compact独立策略,compact端点移除stream字段
- candidate_builder支持compact回退到cli端点
- auth_type: vertex_ai重命名为service_account,保持向后兼容
- Vertex Provider新增api_formats与auth_type组合校验
- KeyAllowedModels对话框改为从Provider获取模型,展示provider_model_name
- Dialog内Select组件自动禁用Portal,修复层级遮挡问题
- 新增Codex compact端点回填迁移脚本
This commit is contained in:
fawney19
2026-03-01 23:55:26 +08:00
parent 4bf3a453e7
commit 97d42703da
37 changed files with 650 additions and 286 deletions

View File

@@ -59,6 +59,15 @@ def test_get_upstream_stream_policy_codex_compact_forces_non_stream() -> None:
set_codex_request_context(None)
def test_get_upstream_stream_policy_codex_openai_compact_defaults_to_auto() -> None:
ep = _DummyEndpoint(
api_format="openai:compact",
config=None,
provider=SimpleNamespace(provider_type="codex"),
)
assert get_upstream_stream_policy(ep) == UpstreamStreamPolicy.AUTO
def test_enforce_stream_mode_for_upstream_openai_chat_sets_stream_options_usage() -> None:
body = {"stream": False}
out = enforce_stream_mode_for_upstream(
@@ -79,3 +88,30 @@ def test_enforce_stream_mode_for_upstream_gemini_drops_stream_field() -> None:
)
assert "stream" not in out
assert out["foo"] == "bar"
def test_enforce_stream_mode_for_upstream_openai_compact_drops_stream_field() -> None:
body = {"stream": True, "foo": "bar"}
out = enforce_stream_mode_for_upstream(
body,
provider_api_format="openai:compact",
upstream_is_stream=True,
)
assert "stream" not in out
assert out["foo"] == "bar"
def test_enforce_stream_mode_for_upstream_codex_compact_keeps_stream_absent() -> None:
body = {"stream": True, "foo": "bar"}
try:
set_codex_request_context(CodexRequestContext(is_compact=True))
out = enforce_stream_mode_for_upstream(
body,
provider_api_format="openai:cli",
upstream_is_stream=False,
)
finally:
set_codex_request_context(None)
assert "stream" not in out
assert out["foo"] == "bar"