Commit 447f65f
feat: Add configurable max_tokens support to Summarizer
## Configuration Support
Implemented max_tokens configuration support to allow users to control Claude API response length via configuration files.
### Changes
**memdocs/summarize.py**:
- Added `max_tokens` parameter to `Summarizer.__init__()` with default=DEFAULT_MAX_TOKENS (4096)
- Updated `Summarizer.summarize()` to use `self.max_tokens` instead of hardcoded constant
- Enhanced docstrings to document the new parameter
- Stored max_tokens as instance variable for flexible configuration
**memdocs/cli_modules/commands/review_cmd.py**:
- Updated Summarizer instantiation to pass `doc_config.ai.max_tokens`
- Ensures CLI respects configuration file settings
### Configuration Flow
```
.memdocs.yml (max_tokens: 8192)
↓
AIConfig schema (default: 4096)
↓
Summarizer class (uses configured value)
↓
Claude API request
```
### Backward Compatibility
✅ Default parameter value maintains existing behavior (4096 tokens)
✅ All existing code that calls `Summarizer()` without parameters works unchanged
✅ All tests pass (304 passed, 9 skipped)
✅ No breaking changes to API
### Configuration Hierarchy
1. **DEFAULT_MAX_TOKENS = 4096** - Constant used as parameter default
2. **AIConfig.max_tokens = 4096** - Schema default when not specified in config
3. **.memdocs.yml: max_tokens: 8192** - User configuration (overrides schema default)
### Benefits
- Users can now control response length via .memdocs.yml
- Flexibility for different use cases (short summaries vs detailed docs)
- Maintains safe defaults while allowing customization
- Aligns code behavior with documented configuration options
### Example Usage
```python
# Use default (4096 tokens)
summarizer = Summarizer()
# Use custom value
summarizer = Summarizer(max_tokens=8192)
# Via configuration file (.memdocs.yml sets max_tokens: 8192)
# CLI automatically respects config value
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent d3793d1 commit 447f65f
2 files changed
+16
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| |||
94 | 102 | | |
95 | 103 | | |
96 | 104 | | |
97 | | - | |
| 105 | + | |
98 | 106 | | |
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| 111 | + | |
103 | 112 | | |
104 | 113 | | |
105 | 114 | | |
| |||
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
118 | 130 | | |
119 | 131 | | |
120 | 132 | | |
| |||
144 | 156 | | |
145 | 157 | | |
146 | 158 | | |
147 | | - | |
| 159 | + | |
148 | 160 | | |
149 | 161 | | |
150 | 162 | | |
| |||
0 commit comments