Skip to content

codex: base64-encode final_message to fix $GITHUB_OUTPUT framing - #525

Merged
max-sixty merged 1 commit into
mainfrom
codex-output-base64
May 16, 2026
Merged

max-sixty merged 1 commit into
mainfrom
codex-output-base64

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

codex exec --output-last-message writes the final-message file without a trailing newline. The previous $GITHUB_OUTPUT heredoc did cat "$OUTPUT_FILE" then echo "$DELIM", gluing the closing delimiter onto the last content line. The runner never saw ghadelimiter_… alone on a line and failed the step with Invalid value. Matching delimiter not found — turning every Codex run red even though the agent completed its work correctly. PR #521 randomized the delimiter (collision-proofing) but didn't fix this framing failure.

The fix replaces the heredoc with echo "final_message=$(base64 -w0 "$OUTPUT_FILE")" >> "$GITHUB_OUTPUT" — a single-line key=value assignment, no heredoc, no delimiter. Immune to both the missing trailing newline and to agent content that happens to contain the delimiter. base64 -w0 (GNU coreutils, present on Ubuntu runners) guarantees no line wrapping.

Scope is internal to codex/action.yaml. final_message is set there and exposed as an action output, but consumed nowhere — verified exhaustively: not in the generator, generated workflows, the Claude action.yaml (no analogous output), plugins, or skills. The output description now documents the base64 encoding (base64 -d to decode) for any future consumer.

