Skip to content

fix(coding-agent): a review round is never refused for its length (TASK-901) - #935

Merged
yalexx merged 1 commit into
betafrom
clawbox/run-46idd916
Sep 19, 2026
Merged

yalexx merged 1 commit into
betafrom
clawbox/run-46idd916

Conversation

@yalexx

@yalexx yalexx commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

What broke (TASK-901)

On 2026-09-18 run-q3tjkwm3 (TASK-899) opened PR #926, and the box could not start its review round:

Could not start a review round: The task is too long: at most 4000 characters.

The pull request was handed back needs_owner with its pr phase blocked, and no round was spent on it.

Why

startRun ran every task through normalizeTask, which refuses anything over MAX_TASK_CHARS (4 000). That limit was meant for what a person types, but it also applied to the follow-ups the box writes itself.

A review-loop round's task comes from buildReviewFeedback (src/lib/coding-review-state.ts). It quotes GitHub's failing-check logs (up to 5 Γ— 2 000 chars) and unresolved review threads (up to 20 Γ— 1 000 chars), and is capped at MAX_FEEDBACK_CHARS = 24 000. So any PR with a few CodeRabbit comments produced a round that startRun refused. PR #926 had 4 review threads totalling 17 385 characters (measured with gh api .../pulls/926/comments).

The round does not embed the original task text. It resumes the session that holds that task and names the pull request, branch and base. So there was nothing to truncate or summarise there. The run id is already how the original task is referenced.

The fix

  • MAX_TASK_CHARS still applies, unchanged, to typed tasks (owner or assistant): startRun, createDraftRun, the /run and /draft routes and the MCP tool schema.
  • Tasks the box writes itself are exempt: the automatic review pass (reviewOf), a review-loop round (reviewLoopOf) and a Vercel deploy-fix turn (vercelFixOf). No route passes those fields through from a request body, so a typed task can't claim the exemption.
  • Those tasks have their own ceiling instead, MAX_BOX_TASK_CHARS = 32 000. That is above anything the builders produce today (review feedback ≀ 24 014). A task over it is clipped, ending in \n…(truncated), and never refused. The length of a task the box wrote is never the reason a follow-up fails to start.

The task text goes to the harness on stdin, and the MCP layer only shows its first line, so a longer task needed nothing else downstream. Team planner, worker and reviewer tasks already trim themselves to MAX_TASK_CHARS and are left as they were.

Tests

  • coding-review-loop.test.ts β€Ί a round longer than the owner's task limit:
    • A completed run with a 6 000-character primary task. Its PR has a failing check (2 000-char log), CHANGES_REQUESTED, and four review threads at the parser's full 1 000 characters each.
    • The round starts: round 1, fixMode: "resumed", the fix run completes and the loop reaches clean.
    • The round's task is longer than MAX_TASK_CHARS and contains every thread and the check log, with nothing truncated. It does not re-embed the primary task.
    • With the fix reverted, the same test ends in needs_owner, which is the incident.
  • The same block pins the worst-case buildReviewFeedback output (every cap overrun) and a 200-file reviewPassTask under MAX_BOX_TASK_CHARS.
  • coding-agent.test.ts: a typed continuation over 4 000 characters is still refused invalid. A box-written round over MAX_BOX_TASK_CHARS starts, clipped to exactly that length with the marker.

Verification (this pass)

Run on this branch (origin/beta 67a8e6d + this commit). tsc ran first, on its own, with the larger heap this device needs:

  • NODE_OPTIONS=--max-old-space-size=8192 bunx tsc --noEmit -p tsconfig.json: exit 0, no errors.
  • NODE_OPTIONS=--max-old-space-size=8192 bun run test: exit 0.
    Test Files  1231 passed (1231)
         Tests  19198 passed | 1 skipped (19199)
      Duration  214.54s
    
  • bunx eslint src/lib/coding-agent.ts src/tests/unit/coding-agent.test.ts src/tests/unit/coding-review-loop.test.ts: exit 0, no problems.
  • With the coding-agent.ts change reverted and the new tests kept, all 3 new tests fail. The 6 000-character round test fails with expected 'needs_owner' to be 'clean'.

