Skip to content

Commit eea5e73

Browse files
matejclaude
andcommitted
Raise diff size defaults for 1M context models
The previous DEFAULT_MAX_DIFF_CHARS (400k chars / ~100k tokens) was sized for 200k-token context models. Both Opus 4.7 and Sonnet 4.6 now expose a 1M context window, so double the default to 800k chars (~200k tokens), which still leaves ~5x context headroom for system prompt, tools, thinking, and output. Also wire get_pr_data's fallback default to DEFAULT_MAX_DIFF_CHARS so the constant is the single source of truth, refresh the action.yml and README guidance for 1M-context defaults, and clarify the PROMPT_TOKEN_LIMIT comment (it caps filter/validator output, not input). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4c514ce commit eea5e73

4 files changed

Lines changed: 21 additions & 23 deletions

File tree

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ This action is not hardened against prompt injection attacks and should only be
111111
| `comment-pr` | Whether to comment on PRs with findings | `true` | No |
112112
| `upload-results` | Whether to upload results as artifacts | `true` | No |
113113
| `exclude-directories` | Comma-separated list of directories to exclude from scanning | None | No |
114-
| `claude-model` | Claude [model name](https://docs.anthropic.com/en/docs/about-claude/models/overview#model-names) to use. Defaults to Opus 4.7. For large PRs (>400k char diffs), consider using `claude-sonnet-4-6` (1M context). | `claude-opus-4-7` | No |
114+
| `claude-model` | Claude [model name](https://docs.anthropic.com/en/docs/about-claude/models/overview#model-names) to use. Defaults to Opus 4.7 (1M context). For very large PRs or to reduce cost, consider `claude-sonnet-4-6` (also 1M context, faster and cheaper). | `claude-opus-4-7` | No |
115115
| `claudecode-timeout` | Timeout for ClaudeCode analysis in minutes | `20` | No |
116-
| `max-diff-chars` | Maximum diff characters to include in prompt. Set to `0` for agentic mode (Claude uses git commands to explore). See [Diff Size Configuration](#diff-size-configuration) below. | `400000` | No |
116+
| `max-diff-chars` | Maximum diff characters to include in prompt. Set to `0` for agentic mode (Claude uses git commands to explore). See [Diff Size Configuration](#diff-size-configuration) below. | `800000` | No |
117117
| `max-diff-lines` | **[DEPRECATED]** Use `max-diff-chars` instead. Converts lines to chars (line × 80). | None | No |
118118
| `run-every-commit` | Run ClaudeCode on every commit (skips cache check). Warning: May increase false positives on PRs with many commits. **Deprecated**: Use `trigger-on-commit` instead. | `false` | No |
119119
| `trigger-on-open` | Run review when PR is first opened | `true` | No |
@@ -146,7 +146,7 @@ The action handles PRs of any size using three review modes:
146146
1. **Full Diff Mode** (default for small PRs)
147147
- Entire diff embedded in prompt
148148
- Fastest and most comprehensive
149-
- Works for diffs up to ~400k characters
149+
- Works for diffs up to ~800k characters
150150

151151
2. **Partial Diff Mode** (automatic for large PRs)
152152
- First N files embedded in prompt
@@ -160,21 +160,20 @@ The action handles PRs of any size using three review modes:
160160

161161
#### Configuration
162162

163-
**`max-diff-chars`** - Maximum diff characters to embed (default: 400,000)
163+
**`max-diff-chars`** - Maximum diff characters to embed (default: 800,000)
164164

165165
```yaml
166-
# Default: 400k chars (fits in 200k token models)
166+
# Default: 800k chars (~200k tokens, fits comfortably in 1M context models)
167167
- uses: PSPDFKit-labs/nutrient-code-review@main
168168
with:
169169
claude-api-key: ${{ secrets.CLAUDE_API_KEY }}
170-
max-diff-chars: 400000 # ~100k tokens
170+
max-diff-chars: 800000
171171
172-
# Large PRs: Use 1M context model with higher limit
172+
# Very large PRs: push the embed budget higher (still within 1M context)
173173
- uses: PSPDFKit-labs/nutrient-code-review@main
174174
with:
175175
claude-api-key: ${{ secrets.CLAUDE_API_KEY }}
176-
claude-model: claude-sonnet-4-6 # 1M context
177-
max-diff-chars: 800000 # ~200k tokens
176+
max-diff-chars: 1600000 # ~400k tokens
178177
179178
# Always use agentic mode (no embedded diff)
180179
- uses: PSPDFKit-labs/nutrient-code-review@main
@@ -187,9 +186,9 @@ The action handles PRs of any size using three review modes:
187186

188187
| Diff Size | Recommended Model | Context Window |
189188
|-----------|-------------------|----------------|
190-
| < 400k chars | `claude-opus-4-7` (default) | 1M tokens |
191-
| 400k - 800k chars | `claude-sonnet-4-6` | 1M tokens |
192-
| > 800k chars | Set `max-diff-chars: 0` (agentic mode) | Any model |
189+
| < 800k chars | `claude-opus-4-7` (default) | 1M tokens |
190+
| 800k - 1.6M chars | `claude-opus-4-7` or `claude-sonnet-4-6` with raised `max-diff-chars` | 1M tokens |
191+
| > 1.6M chars | Set `max-diff-chars: 0` (agentic mode) | Any model |
193192

194193
**Backward Compatibility:**
195194

action.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ inputs:
7171

7272
max-diff-chars:
7373
description: |
74-
Maximum diff characters to embed in prompt (default: 400000 = 400k chars).
75-
Larger diffs use agentic file reading instead. Set to 0 to always use agentic mode.
74+
Maximum diff characters to embed in prompt (default: 800000 = 800k chars,
75+
~200k tokens). Larger diffs use agentic file reading instead. Set to 0 to
76+
always use agentic mode.
7677
77-
IMPORTANT: For large limits (>400k), use a model with larger context like:
78-
- claude-sonnet-4-6 (1M context) for diffs up to 800k chars
79-
- Set via 'claude-model' input parameter
80-
81-
Note: ~400k chars fits comfortably in the default Opus 4.7 model (1M context).
78+
Note: 800k chars fits comfortably in the default Opus 4.7 model (1M
79+
context). To embed even larger diffs, raise this value — both Opus 4.7
80+
and Sonnet 4.6 have 1M context.
8281
required: false
83-
default: '400000'
82+
default: '800000'
8483

8584
max-diff-lines:
8685
description: |

claudecode/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
RATE_LIMIT_BACKOFF_MAX = 30 # Maximum backoff time for rate limits
1212

1313
# Token Limits
14-
PROMPT_TOKEN_LIMIT = 16384 # 16k tokens max for claude-opus-4
14+
PROMPT_TOKEN_LIMIT = 16384 # Output cap for filter/validator API calls
1515

1616
# Diff Construction Limits
17-
DEFAULT_MAX_DIFF_CHARS = 400000 # 400k characters (suitable for 200k token models)
17+
DEFAULT_MAX_DIFF_CHARS = 800000 # 800k characters (~200k tokens; fits comfortably in 1M context models)
1818
# Conversion factor for deprecated MAX_DIFF_LINES -> MAX_DIFF_CHARS
1919
CHARS_PER_LINE_ESTIMATE = 80 # Average characters per line for conversion
2020

claudecode/github_action_audit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(self):
128128
print(f"[Debug] User excluded directories: {user_excluded_dirs}", file=sys.stderr)
129129
print(f"[Debug] Total excluded directories: {self.excluded_dirs}", file=sys.stderr)
130130

131-
def get_pr_data(self, repo_name: str, pr_number: int, max_diff_chars: int = 400000) -> Dict[str, Any]:
131+
def get_pr_data(self, repo_name: str, pr_number: int, max_diff_chars: int = DEFAULT_MAX_DIFF_CHARS) -> Dict[str, Any]:
132132
"""Get PR metadata and construct diff in one pass with early termination.
133133
134134
Fetches files page-by-page while building the diff. Stops fetching when

0 commit comments

Comments
 (0)