This is the last known blocker for the Codex CI cutover (#520). A release + workflow regen is required before that re-test — follow-on, not part of this PR.

🤖 Generated with Claude Code

codex exec --output-last-message writes the file without a trailing
newline. The heredoc capture (echo "$DELIM" after cat) glued the
closing delimiter onto the last content line, so the runner never
saw the delimiter alone and failed the step with "Matching delimiter
not found", turning every Codex run red even when the agent's work
succeeded. PR #521's random delimiter addressed collisions but not
this framing failure.

base64 -w0 emits a single-line key=value with no heredoc — immune to
both the missing trailing newline and content collisions. No consumer
decodes this output yet (generator, generated workflows, Claude
action, plugins, skills all clear); the output description now
documents the encoding for future consumers.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 1016f6c into main May 16, 2026
6 checks passed
@max-sixty
max-sixty deleted the codex-output-base64 branch May 16, 2026 05:43
@max-sixty max-sixty mentioned this pull request May 16, 2026
3 tasks
max-sixty added a commit that referenced this pull request May 16, 2026
## Summary

Release 0.0.22 — the last known Codex-harness blocker.

3 commits since 0.0.21:
- #525 — base64-encode `final_message` so the agent's output can't break
the `$GITHUB_OUTPUT` heredoc (every Codex run was exiting red *after*
the agent succeeded)
- #528 — declare `CODEX_AUTH_JSON` in `secrets.allowed`
- #529 — Codex in package/CLI descriptions; fix stale `.toml` ref

## Test plan

- [ ] CI green (test, test-worker, lint)
- [ ] After merge: tag `0.0.22`, PyPI publish, `uvx [email protected] --help`
works
- [ ] Regenerate tend's own workflows to `@0.0.22`

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 16, 2026
0.0.22 carries #525 (base64-encoded final_message) which fixes the
$GITHUB_OUTPUT framing bug that turned every Codex run red after the
agent succeeded. Last known cutover blocker.

Co-Authored-By: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 16, 2026
Routine post-release regen. Pins the 8 `tend-*.yaml` workflows to
`max-sixty/[email protected]` (#525 base64 output fix). tend stays on the
Claude harness; only the pinned version changes.

## Test plan
- [ ] CI green (test, test-worker, lint)

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 16, 2026
## Summary

Flips tend's own CI from the Claude harness to the Codex harness by
setting `harness: codex` in `.config/tend.yaml` and regenerating the
eight `tend-*.yaml` workflows. Each now invokes
`max-sixty/tend/[email protected]` with `CODEX_AUTH_JSON` instead of
`max-sixty/tend@<v>` with `CLAUDE_CODE_OAUTH_TOKEN`.

Motivation is cost: API billing scales per token; a flat-rate ChatGPT
subscription funds unlimited runs. tend dogfoods its own setup, so it
should run the harness we recommend for cost-sensitive adopters.

The net diff is small — config (+ `harness: codex`, + `secrets.allowed:
[CODEX_AUTH_JSON]`) and the regenerated workflow files (action ref, auth
secret, model, skill-invocation syntax). Supporting infrastructure
landed separately on main:

- `codex-auth-refresh.yaml` + env-scoped `CODEX_REFRESH_PAT` rotation
(#500, #510)
- `CODEX_AUTH_JSON` as a repo secret, refresher writes it back at repo
scope (#514)
- Codex-on-GHA fixes, all in release 0.0.22: sandbox
`danger-full-access` (#519), npm prebuilt install (#522), base64
`final_message` capture (#525)

## Validation

The original "do not merge until…" prerequisite is **satisfied**:

- `tend-review-runs` `workflow_dispatch` on this branch (pinned
`[email protected]`) ran **green end-to-end** — codex authenticated,
installed via npm, ran without the `bwrap` block, executed the full
agent (real review-runs work: posted evidence to the tracking issue,
commented on the outage issue), and the action exited 0.
- Deterministic CI (`test`, `test-worker`, `lint`) green; `tend-review`
(Claude harness via `pull_request_target`) approved.

Each codex blocker found during stabilization was fixed and released:
auth scoping → sandbox → install → output framing. The smoke test going
green on 0.0.22 confirms convergence.

## Post-merge follow-up

Watch the first unattended nightly `codex-auth-refresh` cron (`17 3 * *
*`) succeed. Manual dispatches (incl. the post-#514 recovery) have all
succeeded; this just confirms the scheduled path runs without a human.
Failure degrades gracefully over the ~8-day refresh window, with manual
rotation as fallback.

---------

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 16, 2026
## Summary

Flips tend's own CI from the Claude harness to the Codex harness by
setting `harness: codex` in `.config/tend.yaml` and regenerating the
eight `tend-*.yaml` workflows. Each now invokes
`max-sixty/tend/[email protected]` with `CODEX_AUTH_JSON` instead of
`max-sixty/tend@<v>` with `CLAUDE_CODE_OAUTH_TOKEN`.

Motivation is cost: API billing scales per token; a flat-rate ChatGPT
subscription funds unlimited runs. tend dogfoods its own setup, so it
should run the harness we recommend for cost-sensitive adopters.

The net diff is small — config (+ `harness: codex`, + `secrets.allowed:
[CODEX_AUTH_JSON]`) and the regenerated workflow files (action ref, auth
secret, model, skill-invocation syntax). Supporting infrastructure
landed separately on main:

- `codex-auth-refresh.yaml` + env-scoped `CODEX_REFRESH_PAT` rotation
(#500, #510)
- `CODEX_AUTH_JSON` as a repo secret, refresher writes it back at repo
scope (#514)
- Codex-on-GHA fixes, all in release 0.0.22: sandbox
`danger-full-access` (#519), npm prebuilt install (#522), base64
`final_message` capture (#525)

## Validation

The original "do not merge until…" prerequisite is **satisfied**:

- `tend-review-runs` `workflow_dispatch` on this branch (pinned
`[email protected]`) ran **green end-to-end** — codex authenticated,
installed via npm, ran without the `bwrap` block, executed the full
agent (real review-runs work: posted evidence to the tracking issue,
commented on the outage issue), and the action exited 0.
- Deterministic CI (`test`, `test-worker`, `lint`) green; `tend-review`
(Claude harness via `pull_request_target`) approved.

Each codex blocker found during stabilization was fixed and released:
auth scoping → sandbox → install → output framing. The smoke test going
green on 0.0.22 confirms convergence.

## Post-merge follow-up

Watch the first unattended nightly `codex-auth-refresh` cron (`17 3 * *
*`) succeed. Manual dispatches (incl. the post-#514 recovery) have all
succeeded; this just confirms the scheduled path runs without a human.
Failure degrades gracefully over the ~8-day refresh window, with manual
rotation as fallback.

---------

Co-authored-by: Claude <[email protected]>
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