πŸ€– Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Box-generated follow-up tasks can now support up to 32,000 characters and are truncated when necessary.
    • User-entered tasks over 4,000 characters continue to be rejected.
    • Resumed review loops preserve all findings without duplicating the original task.
    • Review feedback and generated review tasks remain within supported task limits.
  • Tests

    • Added coverage for task-length handling across resumed runs and review-loop scenarios.

…SK-901)

The owner's 4000-character task limit (MAX_TASK_CHARS) was applied in
startRun to every start, including the follow-ups the box writes itself.
A review-loop round quotes GitHub's failing-check logs and review
comments (buildReviewFeedback bounds that at 24 000 characters), so PR
#926's four CodeRabbit threads made the round's task too long, the start
was refused with "The task is too long: at most 4000 characters.", and
the pull request was handed back unreviewed.

The round never embeds the original task β€” it resumes the session that
holds it and names the pull request β€” so nothing needed truncating
there. Instead, tasks the box wrote (review pass, review-loop round,
Vercel deploy-fix turn) get their own ceiling, MAX_BOX_TASK_CHARS
(32 000, above what those builders produce), and are clipped to it
rather than refused. Typed tasks keep the 4000 limit unchanged.

Tests: a 6000-character primary task whose round quotes four full-length
review threads and a failing check now starts its round (it settled
needs_owner before); a box-written task past its own ceiling is clipped,
a typed one past 4000 is still refused.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@yalexx
yalexx requested a review from a team as a code owner September 19, 2026 05:29
@yalexx
yalexx deployed to e2e-pull-request September 19, 2026 05:29 — with GitHub Actions Active
@yalexx
yalexx deployed to clawreview September 19, 2026 05:29 — with GitHub Actions Active
@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Repository: ID-Robots/clawbox/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 063a6233-990c-4ef1-8e6d-85693c2270bb

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 67a8e6d and 0ef9101.

πŸ“’ Files selected for processing (3)
  • src/lib/coding-agent.ts
  • src/tests/unit/coding-agent.test.ts
  • src/tests/unit/coding-review-loop.test.ts

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


πŸ“ Walkthrough

Walkthrough

The change adds separate size limits for typed and internally generated tasks. Oversized typed tasks remain rejected. Oversized review, review-loop, and deployment-fix tasks are truncated and marked before execution.

Changes

Task Length Handling

Layer / File(s) Summary
Task limits and normalization
src/lib/coding-agent.ts
Adds MAX_BOX_TASK_CHARS, detects internally generated tasks, truncates oversized generated tasks, and preserves rejection for oversized typed tasks.
Boundary and regression tests
src/tests/unit/coding-agent.test.ts, src/tests/unit/coding-review-loop.test.ts
Tests typed-task rejection, generated-task truncation, review-round resumption, finding preservation, and generated task size bounds.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: clawbox

πŸš₯ Pre-merge checks | βœ… 6
βœ… Passed checks (6 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly identifies the main change: preventing generated review rounds from being refused because of task length. It is concise and specific.
Description check βœ… Passed The description provides a detailed summary, rationale, implementation details, testing scope, verification commands, and results. It does not use the template headings or complete the type-of-change …
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 …
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
Persistent Tunnel Security βœ… Passed PASS. The authoritative PR range changes only src/lib/coding-agent.ts and two coding-agent test files. The implementation changes task-length normalization for box-generated review and deployment fo…
✨ Finishing Touches
πŸ“ Generate docstrings
  • Commit to this branch
  • Create a new PR
πŸ§ͺ Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@github-actions

github-actions Bot commented Sep 19, 2026

Copy link
Copy Markdown

CI Summary

βœ… Tests

  • Result: passed
  • View run
  • Coverage: statements 87.81%, branches 81.16%, functions 87.59%, lines 90.45%

βœ… E2E

βœ… E2E Install

@yalexx
yalexx merged commit 319f9b7 into beta Sep 19, 2026
11 checks passed
@yalexx
yalexx deleted the clawbox/run-46idd916 branch September 19, 2026 05:49

This branch was successfully deployed

2 active deployments
e2e-pull-request β€” 0ef9101a Deployed Sep 19, 2026 by yalexx via e2e-install #2638
clawreview β€” 0ef9101a Deployed Sep 19, 2026 by yalexx via review #2311
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.

1 participant