mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-07-03 14:05:26 +02:00
Fix Codex review feedback
This commit is contained in:
@@ -147,7 +147,6 @@ class ClaudeCliAdapter:
|
||||
for key, value in base_env.items()
|
||||
if not key.startswith("ANTHROPIC_")
|
||||
}
|
||||
env.pop("ANTHROPIC_API_KEY", None)
|
||||
env["ANTHROPIC_BASE_URL"] = proxy_root_url
|
||||
env["CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"] = "1"
|
||||
env["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] = _AUTO_COMPACT_WINDOW
|
||||
|
||||
@@ -31,9 +31,9 @@ class CodexCliAdapter:
|
||||
display_name = "Codex CLI"
|
||||
default_binary = "codex"
|
||||
install_hint = "Install Codex with: npm install -g @openai/codex"
|
||||
trace_stage = "claude_cli"
|
||||
process_launch_event = "claude_cli.process.launch"
|
||||
trace_source = "claude_cli"
|
||||
trace_stage = "codex_cli"
|
||||
process_launch_event = "codex_cli.process.launch"
|
||||
trace_source = "codex_cli"
|
||||
|
||||
def build_task_invocation(
|
||||
self,
|
||||
@@ -49,8 +49,9 @@ class CodexCliAdapter:
|
||||
auth_token=config.auth_token,
|
||||
base_env=base_env,
|
||||
)
|
||||
codex_bin = getattr(config, "codex_bin", None) or self.default_binary
|
||||
cmd = self._task_command(
|
||||
codex_bin=getattr(config, "codex_bin", config.claude_bin),
|
||||
codex_bin=codex_bin,
|
||||
prompt=request.prompt,
|
||||
session_id=request.session_id,
|
||||
fork_session=request.fork_session,
|
||||
@@ -75,7 +76,7 @@ class CodexCliAdapter:
|
||||
"fork_session": request.fork_session,
|
||||
"prompt": request.prompt,
|
||||
"cwd": config.workspace_path,
|
||||
"claude_binary": config.claude_bin,
|
||||
"codex_binary": codex_bin,
|
||||
"cli_argv": cmd,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -43,10 +43,11 @@ def responses_request_to_anthropic_payload(
|
||||
if isinstance(request.get("metadata"), dict):
|
||||
payload["metadata"] = request["metadata"]
|
||||
|
||||
raw_tool_choice = request.get("tool_choice")
|
||||
tools = _convert_tools(request.get("tools"))
|
||||
if tools:
|
||||
if tools and raw_tool_choice != "none":
|
||||
payload["tools"] = tools
|
||||
tool_choice = _convert_tool_choice(request.get("tool_choice"))
|
||||
tool_choice = _convert_tool_choice(raw_tool_choice)
|
||||
if tool_choice is not None:
|
||||
payload["tool_choice"] = tool_choice
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ def test_codex_adapter_builds_new_task_command_and_env() -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert invocation.argv[:3] == ("claude-test", "exec", "--json")
|
||||
assert invocation.argv[:3] == ("codex", "exec", "--json")
|
||||
assert "--dangerously-bypass-approvals-and-sandbox" in invocation.argv
|
||||
assert "-C" in invocation.argv
|
||||
assert "/workspace" in invocation.argv
|
||||
@@ -216,6 +216,22 @@ def test_codex_adapter_builds_new_task_command_and_env() -> None:
|
||||
assert "OPENAI_BASE_URL" not in invocation.env
|
||||
assert "CODEX_API_KEY" not in invocation.env
|
||||
assert invocation.trace_metadata["client_cli_id"] == "codex"
|
||||
assert invocation.trace_metadata["codex_binary"] == "codex"
|
||||
assert "claude_binary" not in invocation.trace_metadata
|
||||
assert CODEX_CLI_ADAPTER.trace_stage == "codex_cli"
|
||||
assert CODEX_CLI_ADAPTER.process_launch_event == "codex_cli.process.launch"
|
||||
assert CODEX_CLI_ADAPTER.trace_source == "codex_cli"
|
||||
|
||||
|
||||
def test_codex_adapter_uses_explicit_codex_binary_when_provided() -> None:
|
||||
invocation = CODEX_CLI_ADAPTER.build_task_invocation(
|
||||
config=_config(codex_bin="codex-test"),
|
||||
request=CliTaskRequest(prompt="hello"),
|
||||
base_env={},
|
||||
)
|
||||
|
||||
assert invocation.argv[:3] == ("codex-test", "exec", "--json")
|
||||
assert invocation.trace_metadata["codex_binary"] == "codex-test"
|
||||
|
||||
|
||||
def test_codex_adapter_builds_resume_command() -> None:
|
||||
@@ -225,7 +241,7 @@ def test_codex_adapter_builds_resume_command() -> None:
|
||||
base_env={},
|
||||
)
|
||||
|
||||
assert invocation.argv[:4] == ("claude-test", "exec", "resume", "--json")
|
||||
assert invocation.argv[:4] == ("codex", "exec", "resume", "--json")
|
||||
assert "sess_123" in invocation.argv
|
||||
assert invocation.argv[-1] == "continue"
|
||||
assert invocation.trace_metadata["resume_session_id"] == "sess_123"
|
||||
|
||||
@@ -110,6 +110,29 @@ def test_responses_messages_tools_and_tool_results_convert() -> None:
|
||||
assert payload["tool_choice"] == {"type": "tool", "name": "echo"}
|
||||
|
||||
|
||||
def test_responses_tool_choice_none_disables_forwarded_tools() -> None:
|
||||
payload = responses_request_to_anthropic_payload(
|
||||
{
|
||||
"model": "deepseek/deepseek-chat",
|
||||
"input": "Reply without tools",
|
||||
"tools": [
|
||||
{
|
||||
"type": "function",
|
||||
"name": "echo",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {"value": {"type": "string"}},
|
||||
},
|
||||
}
|
||||
],
|
||||
"tool_choice": "none",
|
||||
}
|
||||
)
|
||||
|
||||
assert "tools" not in payload
|
||||
assert "tool_choice" not in payload
|
||||
|
||||
|
||||
def test_responses_unsupported_tool_type_is_clear() -> None:
|
||||
with pytest.raises(
|
||||
ResponsesConversionError, match="Unsupported Responses tool type"
|
||||
|
||||
Reference in New Issue
Block a user