fix: truncate step summary to stay under GitHub's 1024k limit#1047
fix: truncate step summary to stay under GitHub's 1024k limit#1047sunnypatell wants to merge 2 commits intoanthropics:mainfrom
Conversation
- added truncateStepSummary() that checks byte size against GitHub's hard limit and cuts at the last section boundary (---) when possible - uses 1000k budget (not 1024k) to leave headroom for content from earlier steps in the same job - appends a truncation notice pointing users to display_report: false - handles multi-byte characters correctly via TextEncoder/TextDecoder - applied to both the formatted report and the raw JSON fallback path - added 5 tests covering: under-limit passthrough, over-limit truncation, section boundary cutting, multi-byte character safety, default limit fixes anthropics#927
There was a problem hiding this comment.
Pull request overview
Adds step-summary truncation to prevent GitHub Actions $GITHUB_STEP_SUMMARY size-limit issues when rendering large Claude Code reports.
Changes:
- Introduces
truncateStepSummary()to truncate markdown output to a byte budget and append a notice. - Applies truncation when writing both formatted and fallback (raw JSON) step summaries.
- Adds unit tests covering truncation behavior, section-boundary cutting, and multi-byte character handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/entrypoints/format-turns.ts |
Adds truncateStepSummary() and a default byte budget for step-summary output. |
src/entrypoints/run.ts |
Wraps step-summary writes with truncateStepSummary() to avoid oversize reports. |
test/format-turns.test.ts |
Adds tests validating truncation and UTF-8/multi-byte behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- guarded against budget going negative when maxBytes < notice size - added re-verification loop for multi-byte boundary edge cases where TextDecoder replacement chars could inflate encoded size - tightened section boundary test to assert Section 3 is excluded - renamed default limit test to reflect 1000k headroom, not 1024k - added edge case test for maxBytes smaller than notice
|
addressing copilot's 5 inline comments (3 fixed in d5b55ae, 2 intentionally kept as-is): fixed in d5b55ae:
intentionally not changed:
|
long Claude sessions (30+ min, many tool calls) generate step summary markdown that exceeds GitHub's hard 1024k limit for
$GITHUB_STEP_SUMMARY, causing:the error is non-fatal (Claude's work still succeeds), but it's noisy and prevents viewing the execution summary. users currently have to set
display_report: falseto avoid it entirely, losing the summary for all sessions.fixes #927
what changed
added
truncateStepSummary()informat-turns.tsthat:---) to avoid breaking mid-contentdisplay_report: falseTextEncoder/TextDecoder(no mid-codepoint cuts)applied in both the formatted report path and the raw JSON fallback path in
writeStepSummary().tests
5 new tests in
format-turns.test.ts:all 35 tests pass.