feat: Enhance ephemeral review process with reasoning effort handling and retry logic
This commit is contained in:
@@ -72,6 +72,14 @@ def test_build_install_command_includes_configured_reasoning_effort(monkeypatch:
|
||||
assert "--reasoning-effort medium" in command
|
||||
|
||||
|
||||
def test_build_install_command_can_disable_reasoning_effort_flag() -> None:
|
||||
settings = get_settings()
|
||||
|
||||
command = _build_install_and_run_command(settings, include_reasoning_effort=False)
|
||||
|
||||
assert "--reasoning-effort" not in command
|
||||
|
||||
|
||||
def test_chatgpt_mode_requires_existing_auth_json(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
||||
missing = tmp_path / "missing-auth.json"
|
||||
monkeypatch.setenv("CODEX_AUTH_MODE", "chatgpt")
|
||||
@@ -157,6 +165,59 @@ def test_run_review_ephemeral_api_key_mode_does_not_fallback_to_host(monkeypatch
|
||||
assert "API-key auth runner failed" in result["summary"]
|
||||
|
||||
|
||||
def test_run_review_ephemeral_retries_without_reasoning_effort_when_unsupported(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
get_settings.cache_clear()
|
||||
settings = get_settings()
|
||||
|
||||
monkeypatch.setattr(
|
||||
"gitea_codex_bot.workers.container_runner.prepare_review_prompt",
|
||||
lambda *_args, **_kwargs: ("prompt", {"diff": ""}, object()),
|
||||
)
|
||||
monkeypatch.setattr("gitea_codex_bot.workers.container_runner.GiteaClient", lambda _settings: object())
|
||||
|
||||
calls: list[list[str]] = []
|
||||
|
||||
def _fake_run(cmd, *args, **kwargs):
|
||||
calls.append(cmd)
|
||||
if len(calls) == 1:
|
||||
return type(
|
||||
"Completed",
|
||||
(),
|
||||
{
|
||||
"returncode": 2,
|
||||
"stdout": "",
|
||||
"stderr": "error: unexpected argument '--reasoning-effort' found",
|
||||
},
|
||||
)()
|
||||
return type(
|
||||
"Completed",
|
||||
(),
|
||||
{
|
||||
"returncode": 0,
|
||||
"stdout": '{"verdict":"correct","confidence":0.9,"summary":"ok","findings":[]}\n',
|
||||
"stderr": "",
|
||||
},
|
||||
)()
|
||||
|
||||
monkeypatch.setattr("gitea_codex_bot.workers.container_runner.subprocess.run", _fake_run)
|
||||
|
||||
from gitea_codex_bot.types import ParsedCommand
|
||||
|
||||
result, _repo_cfg = run_review_ephemeral(
|
||||
settings,
|
||||
repo="acme/repo",
|
||||
pr_number=1,
|
||||
command=ParsedCommand(name="review", raw="@codex review"),
|
||||
)
|
||||
|
||||
assert result["verdict"] == "correct"
|
||||
assert len(calls) == 2
|
||||
first_shell = calls[0][-1]
|
||||
second_shell = calls[1][-1]
|
||||
assert "--reasoning-effort" in first_shell
|
||||
assert "--reasoning-effort" not in second_shell
|
||||
|
||||
|
||||
def test_parse_codex_exec_stdout_from_stream_item_text_json() -> None:
|
||||
stdout = '\n'.join(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user