Skip to content

feat: add loop diagnostics CLI#449

Merged
PerishCode merged 2 commits into
mainfrom
codex/cli-observability-inspect
May 25, 2026
Merged

feat: add loop diagnostics CLI#449
PerishCode merged 2 commits into
mainfrom
codex/cli-observability-inspect

Conversation

@PerishCode
Copy link
Copy Markdown
Contributor

Summary

  • Add looper queue failed for failed queue-item inspection with type/project/limit filters.
  • Add looper loop inspect <seq|loopId|runId> and looper loop failures for structured loop diagnostics.
  • Allow looper logs <runId> by resolving the run id to its owning loop before calling the existing logs API.

Why

CLI-first巡检 showed that common reviewer failure questions required either raw SQLite queries or ad hoc parsing of metadataJson and daemon logs. The new commands expose the same persisted state through first-class CLI surfaces so operators can inspect failed work without depending on internal table shape.

Design notes

Authority: the diagnostic view is read-only and is based on persisted loop, run, queue-item, and agent-execution records. The failure classification is an operator-facing label only; it is not authority for scheduler, retry, publish, or recovery side effects.

New concept trade-off: the CLI adds a small heuristic failure classifier (github_transient, git_transient, agent_idle_timeout, pull_request_unresolved, etc.) so humans can triage failures quickly. Cost is another place where diagnostic wording can drift from retry internals, so the output includes the source message and keeps the recommendation advisory. The simpler alternative, continuing to parse raw metadataJson or SQLite tables, was rejected because it normalizes internal storage as the observability API.

Validation

  • HOME=/Users/zqxy123/.looper-test-home go test ./...
  • HOME=/Users/zqxy123/.looper-test-home go vet ./...
  • HOME=/Users/zqxy123/.looper-test-home go build ./...
  • go run ./cmd/looper loop --help
  • go run ./cmd/looper queue --help

@mrcfps mrcfps self-requested a review May 22, 2026 03:58
Copy link
Copy Markdown
Contributor

@mrcfps mrcfps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PerishCode Thanks for shipping the new diagnostics commands — I found one behavior mismatch in the new logs <runId> path that looks worth tightening up before operators lean on it heavily.

🔁 Powered by Looper · runner=reviewer · agent=opencode · An autonomous AI dev team for your GitHub repos.

Comment thread internal/cliapp/json_output.go Outdated

return r.outputCommand(cmd, func(ctx context.Context) (json.RawMessage, error) {
return r.getJSON(ctx, "/api/v1/loops/"+url.PathEscape(strings.TrimSpace(args[0]))+"/logs")
return r.getJSON(ctx, "/api/v1/loops/"+url.PathEscape(selector)+"/logs")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looper logs <runId> currently resolves the run ID to its loop ID and then still calls /api/v1/loops/{loop}/logs. That handler always loads Runs.GetLatestByLoopID(...) (internal/api/handler.go:4218), so once a loop has retried, looper logs <old-runId> will show the newest run's output instead of the run the operator selected. That makes historical failure triage misleading, especially now that the new diagnostics surfaces expose failed run IDs directly. Please either add a run-scoped logs path, or guard this shortcut so it only accepts a run ID when that run is still the loop's latest run.

🔁 Powered by Looper · runner=reviewer · agent=opencode · An autonomous AI dev team for your GitHub repos.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 123dee9: added run-scoped /api/v1/runs/{runID}/logs, changed non-follow run selectors to use it, and reject --follow for run IDs so historical logs cannot silently show the latest retry output.

Copy link
Copy Markdown
Contributor

@mrcfps mrcfps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PerishCode I re-reviewed the updated head and verified the new run-scoped logs route, the CLI diagnostics commands, and the added regression coverage for historical run selection and failure inspection. Thanks for tightening up the observability flow — this looks solid.

🔁 Powered by Looper · runner=reviewer · agent=opencode · An autonomous AI dev team for your GitHub repos.

@PerishCode PerishCode merged commit e28fda5 into main May 25, 2026
7 checks passed
@PerishCode PerishCode deleted the codex/cli-observability-inspect branch May 25, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants