Skip to content

#168 activity_writer: tolerate Codex notify's appended arg (parse_known_args)#169

Merged
AlvinShenSSW merged 1 commit into
mainfrom
afk/168-activity-writer-notify-args
Jul 3, 2026
Merged

#168 activity_writer: tolerate Codex notify's appended arg (parse_known_args)#169
AlvinShenSSW merged 1 commit into
mainfrom
afk/168-activity-writer-notify-args

Conversation

@AlvinShenSSW

Copy link
Copy Markdown
Owner

Closes #168.

Bug

The documented Codex integration wires notify to activity_writer.py --tool codex --path ... --state idle. Codex invokes its notify program with its event JSON appended as a trailing argv, which main()'s strict argparse.parse_args rejected (error: unrecognized arguments: {...} → exit 2, nothing written). So following the guide, Codex activity was never recorded — dev_activity saw Codex via process-presence only.

Fix

main() now uses parse_known_args — a fire-and-forget hook/notify shim must tolerate extra args and never break the host's chain. Trade-off (a mistyped flag is silently ignored) is acceptable and documented in a comment.

Changes

  • activity_writer.py: parse_argsparse_known_args (+ rationale comment).
  • tests/test_activity.py: regression test — main([... , '{"type":"agent-turn-complete"}']) returns 0 and writes the file.
  • docs/guides/dev-agent-activity.md: note that the writer ignores Codex's appended payload.

Tests

uv run --locked pytest green; uv lock --check, ruff, ruff format --check, mypy all clean.

Review trail (/afk)

Claude implement + TDD. External gates run automatically: Codex 外门 then Kimi 终审. Leave-open (owner merges).

…wn_args)

Codex invokes its `notify` program with the event JSON appended as a trailing
argv. activity_writer.main() used strict parse_args, which rejected it (exit 2 →
nothing written), so the documented Codex notify config recorded no state. Switch
to parse_known_args so the shim ignores extra args and never breaks the host's
notify/hook chain. Add a regression test for the appended-arg case; note it in the
guide.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AlvinShenSSW

Copy link
Copy Markdown
Owner Author

Review trail (/afk — Claude-driven)

  • Codex 外门: CLEAN — "correctly tolerates Codex notify's trailing event argument while preserving existing behavior; test covers the intended scenario; no introduced correctness issues."
  • Kimi 终审: VERDICT: PASS. No blocking/major. parse_known_args is the right API; the trade-off (a mistyped optional flag is silently ignored) is proportionate for a fire-and-forget shim whose contract is "never disrupt the host hook/notify chain." One optional informational nit (a test for an unknown flag) — not required; the core regression (trailing JSON argv) is covered.

CI green. Leave-open (owner merges).

@AlvinShenSSW AlvinShenSSW merged commit 9661415 into main Jul 3, 2026
7 checks passed
@AlvinShenSSW AlvinShenSSW deleted the afk/168-activity-writer-notify-args branch July 3, 2026 03:51
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.

activity_writer: Codex notify's appended JSON arg makes it argparse-error (writes nothing)

1 participant