agent headless: reservation check should gate before the LLM pre-flight, not after #184

Closed
opened 2026-06-18 09:31:34 +00:00 by coilyco-ops · 3 comments
Member

Summary

ward agent <name> headless runs the LLM pre-flight GO/NO-GO read before it checks the two-sided issue reservation. When an issue is already reserved (locally or remotely), ward still burns a full pre-flight (up to the 3-minute preflightTimeout) on goose/the model before bailing at the reservation gate. The reservation check is cheap and authoritative; it should gate before runPreflight.

Observed

Dispatched ward agent goose headless on coilyco-bridge/agentic-os-kai#686. The issue was already reserved remotely by @coilyco-ops at 2026-06-18T09:26:15Z. Sequence observed:

  1. ssm fetch failed / error getting credentials -> registry pull failed -> fell back to local image (graceful, unrelated).
  2. Pre-flight ran: goose evaluated the full issue + thread and answered GO.
  3. Reservation check then failed: issue coilyco-bridge/agentic-os-kai#686 is already reserved remotely (by @coilyco-ops at 2026-06-18T09:26:15Z); wait for it to finish or pass --force to override.

So a full model pre-flight was spent on an issue ward could already have known was claimed.

Root cause

In cmd/ward/agent.go runAgentWork:

  • runPreflight is called at agent.go:308.
  • The container launch (launchAgentContainer -> reserveIssue, agent.go:727) only happens at agent.go:318.

The remote reservation marker is fetched during launch, after the pre-flight has already run.

Proposed fix

Move (or duplicate) the remote-reservation precheck ahead of runPreflight so an already-reserved issue short-circuits before any model read. --force should still bypass it. Keep the full reserveIssue (which also acquires the local file sentinel and posts the marker) where it is for the actual hold; this is just an early cheap gate to avoid wasting a pre-flight.

Secondary note (separate, probably transient)

The ssm fetch failed / error getting credentials - err: exit status 1 before the image pull is worth a glance - the registry-cred SSM lookup failed and ward silently fell back to the local image. Fine as degradation, but if creds are expected it may mask a stale local image. Split out if it is a real problem.

## Summary `ward agent <name> headless` runs the LLM pre-flight GO/NO-GO read *before* it checks the two-sided issue reservation. When an issue is already reserved (locally or remotely), ward still burns a full pre-flight (up to the 3-minute `preflightTimeout`) on goose/the model before bailing at the reservation gate. The reservation check is cheap and authoritative; it should gate *before* `runPreflight`. ## Observed Dispatched `ward agent goose headless` on `coilyco-bridge/agentic-os-kai#686`. The issue was already reserved remotely by `@coilyco-ops` at `2026-06-18T09:26:15Z`. Sequence observed: 1. `ssm fetch failed` / `error getting credentials` -> registry pull failed -> fell back to local image (graceful, unrelated). 2. Pre-flight ran: goose evaluated the full issue + thread and answered `GO`. 3. Reservation check then failed: `issue coilyco-bridge/agentic-os-kai#686 is already reserved remotely (by @coilyco-ops at 2026-06-18T09:26:15Z); wait for it to finish or pass --force to override`. So a full model pre-flight was spent on an issue ward could already have known was claimed. ## Root cause In `cmd/ward/agent.go` `runAgentWork`: - `runPreflight` is called at agent.go:308. - The container launch (`launchAgentContainer` -> `reserveIssue`, agent.go:727) only happens at agent.go:318. The remote reservation marker is fetched during launch, after the pre-flight has already run. ## Proposed fix Move (or duplicate) the remote-reservation precheck ahead of `runPreflight` so an already-reserved issue short-circuits before any model read. `--force` should still bypass it. Keep the full `reserveIssue` (which also acquires the local file sentinel and posts the marker) where it is for the actual hold; this is just an early cheap gate to avoid wasting a pre-flight. ## Secondary note (separate, probably transient) The `ssm fetch failed` / `error getting credentials - err: exit status 1` before the image pull is worth a glance - the registry-cred SSM lookup failed and ward silently fell back to the local image. Fine as degradation, but if creds are expected it may mask a stale local image. Split out if it is a real problem.
Author
Member

🔒 Reserved by ward agent codex — container ward-ward-issue-184-codex-bacc9b2c on host kais-macbook-pro.local is carrying this issue (reserved 2026-06-18T09:32:16Z). Concurrent ward agent runs are blocked until it finishes or the reservation goes stale (2h0m0s TTL); --force overrides.

— Codex, via ward agent

<!-- ward-agent-reservation --> 🔒 Reserved by `ward agent codex` — container `ward-ward-issue-184-codex-bacc9b2c` on host `kais-macbook-pro.local` is carrying this issue (reserved 2026-06-18T09:32:16Z). Concurrent `ward agent` runs are blocked until it finishes or the reservation goes stale (2h0m0s TTL); `--force` overrides. <!-- ward-agent-signature --> — Codex, via `ward agent`
Author
Member

🔒 Reserved by ward agent codex — container ward-ward-issue-184-codex-1c8b3285 on host kais-macbook-pro.local is carrying this issue (reserved 2026-06-18T09:33:13Z). Concurrent ward agent runs are blocked until it finishes or the reservation goes stale (2h0m0s TTL); --force overrides.

— Codex, via ward agent

<!-- ward-agent-reservation --> 🔒 Reserved by `ward agent codex` — container `ward-ward-issue-184-codex-1c8b3285` on host `kais-macbook-pro.local` is carrying this issue (reserved 2026-06-18T09:33:13Z). Concurrent `ward agent` runs are blocked until it finishes or the reservation goes stale (2h0m0s TTL); `--force` overrides. <!-- ward-agent-signature --> — Codex, via `ward agent`
Author
Member

🔒 Reserved by ward agent claude — container ward-ward-issue-184-claude-9a87360a on host kais-macbook-pro.local is carrying this issue (reserved 2026-06-18T09:33:42Z). Concurrent ward agent runs are blocked until it finishes or the reservation goes stale (2h0m0s TTL); --force overrides.

— Claude (she/her), via ward agent

<!-- ward-agent-reservation --> 🔒 Reserved by `ward agent claude` — container `ward-ward-issue-184-claude-9a87360a` on host `kais-macbook-pro.local` is carrying this issue (reserved 2026-06-18T09:33:42Z). Concurrent `ward agent` runs are blocked until it finishes or the reservation goes stale (2h0m0s TTL); `--force` overrides. <!-- ward-agent-signature --> — Claude (she/her), via `ward agent`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
coilyco-flight-deck/ward#184
No description provided.