aws-samples / aws-samples/sample-autonomous-cloud-coding-agents

fix(agent): unrunnable pipeline.buildCommand kills the task pre-agent while a build timeout degrades gracefully

Aperta
#750 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
146
Fork
46
Merge medio
3g 10h
PR unite (30g)
24

Descrizione

### Component

Agent (Python runtime)

### Describe the bug

A `pipeline.buildCommand` whose executable does not exist in the agent container raises `FileNotFoundError` out of the pre-agent baseline build and **kills the task before the agent ever runs**. The surrounding code goes to considerable lengths to handle the analogous timeout case gracefully, so this looks like an oversight rather than a deliberate choice.

`agent/src/repo.py:457-473`:

```python
try:
result = run_cmd(build_argv, label="verify-build-pre", ..., timeout=BUILD_VERIFY_TIMEOUT_S, stream=True)
except subprocess.TimeoutExpired:
log("WARN", f"Initial build ({build_cmd_str}) did not finish within ... skipping baseline (not a regression)")
```

The comment above that block explains the reasoning for the timeout path at length — *"a timeout means 'no usable baseline', NOT 'the agent broke it', so we treat it as no-known-regression and let the run proceed"* — and notes that without the guard the task would "crash the whole task BEFORE the agent ever ran, so the issue got no PR and sat in Backlog — indistinguishable from a real failure."

A missing binary produces exactly that outcome, because only `TimeoutExpired` is caught.

### Expected behavior

An unrunnable build command should be treated the same way as a timeout: log a warning, record "no usable baseline", and let the agent run. The misconfiguration should be surfaced on the PR (and ideally as an inert-gate note), not converted into a task failure.

### Current behavior

The task dies during hydration with `build_passed=null` and no PR. Observed on task `01KZS2MS1BG7TDXHR7CDNMYM0A`:

```
status = FAILED
build_passed = null
error_message = FileNotFoundError: [Errno 2] No such file or directory: 'pytest'
```

Total time to failure: ~20 seconds. The agent never started, so a single typo in a blueprint's `buildCommand` bricks every task against that repo until someone redeploys.

### Reproduction steps

1. Onboard a repo with a `pipeline.buildCommand` naming a binary not present in the agent image, e.g. `buildCommand: 'pytest tests/unit/'` (the agent container's `PATH` leads with `/app/.venv/bin`, built `uv sync --frozen --no-dev` per `agent/Dockerfile:104`, so there is no `pytest`).
2. Submit any coding task against that repo.
3. Task fails in ~20s at hydration with the `FileNotFoundError` above; no PR, no agent turns.

### Possible solution

Catch `FileNotFoundError` (and likely `PermissionError`/`NotADirectoryError`) alongside `subprocess.TimeoutExpired` in both the pre-agent baseline (`agent/src/repo.py:457`) and the post-agent gate (`agent/src/post_hooks.py:187`), mapping them onto the existing inert-gate path rather than a task failure — an unrunnable command verified nothing, which is the definition of inert already handled elsewhere in `pipeline.py:1435-1441`.

Arguably a misconfigured blueprint should also surface a distinct, non-retryable error classification so the operator knows to fix the blueprint rather than retry.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la gestione esistente di TimeoutExpired in agent/src/repo.py:457-473 e confrontala con il gate post-agent in agent/src/post_hooks.py:187. Esamina il comportamento del gate inerte in pipeline.py:1435-1441, quindi verifica che un eseguibile di build non disponibile venga registrato come privo di una baseline utilizzabile, consenta all’agente di essere eseguito e venga riportato nella PR invece di far fallire il task.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
75/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.