Skip to content

fix(github-copilot): Lower problem_statement truncation limit#110600

Merged
JoshFerge merged 2 commits intomasterfrom
jferg/fix-copilot-prompt-truncation
Mar 13, 2026
Merged

fix(github-copilot): Lower problem_statement truncation limit#110600
JoshFerge merged 2 commits intomasterfrom
jferg/fix-copilot-prompt-truncation

Conversation

@JoshFerge
Copy link
Member

@JoshFerge JoshFerge commented Mar 12, 2026

GitHub Copilot's API rejects problem_statement values exceeding 30,000 characters. The previous truncation at 29,900 raw characters was too close to the limit — JSON encoding expansion (e.g. \n, \", \\) could push the serialized length over 30,000.

Lowers the limit to 25,000 characters to leave headroom for encoding expansion.

Fixes SENTRY-5M31

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 12, 2026
@JoshFerge JoshFerge changed the title fix(github-copilot): Truncate problem_statement based on JSON-encoded length fix(github-copilot): Simplify prompt truncation for problem_statement Mar 13, 2026
@JoshFerge JoshFerge marked this pull request as ready for review March 13, 2026 15:15
@JoshFerge JoshFerge requested review from a team as code owners March 13, 2026 15:15
@JoshFerge JoshFerge changed the title fix(github-copilot): Simplify prompt truncation for problem_statement fix(github-copilot): Lower problem_statement truncation limit Mar 13, 2026
… length

The existing truncation used Python string length (29,900 chars), but
GitHub Copilot's 30,000 character limit is on the JSON-serialized value.
Characters like \n, \", and \\ expand during JSON encoding, so prompts
with heavy escaping (e.g. minified JS stack traces) could exceed the
limit even after truncation. Now measures the actual JSON-encoded length
and scales the raw string proportionally.

Agent transcript: https://claudescope.sentry.dev/share/amHLtSlX7RtQwj_2G1233fd_LCxUpJR7WWMPcbEVQAU
…limit

Replace json.dumps-based encoded length measurement with a simple
25,000 character limit. This provides sufficient headroom below the
30,000 char API limit to account for JSON encoding expansion, without
the complexity of proportional scaling and iterative trimming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/eZU4taoDKUIFtUzcHX_iwlQF2EWijOK4cifRNJ9ZOGU
@JoshFerge JoshFerge merged commit 070c503 into master Mar 13, 2026
57 checks passed
@JoshFerge JoshFerge deleted the jferg/fix-copilot-prompt-truncation branch March 13, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants