From 9cc8055020e79418067f5f90662e88b99c08db90 Mon Sep 17 00:00:00 2001 From: Gahow Wang Date: Wed, 6 May 2026 15:47:15 +0800 Subject: [PATCH] fix: feed Codex prompts through stdin --- config.example.yaml | 6 ++---- config.yaml | 6 ++---- src/agent_gitea/agents.py | 4 ++-- src/agent_gitea/service.py | 4 ++-- tests/conftest.py | 4 ++-- tests/test_gitea_service.py | 7 ++++--- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/config.example.yaml b/config.example.yaml index e585e4f..a018079 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -21,8 +21,7 @@ agents: - "--dangerously-bypass-approvals-and-sandbox" - "--cd" - "{workspace_path}" - - "--prompt-file" - - "{prompt_path}" + - "-" reviewer: command: - "codex" @@ -30,8 +29,7 @@ agents: - "--dangerously-bypass-approvals-and-sandbox" - "--cd" - "{workspace_path}" - - "--prompt-file" - - "{prompt_path}" + - "-" labels: ready: "agent:ready" diff --git a/config.yaml b/config.yaml index e585e4f..a018079 100644 --- a/config.yaml +++ b/config.yaml @@ -21,8 +21,7 @@ agents: - "--dangerously-bypass-approvals-and-sandbox" - "--cd" - "{workspace_path}" - - "--prompt-file" - - "{prompt_path}" + - "-" reviewer: command: - "codex" @@ -30,8 +29,7 @@ agents: - "--dangerously-bypass-approvals-and-sandbox" - "--cd" - "{workspace_path}" - - "--prompt-file" - - "{prompt_path}" + - "-" labels: ready: "agent:ready" diff --git a/src/agent_gitea/agents.py b/src/agent_gitea/agents.py index eb05e90..1f4539d 100644 --- a/src/agent_gitea/agents.py +++ b/src/agent_gitea/agents.py @@ -7,8 +7,8 @@ from .models import AgentResult class CommandRunner: - def run(self, command: list[str], cwd: str | Path) -> AgentResult: - result = subprocess.run(command, cwd=cwd, text=True, capture_output=True, check=False) + def run(self, command: list[str], cwd: str | Path, *, stdin: str | None = None) -> AgentResult: + result = subprocess.run(command, cwd=cwd, input=stdin, text=True, capture_output=True, check=False) return AgentResult(exit_code=result.returncode, stdout=result.stdout, stderr=result.stderr) diff --git a/src/agent_gitea/service.py b/src/agent_gitea/service.py index e21fe47..4c55bd6 100644 --- a/src/agent_gitea/service.py +++ b/src/agent_gitea/service.py @@ -201,7 +201,7 @@ class TaskRunner: issue_title=issue.title, branch_name=branch_name, ) - result = self.command_runner.run(command, workspace) + result = self.command_runner.run(command, workspace, stdin=prompt) report = read_report(workspace / "AGENT_IMPLEMENTATION_REPORT.md") self.db.add_agent_run( task_id=task.id, @@ -236,7 +236,7 @@ class TaskRunner: issue_title=issue.title, pr_number=pr_number, ) - result = self.command_runner.run(command, workspace) + result = self.command_runner.run(command, workspace, stdin=prompt) report = read_report(workspace / "AGENT_REVIEW_REPORT.md") self.db.add_agent_run( task_id=task.id, diff --git a/tests/conftest.py b/tests/conftest.py index a8cf4b4..df3f412 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,8 +15,8 @@ def make_config(tmp_path: Path, **overrides: object) -> AppConfig: "scheduler": {"interval_seconds": 1, "concurrency": 1, "lease_seconds": 60}, "workspace": {"root": tmp_path / "workspaces", "cleanup_on_success": False}, "agents": { - "implementer": {"command": ["implementer", "{prompt_path}"]}, - "reviewer": {"command": ["reviewer", "{prompt_path}"]}, + "implementer": {"command": ["implementer", "-"]}, + "reviewer": {"command": ["reviewer", "-"]}, }, } data.update(overrides) diff --git a/tests/test_gitea_service.py b/tests/test_gitea_service.py index e580723..3552cf7 100644 --- a/tests/test_gitea_service.py +++ b/tests/test_gitea_service.py @@ -18,8 +18,8 @@ def make_config(tmp_path: Path, **overrides: object) -> AppConfig: "scheduler": {"interval_seconds": 1, "concurrency": 1, "lease_seconds": 60}, "workspace": {"root": tmp_path / "workspaces", "cleanup_on_success": False}, "agents": { - "implementer": {"command": ["implementer", "{prompt_path}"]}, - "reviewer": {"command": ["reviewer", "{prompt_path}"]}, + "implementer": {"command": ["implementer", "-"]}, + "reviewer": {"command": ["reviewer", "-"]}, }, } data.update(overrides) @@ -144,8 +144,9 @@ class FakeRunner: def __init__(self, *, fail_role: str | None = None): self.fail_role = fail_role - def run(self, command, cwd): + def run(self, command, cwd, *, stdin=None): role = command[0] + assert stdin if role == self.fail_role: return AgentResult(exit_code=1, stdout="", stderr="failed") if role == "implementer":