Commit 6b6a2a1
committed
Feat: Make max output tokens configurable for agentic workflows
Added MCP_CODE_AGENT_MAX_OUTPUT_TOKENS environment variable and config
setting to allow users to customize max output tokens for agentic workflows,
overriding tier-based defaults.
## Configuration (config_manager.rs):
Added to LLMConfig:
- mcp_code_agent_max_output_tokens: Option<usize> field
- Environment variable override: MCP_CODE_AGENT_MAX_OUTPUT_TOKENS
- Defaults to None (uses tier-based defaults)
## Orchestrator (agentic_orchestrator.rs):
AgenticConfig changes:
- from_tier_with_override(tier, max_tokens_override) method
- from_tier() now delegates to from_tier_with_override(tier, None)
AgenticOrchestrator changes:
- new_with_override() constructor accepting optional max_tokens
- new() delegates to new_with_override(..., None)
## Server Integration (official_server.rs):
execute_agentic_workflow() changes:
- Reads config.llm.mcp_code_agent_max_output_tokens
- Passes override to AgenticOrchestrator::new_with_override()
- Falls back to tier defaults if not configured
## CLI Display (bin/codegraph.rs):
codegraph config agent-status changes:
- Calculates actual max_output_tokens used
- Shows "(custom)" or "(tier default)" indicator
- JSON output includes:
* max_output_tokens: actual value
* max_output_tokens_source: "custom" | "tier_default"
## Usage:
Environment variable:
export MCP_CODE_AGENT_MAX_OUTPUT_TOKENS=8000
Config file (.codegraph.toml):
[llm]
mcp_code_agent_max_output_tokens = 8000
Tier defaults (if not configured):
- Small: 2,048 tokens
- Medium: 4,096 tokens
- Large: 8,192 tokens
- Massive: 16,384 tokens
## Benefits:
- Users can test different token limits to optimize coding flow
- Override tier defaults without changing LLM configuration
- Visible in agent-status command for debugging
- Backward compatible (defaults to tier-based values)
~75 lines added1 parent 5b521d6 commit 6b6a2a1
File tree
4 files changed
+64
-10
lines changed- crates
- codegraph-core/src
- codegraph-mcp/src
- bin
4 files changed
+64
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
199 | 204 | | |
200 | 205 | | |
201 | 206 | | |
| |||
223 | 228 | | |
224 | 229 | | |
225 | 230 | | |
| 231 | + | |
226 | 232 | | |
227 | 233 | | |
228 | 234 | | |
| |||
531 | 537 | | |
532 | 538 | | |
533 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
534 | 546 | | |
535 | 547 | | |
536 | 548 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
| 48 | + | |
| 49 | + | |
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| |||
204 | 211 | | |
205 | 212 | | |
206 | 213 | | |
207 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
208 | 225 | | |
209 | 226 | | |
210 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1704 | 1704 | | |
1705 | 1705 | | |
1706 | 1706 | | |
1707 | | - | |
1708 | | - | |
1709 | | - | |
1710 | | - | |
1711 | | - | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
1712 | 1712 | | |
1713 | 1713 | | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
1714 | 1720 | | |
1715 | 1721 | | |
1716 | 1722 | | |
| |||
1766 | 1772 | | |
1767 | 1773 | | |
1768 | 1774 | | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
1769 | 1781 | | |
1770 | 1782 | | |
1771 | 1783 | | |
| |||
1851 | 1863 | | |
1852 | 1864 | | |
1853 | 1865 | | |
1854 | | - | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
1855 | 1872 | | |
1856 | 1873 | | |
1857 | 1874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1359 | 1359 | | |
1360 | 1360 | | |
1361 | 1361 | | |
1362 | | - | |
1363 | | - | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
1364 | 1372 | | |
1365 | 1373 | | |
1366 | 1374 | | |
| |||
0 commit comments