Skip to content

Fix tri-agent failures on large diffs - #31

Merged
5uck1ess merged 3 commits into
mainfrom
fix/tri-agent-large-diff
Apr 7, 2026
Merged

Fix tri-agent failures on large diffs#31
5uck1ess merged 3 commits into
mainfrom
fix/tri-agent-large-diff

Conversation

@5uck1ess

@5uck1ess 5uck1ess commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the root causes of all-three-agents-failing on large diffs:

  • Diff truncation 30K → 500K chars — old limit silently chopped diffs mid-hunk, causing all agents to review incomplete code. New limit truncates at file boundaries (last diff --git marker).
  • Stdin piping for all runners — Claude, Codex, and Gemini now receive prompts via stdin instead of -p CLI arguments. Eliminates ARG_MAX risk and special character mangling.
  • OAuth token detection — Claude runner now checks ANTHROPIC_API_KEY prefix. OAuth tokens (sk-ant-oat*) don't work for subprocess claude -p calls, so the runner marks itself unavailable and Codex/Gemini still run instead of all three silently failing.

Root cause analysis

When the Go harness ran devkit review on a large diff:

  1. Diff truncated at 30K chars → all agents got incomplete context
  2. Claude subprocess failed (OAuth token not valid for -p mode)
  3. Codex/Gemini got truncated diff → produced low-quality or wrong reviews
  4. Result: all three outputs useless

Test plan

  • go test ./... passes (verified locally — all pass)
  • go build ./... succeeds (verified locally)
  • Run devkit review on a repo with >30K char diff — verify no truncation
  • With OAuth token: verify Claude runner skipped, Codex/Gemini still run
  • With real API key: verify all three runners work

5uck1ess added 3 commits April 6, 2026 22:15
Three root causes found and fixed:

1. Diff truncation at 30K chars (review.go) — raised to 500K with
   file-boundary-aware truncation. 500K chars ≈ 125K tokens, well
   within Claude (200K) and Gemini (1M) context windows.

2. All runners passed prompt as CLI argument (-p prompt) — switched
   to stdin piping for all three (Claude, Codex, Gemini). Eliminates
   ARG_MAX risk and handles special characters in diffs safely.

3. Claude runner fails silently with OAuth tokens (sk-ant-oat*) —
   Added Available() check that skips Claude when OAuth token detected.
   OAuth tokens only work within the parent session, not for subprocess
   claude -p calls. When skipped, Codex and Gemini still run.
Code-reviewer caught three issues, all verified:

- Claude: -p is print-mode flag, not stdin marker. Reverted to
  passing prompt as positional arg. Added stderr log when OAuth
  token detected so skipping is visible, not silent.

- Codex: Reverted to passing prompt as arg (verified it works).
  Removed unnecessary stdin piping and vague placeholder instruction.

- Gemini: Dropped -p flag entirely — it was duplicating instructions
  (stdin + -p both sent to model). Now stdin-only, verified working.
- Claude: JSON parse failure now returns error instead of nil
  (prevents garbage output presented as legitimate review)
- Codex: Non-zero exit codes now treated as errors (matching Gemini)
- All runners: "failed to start" → "failed to run" (accurate message)
- Truncation: Differentiates file-boundary vs mid-hunk truncation
  in the warning message
@5uck1ess
5uck1ess merged commit 3a141a8 into main Apr 7, 2026
3 checks passed
@5uck1ess
5uck1ess deleted the fix/tri-agent-large-diff branch April 7, 2026 03:53
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