Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/cli_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,27 @@ def run_agent_for_messages(model, messages):
)
cwd = os.path.abspath(os.getcwd())
command = build_agent_command(model=model, prompt=prompt, cwd=cwd)
# Agent CLIs write the final response to stdout and diagnostics/transcripts
# to stderr; keep them separate so echoed JSON never reaches the parser.
result = subprocess.run(
command.argv,
input=command.stdin,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stderr=subprocess.PIPE,
text=True,
encoding="utf-8",
errors="replace",
timeout=1800,
check=False,
)
if result.returncode != 0:
output = (result.stdout or "")[-4000:]
output = "\n".join(
part.strip()
for part in (result.stdout or "", result.stderr or "")
if part.strip()
)[-4000:]
raise RuntimeError(
f"{command.backend} exited with code {result.returncode}: {output}"
)
return result.stdout.strip(), {}
return (result.stdout or "").strip(), {}