Skip to content

fix(flows): cap generated PR and comment bodies under GitHub's 65,536-character limit - #161

Merged
khaliqgant merged 10 commits into
mainfrom
fix/160-pr-body-cap
Oct 8, 2026
Merged

khaliqgant merged 10 commits into
mainfrom
fix/160-pr-body-cap

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Fixes #160

Garden run 80faae32 (AgentWorkforce/flows#494) did its work, then lost its pull request to Body is too long (maximum is 65536 characters). Nothing in web/lib/flow-workflows.ts bounded summary.md plus the check report.

What changed

Every body the generated flow posts now stays within the new FLOW_BODY_LIMIT, set to 60,000 bytes. A byte is at most one character, so this also keeps the character count under 60,000.

A shared POSIX helper, relayflow_cap <file> <bytes> head|tail <where>, does the cutting:

  • It cuts at a line boundary, or at a UTF-8 character boundary when the kept part has no line break, so a one-line file keeps what fits.
  • It shows the kept start as plain text in a code block. The fence is one longer than any backtick run in the text, so no fence, comment, <details> or code span left open by the cut can hide what follows.
  • It marks the cut with …truncated to fit GitHub's limit … The full text is <where>. The cut text is never printed, because logs can hold credentials.
  • It measures the result and tries again if it ran over, so the output never exceeds its bound.

Where the cap applies:

  • PR body (FLOW_CHECK_REPORT_COMMAND): the check script is capped at 4 KB, each log at 10 KB (keeping the tail, where the failure is), and the repair notes at 4 KB. summary.md gets what is left. Two amounts come off before that: the real length of the closing reference, and FLOW_WITHHELD_NOTICE_RESERVE (2 KB), so the push step always has room to say it withheld workflow edits. The verdict is never cut.
  • Closing reference (FLOW_PREPARE_CHANGE_METADATA_COMMAND and validation): an over-long body is capped and a Fixes #N line the cut removed is put back at the end. A reference over FLOW_REFERENCE_LIMIT (1 KB) is refused as reference-too-long before anything is pushed.
  • Comments: review-blocked.md and time-stop.md are capped. The withheld-workflow section is capped as a whole against the room left in the body.

Tests (red, then green)

New block in flow-workflows.test.ts (agentrelay.com#160), plus additions to the push-guard and onboarding tests:

  • Inputs totalling more than 65,536 characters produce a body within the cap and the reserve, with valid UTF-8. The body keeps the summary, the verdict, exactly one Fixes #160 line and the tail of each log, and passes validation.
  • Bodies are rendered with micromark (GFM, raw HTML allowed, as GitHub does). The report and Fixes stay visible when the cut leaves any of these open:
    • a backtick, tilde or indented fence;
    • an HTML comment, including one after inline code or in uneven backticks;
    • a multi-line code span;
    • <details>;
    • CRLF line endings;
    • an invalid backtick fence;
    • a 5,000-backtick fence.
  • Other cases:
    • a one-line summary keeps what fits;
    • a 1 KB reference keeps the whole report, and a longer one stops the generated flow at needs_human with no push and no PR;
    • a near-full body with 50 long workflow paths stays within the cap, and the withheld notice survives a full body;
    • the review-blocked and time-stop comments are capped.

The full web suite passes (456 tests), as do tsc --noEmit and npm run verify:recommended-flows; the shell is also exercised under gawk --posix. micromark and micromark-extension-gfm are added as web devDependencies at the versions already in the lockfile.

🤖 Generated with Claude Code


Note

Medium Risk
Changes shell logic on the publish path (PR body assembly, push guard, comments) where mistakes could truncate content or block valid PRs, but behavior is heavily tested and fail-closed on over-long references.

Overview
Fixes #160 by bounding every body the generated Relayflow posts (PR bodies, review/time-stop comments, withheld-workflow sections) under FLOW_BODY_LIMIT (60,000 bytes), with FLOW_WITHHELD_NOTICE_RESERVE left for the push step and FLOW_REFERENCE_LIMIT rejecting oversized closing lines before push.

A shared POSIX relayflow_cap / relayflow_block pair truncates at line or UTF-8 boundaries, fences kept text so open Markdown/HTML cannot hide the check report or Fixes #N, omits cut log text from output, and re-appends the closing reference after caps. FLOW_CHECK_REPORT_COMMAND now caps script/logs/repair sections, sizes summary.md to remaining room (accounting for reference), and embeds check output via safe fences; metadata prepare/validate and the generated factory flow pass reference through those steps.

Tests add micromark-based rendering checks, push-guard near-full-body cases, and onboarding reference-too-long → needs_human without push/PR.

Reviewed by Cursor Bugbot for commit 6b9979b. Bugbot is set up for automated code reviews on this repo. Configure here.

…-character limit (#160)

Garden run 80faae32 lost its pull request after 92 minutes to "Body is too
long (maximum is 65536 characters)": nothing bounded summary.md plus the
check report. Every body the generated flow posts now stays within
FLOW_BODY_LIMIT (60,000 bytes, which bounds the characters too):

- the check report cuts the script, each log (keeping its tail) and the
  repair notes to fixed section limits; summary.md gets what is left. The
  verdict is never cut, and an open code fence is closed;
- the metadata step caps an over-long body and puts back a closing
  reference (Fixes #N) the cut removed, so it always survives;
- the unresolved-review and time-stop comments are capped, and the
  withheld-workflow section's room is measured against the same limit.

Cut text goes to the step's stderr, so the run journal keeps it, and the
body says where the full text is.

Fixes #160

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T12:08:29.404087Z 6b9979b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aaf7bbe3-874b-450c-995c-4652ad58af72
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 4 potential issues.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment thread web/lib/flow-workflows.ts
Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts Outdated
…nce, keep one-line text, print no cut text

Review on #161:
- the withheld-workflow section is capped as a whole against the body's
  remaining room, so 50 long paths cannot overflow a near-full body;
- the check report is told the closing reference and leaves room for its
  real length, so a long ticket URL never cuts the report;
- relayflow_cap keeps what fits of a one-line file, cut at a UTF-8
  character boundary, and closes an open fence with a matching fence;
- cut text is no longer printed to stderr: a log or review can hold
  credentials the run journal must not show.

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread web/lib/flow-workflows.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployed!

Environment URL
Web https://0e7e73a1-agentrelay-web.agent-workforce.workers.dev

This is a Cloudflare Workers preview version of this PR's build.

…osing fence

Review on #161:
- the prepared pull-request body stays FLOW_WITHHELD_NOTICE_RESERVE (2 KB)
  under FLOW_BODY_LIMIT, so the push step can always say it withheld
  workflow edits, however full the body is;
- relayflow_cap measures its result and, when a closing fence as long as
  an agent's opening one ran over, keeps less and tries again (three tries,
  then empty), so the result never exceeds its bound.

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca8431cb17

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/lib/flow-workflows.ts
@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d07e85b250

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/lib/flow-workflows.ts Outdated
Review on #161: relayflow_cap recognised only backtick fences, so a summary
cut inside a ~~~ block left the report rendering as code. Tilde fences are
now tracked too, and a fence closes only with the same character, at least
as long.

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05
@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 246fc8d0b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts Outdated
Review on #161:
- the closer awk also tracks HTML comments outside code blocks, so a
  summary cut inside <!-- ... --> cannot hide the report after it;
- a closing reference over FLOW_REFERENCE_LIMIT (1,024 bytes) is never
  appended, and the validation step, now given the reference, refuses it
  (reference-too-long) before anything is pushed.

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05
@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d53840f72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/lib/flow-workflows.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread web/lib/test/flow-workflows.test.ts
Comment thread web/lib/test/flow-workflows.test.ts Outdated
…ce stop end to end

Review on #161:
- the closer awk treats a fence as one only when indented at most three
  spaces (GFM); four spaces or a tab is an indented code line;
- the generated flow is run with the real validation command: a runaway
  closing reference stops at needs_human before any push or pull request,
  and an ordinary one publishes;
- the long-reference tests derive their boundary from the prefix.

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05
@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 494079b52c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts Outdated
…k fences

Review on #161: the closer awk now skips `<!--` inside inline code spans,
and does not treat a backtick fence whose info string holds a backtick as
an opener (GFM does not). Restructured so an opener records its fence and a
closer must be the same character, at least as long, with only whitespace
after it.

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05
@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread web/lib/flow-workflows.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9bc1717e44

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread web/lib/flow-workflows.ts Outdated
Review on #161 kept finding Markdown constructs the closer awk could not
track (uneven inline-code delimiters, multi-line code spans, CRLF, open
<details>). Parsing Markdown in awk does not converge, so relayflow_cap no
longer tries: the kept start of a cut is shown in a code block whose fence
is longer than any backtick run in it. Nothing inside can be interpreted,
so no construct the cut leaves open can hide the check verdict or the
closing reference after it.

The tests render each body with micromark (GFM, raw HTML allowed, as
GitHub does) and assert the report heading and Fixes line are visible for
every construct the review raised. micromark and micromark-extension-gfm
become web devDependencies at the versions already in the lockfile.

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05
@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0ba544be5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/lib/flow-workflows.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f0ba544. Configure here.

Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/flow-workflows.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files (changes from recent commits).

    const html = micromark(body, { extensions: [gfm()], htmlExtensions: [gfmHtml()], allowDangerousHtml: true });
```</violation>
</file>
    const html = micromark(body, { extensions: [gfm()], htmlExtensions: [gfmHtml()], allowDangerousHtml: true });
```</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread web/lib/flow-workflows.ts Outdated
Comment thread web/lib/test/flow-workflows.test.ts Outdated
… blocks to fit

Review on #161:
- a cut summary (and the last-resort cap of a whole body) is shown as
  code, where a closing reference does nothing, so the reference is taken
  out first and appended after the report, exactly once;
- the report's script and log blocks use relayflow_block, a fence longer
  than any backtick run inside, so a cut script's own fence, or a fence in
  check output, can no longer end the block early;
- the tests render with raw HTML allowed throughout, as GitHub does.

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05
@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread web/lib/test/flow-workflows.test.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 22d74d8f54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Session-Id: 27d4ebe3-2e2f-461e-849f-1bd9727cfc05
@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 6b9979bfdb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@khaliqgant
khaliqgant merged commit 63e2928 into main Oct 8, 2026
5 checks passed
@khaliqgant
khaliqgant deleted the fix/160-pr-body-cap branch October 8, 2026 12:26
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.

Generated flows lose their PR when the body exceeds GitHub's 65,536-character limit

1 participant