Procházet zdrojové kódy

feat(context): trim maxNodes default to 8 on tiny repos

On a <150-file project the entire repo is grep-able in one turn, so the
20-node default `codegraph_context` was paying for a graph subset that
exceeds the agent's actual question. Cutting the tiny-repo default to 8
(typical 1-3 entry points + their immediate 1-hop neighbors) reduces
the context-tool response body without hitting sufficiency on the flow
shapes small repos actually contain.

Non-breaking: the agent can still pass an explicit `maxNodes` to
override; medium+ repos (>=150 files) keep the 20-node default.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Colby McHenry před 3 týdny
rodič
revize
d8bb6f84b0
1 změnil soubory, kde provedl 12 přidání a 1 odebrání
  1. 12 1
      src/mcp/tools.ts

+ 12 - 1
src/mcp/tools.ts

@@ -1083,7 +1083,18 @@ export class ToolHandler {
     }
 
     const cg = this.getCodeGraph(args.projectPath as string | undefined);
-    const maxNodes = (args.maxNodes as number) || 20;
+    // On tiny repos (<150 files), trim maxNodes hard — the entire repo
+    // is grep-able in a turn so a 20-node context is wasted budget.
+    // 8 covers the typical 1-3 entry-point + their immediate neighbors
+    // without dragging in the rest of the small codebase.
+    let defaultMaxNodes = 20;
+    try {
+      const stats = cg.getStats();
+      if (stats.fileCount < 150) defaultMaxNodes = 8;
+    } catch {
+      // stats failure — fall back to the standard default
+    }
+    const maxNodes = (args.maxNodes as number) || defaultMaxNodes;
     const includeCode = args.includeCode !== false;
 
     const context = await cg.buildContext(task, {