Skip to content

feat(agent-watchdog): add --dump-job one-shot CLI lookup - #75

Merged
lklimek merged 1 commit into
mainfrom
docs/codex-monitoring-script
Jul 21, 2026
Merged

feat(agent-watchdog): add --dump-job one-shot CLI lookup#75
lklimek merged 1 commit into
mainfrom
docs/codex-monitoring-script

Conversation

@lklimek

@lklimek lklimek commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Why this PR exists

A user-level codex-monitoring skill had independently converged on the same doctrine as codex-crew's job-state monitoring, plus one genuine addition: a hand-rolled python3 -c "..." snippet to read a Codex job's full state file (result.rawOutput, result.touchedFiles, etc.) by id. Porting that as a raw doc snippet would have duplicated logic agent-watchdog.py already has tested (codex_state_root(), workspace resolution) — so instead it's now a real CLI feature on the script itself.

What changed

  • scripts/agent-watchdog.py: new --dump-job <job-id> one-shot mode. Searches every workspace's jobs/<job-id>.json directly (bypasses all team/session/ownership discovery — deliberately, since this is meant to work even when you don't know which team/session a job belongs to), prints the full record (id, status, phase, pid, startedAt, completedAt, errorMessage, result.rawOutput, result.touchedFiles) for every match, and exits without starting the persistent poll loop. Not-found and malformed-record cases exit 1 with a clear stderr message — no traceback.
  • tests/test_agent_watchdog.py: found-case, not-found-case, and malformed-file-case coverage for the new flag.
  • skills/codex-crew/references/sandbox-and-recovery.md: § On-Disk Job State now points at --dump-job instead of leaving the read as a hand-rolled snippet.
  • .claude-plugin/plugin.json / CHANGELOG.md: version bump 5.12.1 → 5.13.0 (minor — new CLI capability).

Test plan

  • python3 -m pytest tests/test_agent_watchdog.py -q — 91 passed (independently re-run by coordinator, not just Codex's self-report)
  • ruff check / ruff format --check — clean
  • Manual diff review of both changed files
  • Verified via the live job this feature was itself dispatched as (task-mrto0ofc-ojhhry) — resolved correctly via resolve_workspace()

🤖 Co-authored by Claudius the Magnificent — implementation by Codex Sol (gpt-5.6-sol, high effort), verified and committed by the coordinator.

Adds `--dump-job <job-id>` to scripts/agent-watchdog.py: searches every
workspace's jobs/<job-id>.json directly (no team/session/worktree setup
required), prints the full record including result.rawOutput/touchedFiles,
and exits without starting the persistent poll loop. Not-found and
malformed-record cases exit 1 with a clear stderr message, no traceback.

Ported from a doctrine gap identified in a user-level codex-monitoring
skill, which had converged on the same field list via a hand-rolled
python3 snippet. Replaces that copy-paste approach in
skills/codex-crew/references/sandbox-and-recovery.md with a pointer to
the new tested flag.

Co-Authored-By: Codex Sol <noreply@openai.com>
@lklimek
lklimek requested a review from Copilot July 21, 2026 09:09
@lklimek
lklimek marked this pull request as ready for review July 21, 2026 09:09

Copilot AI left a comment

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.

Pull request overview

Adds a one-shot CLI mode to scripts/agent-watchdog.py for dumping Codex job state by id, and updates docs/tests/versioning to make it a supported, reusable workflow in the Claudius plugin.

Changes:

  • Add --dump-job <job-id> to scripts/agent-watchdog.py to locate and print matching jobs/<id>.json records across workspaces, then exit.
  • Add pytest coverage for found / not-found / malformed job record cases.
  • Update codex-crew reference docs and bump plugin version + changelog.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/agent-watchdog.py Adds --dump-job one-shot mode and CLI parsing/dispatch.
tests/test_agent_watchdog.py Adds targeted tests ensuring dump mode output and clean error behavior.
skills/codex-crew/references/sandbox-and-recovery.md Replaces hand-rolled snippet with the new --dump-job workflow.
CHANGELOG.md Documents the new capability under 5.13.0.
.claude-plugin/plugin.json Bumps plugin version to 5.13.0 (minor).
Comments suppressed due to low confidence (1)

scripts/agent-watchdog.py:2116

  • The USAGE text says stdout contains only transition lines, but --dump-job intentionally prints job records to stdout. Adjust the help text so it remains accurate when --dump-job is used.
--dump-job ID prints every matching Codex job record once and exits.
--worktrees precedence: flag > $CLAUDIUS_WORKTREE_ROOT > .claude/worktrees.
--codex-job-recency-secs defaults to 604800 (7 days); older job files are not parsed.
Emits ONLY transition lines to stdout; diagnostics to stderr.
"""

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/agent-watchdog.py
Comment on lines +2216 to +2219
state_root = codex_state_root(env)
try:
matches = sorted(state_root.glob(f"*/jobs/{job_id}.json"))
except OSError as error:
Comment thread scripts/agent-watchdog.py
Comment on lines +2246 to +2257
try:
with path.open(encoding="utf-8") as handle:
record = json.load(handle)
if not isinstance(record, dict):
raise TypeError("expected a JSON object")
except (
OSError,
UnicodeError,
json.JSONDecodeError,
RecursionError,
TypeError,
) as error:
@lklimek
lklimek merged commit 0fe8291 into main Jul 21, 2026
3 checks passed
@lklimek
lklimek deleted the docs/codex-monitoring-script branch July 21, 2026 09:43
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.

3 participants