attocode 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/src/agent.d.ts +15 -1
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +227 -32
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/defaults.d.ts +1 -1
  7. package/dist/src/defaults.d.ts.map +1 -1
  8. package/dist/src/integrations/budget-pool.d.ts +96 -0
  9. package/dist/src/integrations/budget-pool.d.ts.map +1 -0
  10. package/dist/src/integrations/budget-pool.js +145 -0
  11. package/dist/src/integrations/budget-pool.js.map +1 -0
  12. package/dist/src/integrations/context-engineering.d.ts +16 -1
  13. package/dist/src/integrations/context-engineering.d.ts.map +1 -1
  14. package/dist/src/integrations/context-engineering.js +17 -0
  15. package/dist/src/integrations/context-engineering.js.map +1 -1
  16. package/dist/src/integrations/file-cache.d.ts +90 -0
  17. package/dist/src/integrations/file-cache.d.ts.map +1 -0
  18. package/dist/src/integrations/file-cache.js +164 -0
  19. package/dist/src/integrations/file-cache.js.map +1 -0
  20. package/dist/src/integrations/index.d.ts +4 -2
  21. package/dist/src/integrations/index.d.ts.map +1 -1
  22. package/dist/src/integrations/index.js +4 -0
  23. package/dist/src/integrations/index.js.map +1 -1
  24. package/dist/src/integrations/safety.d.ts +25 -0
  25. package/dist/src/integrations/safety.d.ts.map +1 -1
  26. package/dist/src/integrations/safety.js +47 -0
  27. package/dist/src/integrations/safety.js.map +1 -1
  28. package/dist/src/providers/adapters/anthropic.d.ts +1 -1
  29. package/dist/src/providers/adapters/anthropic.d.ts.map +1 -1
  30. package/dist/src/providers/adapters/anthropic.js +15 -2
  31. package/dist/src/providers/adapters/anthropic.js.map +1 -1
  32. package/dist/src/providers/adapters/mock.d.ts +2 -2
  33. package/dist/src/providers/adapters/mock.d.ts.map +1 -1
  34. package/dist/src/providers/adapters/mock.js +2 -1
  35. package/dist/src/providers/adapters/mock.js.map +1 -1
  36. package/dist/src/providers/adapters/openai.d.ts +1 -1
  37. package/dist/src/providers/adapters/openai.d.ts.map +1 -1
  38. package/dist/src/providers/adapters/openai.js +2 -2
  39. package/dist/src/providers/adapters/openai.js.map +1 -1
  40. package/dist/src/providers/adapters/openrouter.d.ts +1 -1
  41. package/dist/src/providers/adapters/openrouter.d.ts.map +1 -1
  42. package/dist/src/providers/adapters/openrouter.js +7 -4
  43. package/dist/src/providers/adapters/openrouter.js.map +1 -1
  44. package/dist/src/providers/types.d.ts +1 -1
  45. package/dist/src/providers/types.d.ts.map +1 -1
  46. package/dist/src/tricks/kv-cache-context.d.ts +24 -0
  47. package/dist/src/tricks/kv-cache-context.d.ts.map +1 -1
  48. package/dist/src/tricks/kv-cache-context.js +68 -0
  49. package/dist/src/tricks/kv-cache-context.js.map +1 -1
  50. package/dist/src/types.d.ts +32 -1
  51. package/dist/src/types.d.ts.map +1 -1
  52. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.9] - 2026-02-06
9
+
10
+ ### Added
11
+ - **Prompt cache markers (P1)** - System prompts are now sent as structured `CacheableContentBlock[]` with `cache_control: { type: 'ephemeral' }` markers, enabling LLM provider-level prompt caching. Static sections (prefix, rules, tools, memory) are marked for caching; dynamic content (session ID, timestamp) is not. Anthropic and OpenRouter adapters pass markers through; OpenAI adapter gracefully flattens to string. Expected 60-70% cache hit rate on multi-turn sessions.
12
+ - **Shared file cache (P2)** - New `SharedFileCache` (LRU, TTL-based) shared across parent and child agents via same-process Map reference. Eliminates redundant file reads in multi-agent workflows (previously 3x reads of large files like agent.ts at 212KB). All file paths normalized via `path.resolve()` for consistent keys. Write operations and `undo_file_change` invalidate cache entries. Configurable max size (5MB default) and TTL (5 min default).
13
+ - **Budget pooling (P4)** - New `SharedBudgetPool` replaces independent per-subagent budgets. Parent reserves 25% for synthesis work; remaining 75% is shared across children. Pessimistic reservation accounting prevents over-allocation during parallel spawns. `recordUsage()` and `release()` called in `finally` block to track actual consumption and return unused budget. Pool exhaustion grants minimal 5K emergency budget instead of bypassing limits.
14
+ - **Subagent compaction (P5)** - Subagents now have auto-compaction enabled with `maxContextTokens: 80000` (compaction triggers at ~64K tokens via 80% threshold). More aggressive settings: fewer preserved messages, no tool result preservation, smaller summaries.
15
+ - **Approval batching (P6)** - New `ApprovalScope` system for subagent pre-approval. Read-only tools (`read_file`, `glob`, `grep`, etc.) auto-approved. Write tools (`write_file`, `edit_file`) scoped-approved within `src/`, `tests/`, `tools/` directories. Directory-boundary-aware path matching prevents false positives (e.g., `src/` won't match `src-backup/`). Tool name matching uses exact comparison, not substring.
16
+ - **Comprehensive test coverage** - 81 new tests across 5 test files: `budget-pool.test.ts` (23 tests), `file-cache.test.ts` (22 tests), `approval-scope.test.ts` (14 tests), `timeout-precedence.test.ts` (14 tests), `cache-markers.test.ts` (8 tests)
17
+
18
+ ### Fixed
19
+ - **Subagent timeout precedence (P3)** - Changed from `configTimeout ?? agentTypeTimeout` (config always wins) to proper 4-level chain: per-type config > agent-type default > global config > hardcoded fallback. Reviewers now correctly get 180s (not global 300s), researchers get 420s. Added per-type config support via `subagent.timeouts` record.
20
+ - **Timeout/iteration validation** - Negative, NaN, and Infinity values in timeout/iteration configs are now rejected and fall through to next precedence level instead of causing runtime errors in `createGracefulTimeout()`.
21
+ - **Budget pool initialization** - Pool now uses the agent's actual configured budget (custom or default) instead of always using `STANDARD_BUDGET` (200K). Users with 500K budgets no longer get a pool capped at 200K.
22
+ - **Cache markers fallback** - When KV-cache context is not configured, `buildCacheableSystemPrompt()` returns empty array (signal to use plain string) instead of an unmarked block that would be sent as structured content without cache benefits.
23
+ - **Approval scope matching** - Tool name matching changed from `includes()` to exact `===` comparison, preventing `requireApproval: ['bash']` from blocking `bash_completion`. Path matching now checks directory boundaries, preventing `src/` from matching `src-backup/file.ts`.
24
+
25
+ ### Changed
26
+ - **LLM Provider interface** - `chat()` method widened to accept `(Message | MessageWithContent)[]` across both provider interfaces (`src/types.ts` and `src/providers/types.ts`). All 4 provider adapters (Anthropic, OpenRouter, OpenAI, Mock) updated.
27
+ - **Subagent budget model** - Subagents no longer get independent 150K budgets (which exposed 250%+ of intended cost). Budget is now drawn from a shared pool bounded by the parent's total budget.
28
+ - **Subagent spawn flow** - `spawnAgent()` now allocates from budget pool, passes file cache, sets approval scope, enables compaction, and records actual usage on completion.
29
+
8
30
  ## [0.1.8] - 2026-02-06
9
31
 
10
32
  ### Added
@@ -21,7 +21,7 @@
21
21
  import type { ProductionAgentConfig, LLMProvider, Message, ToolDefinition, AgentState, AgentMetrics, AgentPlan, AgentResult, AgentEventListener, AgentRoleConfig } from './types.js';
22
22
  import { type AgentMode } from './modes.js';
23
23
  import { type LSPFileToolsConfig } from './agent-tools/index.js';
24
- import { AgentRegistry, LSPManager, SkillManager, type ExecutionBudget, type AgentRole, type TeamTask, type TeamResult, type ReActTrace, type Checkpoint, type AgentDefinition, type LoadedAgent, type SpawnResult, type StructuredClosureReport, type CancellationTokenType, type Skill, type PendingPlan, LearningStore, AutoCompactionManager, FileChangeTracker, CapabilitiesRegistry, TaskManager, type SQLiteStore } from './integrations/index.js';
24
+ import { AgentRegistry, LSPManager, SkillManager, type ExecutionBudget, type AgentRole, type TeamTask, type TeamResult, type ReActTrace, type Checkpoint, type AgentDefinition, type LoadedAgent, type SpawnResult, type StructuredClosureReport, type CancellationTokenType, type Skill, type ApprovalScope, type PendingPlan, LearningStore, AutoCompactionManager, FileChangeTracker, CapabilitiesRegistry, TaskManager, type SQLiteStore } from './integrations/index.js';
25
25
  import { TraceCollector } from './tracing/trace-collector.js';
26
26
  /**
27
27
  * Production-ready agent that composes all features.
@@ -62,6 +62,8 @@ export declare class ProductionAgent {
62
62
  private capabilitiesRegistry;
63
63
  private toolResolver;
64
64
  private blackboard;
65
+ private fileCache;
66
+ private budgetPool;
65
67
  private taskManager;
66
68
  private store;
67
69
  private spawnedTasks;
@@ -70,6 +72,7 @@ export declare class ProductionAgent {
70
72
  private externalCancellationToken;
71
73
  private wrapupRequested;
72
74
  private wrapupReason;
75
+ private cacheableSystemBlocks;
73
76
  private initPromises;
74
77
  private initComplete;
75
78
  private unsubscribers;
@@ -443,6 +446,12 @@ export declare class ProductionAgent {
443
446
  * Spawn multiple agents in parallel to work on independent tasks.
444
447
  * Uses the shared blackboard for coordination and conflict prevention.
445
448
  *
449
+ * Get budget for a subagent, using the pooled budget when available.
450
+ * Falls back to the static SUBAGENT_BUDGET if no pool is configured.
451
+ * Returns both the budget and the pool allocation ID (if any) for tracking.
452
+ */
453
+ private getSubagentBudget;
454
+ /**
446
455
  * Uses Promise.allSettled to handle partial failures gracefully - if one
447
456
  * agent fails or times out, others can still complete successfully.
448
457
  */
@@ -580,6 +589,11 @@ export declare class ProductionAgent {
580
589
  * so the subagent can account for total iterations across the hierarchy.
581
590
  */
582
591
  setParentIterations(count: number): void;
592
+ /**
593
+ * Set an approval scope for this agent (used by parent when spawning subagents).
594
+ * Enables pre-approved operations within a defined scope, reducing approval prompts.
595
+ */
596
+ setApprovalScope(scope: ApprovalScope): void;
583
597
  /**
584
598
  * Set an external cancellation token for this agent.
585
599
  * Used when spawning subagents to propagate parent timeout/cancellation.
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EACX,OAAO,EAGP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,SAAS,EACT,WAAW,EAEX,kBAAkB,EAClB,eAAe,EAGhB,MAAM,YAAY,CAAC;AAUpB,OAAO,EASL,KAAK,SAAS,EACf,MAAM,YAAY,CAAC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,GAAG,EAAE,MAAM,GAAG,IAAI;IAKhC;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKzB;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,qBAAqB,EAAE,UAAU,GAAG,OAAO,GAAG,cAAc,GAAG,OAAO,GAAG,eAAe,GAAG,SAAS,CAAC,GAAG,IAAI;IAKxI;;OAEG;IACH,KAAK,IAAI,eAAe;CAMzB;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,sBAAsB,CAEnD;AAMD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,iBAAiB,EAAE,uBAAuB,CAAC,YAAY,CAAC,EACxD,YAAY,CAAC,EAAE,MAAM,GACpB,uBAAuB,GAAG,SAAS,CAiDrC"}
package/dist/src/agent.js CHANGED
@@ -21,7 +21,7 @@
21
21
  import { buildConfig, isFeatureEnabled, getEnabledFeatures, getSubagentTimeout, getSubagentMaxIterations, } from './defaults.js';
22
22
  import { createModeManager, formatModeList, parseMode, calculateTaskSimilarity, SUBAGENT_PLAN_MODE_ADDITION, } from './modes.js';
23
23
  import { createLSPFileTools, } from './agent-tools/index.js';
24
- import { HookManager, MemoryManager, PlanningManager, ObservabilityManager, SafetyManager, RoutingManager, MultiAgentManager, ReActManager, ExecutionPolicyManager, ThreadManager, RulesManager, DEFAULT_RULE_SOURCES, ExecutionEconomicsManager, STANDARD_BUDGET, SUBAGENT_BUDGET, TIMEOUT_WRAPUP_PROMPT, AgentRegistry, filterToolsForAgent, formatAgentList, createCancellationManager, isCancellationError, createLinkedToken, createGracefulTimeout, race, createResourceManager, createLSPManager, createSemanticCacheManager, createSkillManager, formatSkillList, createContextEngineering, stableStringify, createCodebaseContext, buildContextFromChunks, createPendingPlanManager, createInteractivePlanner, createRecursiveContext, createLearningStore, createCompactor, createAutoCompactionManager, createFileChangeTracker, createCapabilitiesRegistry, createSharedBlackboard, createTaskManager, } from './integrations/index.js';
24
+ import { HookManager, MemoryManager, PlanningManager, ObservabilityManager, SafetyManager, RoutingManager, MultiAgentManager, ReActManager, ExecutionPolicyManager, ThreadManager, RulesManager, DEFAULT_RULE_SOURCES, ExecutionEconomicsManager, STANDARD_BUDGET, SUBAGENT_BUDGET, TIMEOUT_WRAPUP_PROMPT, AgentRegistry, filterToolsForAgent, formatAgentList, createCancellationManager, isCancellationError, createLinkedToken, createGracefulTimeout, race, createResourceManager, createLSPManager, createSemanticCacheManager, createSkillManager, formatSkillList, createContextEngineering, stableStringify, createCodebaseContext, buildContextFromChunks, createSharedFileCache, createBudgetPool, createPendingPlanManager, createInteractivePlanner, createRecursiveContext, createLearningStore, createCompactor, createAutoCompactionManager, createFileChangeTracker, createCapabilitiesRegistry, createSharedBlackboard, createTaskManager, } from './integrations/index.js';
25
25
  // Lesson 26: Tracing & Evaluation integration
26
26
  import { createTraceCollector } from './tracing/trace-collector.js';
27
27
  // Model registry for context window limits
@@ -74,6 +74,8 @@ export class ProductionAgent {
74
74
  capabilitiesRegistry = null;
75
75
  toolResolver = null;
76
76
  blackboard = null;
77
+ fileCache = null;
78
+ budgetPool = null;
77
79
  taskManager = null;
78
80
  store = null;
79
81
  // Duplicate spawn prevention - tracks recently spawned tasks to prevent doom loops
@@ -88,6 +90,9 @@ export class ProductionAgent {
88
90
  // Graceful wrapup support (for subagent timeout wrapup phase)
89
91
  wrapupRequested = false;
90
92
  wrapupReason = null;
93
+ // Cacheable system prompt blocks for prompt caching (Improvement P1)
94
+ // When set, callLLM() will inject these as structured content with cache_control markers
95
+ cacheableSystemBlocks = null;
91
96
  // Initialization tracking
92
97
  initPromises = [];
93
98
  initComplete = false;
@@ -141,6 +146,26 @@ export class ProductionAgent {
141
146
  deduplicateFindings: true,
142
147
  });
143
148
  }
149
+ // Shared File Cache - eliminates redundant file reads across parent and subagents
150
+ // Subagents inherit parent's cache; parent agents create their own
151
+ if (userConfig.fileCache) {
152
+ this.fileCache = userConfig.fileCache;
153
+ }
154
+ else if (this.config.subagent !== false) {
155
+ this.fileCache = createSharedFileCache({
156
+ maxCacheBytes: 5 * 1024 * 1024, // 5MB
157
+ ttlMs: 5 * 60 * 1000, // 5 minutes
158
+ });
159
+ }
160
+ // Shared Budget Pool - pools token budget across parent and subagents
161
+ // Only parent agents create the pool; subagents don't need their own
162
+ // The pool is used in spawnAgent() to allocate budgets from the parent's total
163
+ if (this.config.subagent !== false) {
164
+ // Use actual configured budget (custom or default), not always STANDARD_BUDGET
165
+ const baseBudget = this.config.budget ?? STANDARD_BUDGET;
166
+ const parentBudgetTokens = baseBudget.maxTokens ?? STANDARD_BUDGET.maxTokens ?? 200000;
167
+ this.budgetPool = createBudgetPool(parentBudgetTokens, 0.25, 100000);
168
+ }
144
169
  // Initialize enabled features
145
170
  this.initializeFeatures();
146
171
  }
@@ -1689,28 +1714,42 @@ export class ProductionAgent {
1689
1714
  }
1690
1715
  }
1691
1716
  // Build system prompt using cache-aware builder if available (Trick P)
1692
- let systemPrompt;
1693
1717
  // Combine memory, learnings, and codebase context
1694
1718
  const combinedContext = [
1695
1719
  ...(memoryContext.length > 0 ? memoryContext : []),
1696
1720
  ...(learningsContext ? [learningsContext] : []),
1697
1721
  ...(codebaseContextStr ? [`\n## Relevant Code\n${codebaseContextStr}`] : []),
1698
1722
  ].join('\n');
1723
+ const promptOptions = {
1724
+ rules: rulesContent + (skillsPrompt ? '\n\n' + skillsPrompt : ''),
1725
+ tools: toolDescriptions,
1726
+ memory: combinedContext.length > 0 ? combinedContext : undefined,
1727
+ dynamic: {
1728
+ mode: this.modeManager?.getMode() ?? 'default',
1729
+ },
1730
+ };
1699
1731
  if (this.contextEngineering) {
1700
- // Use cache-optimized prompt builder - orders sections for KV-cache reuse:
1701
- // static prefix -> rules -> tools -> memory/codebase -> dynamic
1702
- systemPrompt = this.contextEngineering.buildSystemPrompt({
1703
- rules: rulesContent + (skillsPrompt ? '\n\n' + skillsPrompt : ''),
1704
- tools: toolDescriptions,
1705
- memory: combinedContext.length > 0 ? combinedContext : undefined,
1706
- dynamic: {
1707
- mode: this.modeManager?.getMode() ?? 'default',
1708
- },
1709
- });
1732
+ // Build cache-aware system prompt with cache_control markers (Improvement P1).
1733
+ // Store structured blocks for callLLM() to inject as MessageWithContent.
1734
+ // The string version is still used for token estimation and debugging.
1735
+ const cacheableBlocks = this.contextEngineering.buildCacheableSystemPrompt(promptOptions);
1736
+ // Safety check: ensure we have content (empty array = no cache context configured)
1737
+ if (cacheableBlocks.length === 0 || cacheableBlocks.every(b => b.text.trim().length === 0)) {
1738
+ this.cacheableSystemBlocks = null;
1739
+ messages.push({ role: 'system', content: this.config.systemPrompt || 'You are a helpful AI assistant.' });
1740
+ }
1741
+ else {
1742
+ // Store cacheable blocks for provider injection
1743
+ this.cacheableSystemBlocks = cacheableBlocks;
1744
+ // Push a regular string Message for backward compatibility (token estimation, etc.)
1745
+ const flatPrompt = cacheableBlocks.map(b => b.text).join('');
1746
+ messages.push({ role: 'system', content: flatPrompt });
1747
+ }
1710
1748
  }
1711
1749
  else {
1712
- // Fallback: manual concatenation (original behavior)
1713
- systemPrompt = this.config.systemPrompt;
1750
+ // Fallback: manual concatenation (original behavior) — no cache markers
1751
+ this.cacheableSystemBlocks = null;
1752
+ let systemPrompt = this.config.systemPrompt;
1714
1753
  if (rulesContent)
1715
1754
  systemPrompt += '\n\n' + rulesContent;
1716
1755
  if (skillsPrompt)
@@ -1721,13 +1760,13 @@ export class ProductionAgent {
1721
1760
  if (toolDescriptions) {
1722
1761
  systemPrompt += '\n\nAvailable tools:\n' + toolDescriptions;
1723
1762
  }
1763
+ // Safety check: ensure system prompt is not empty
1764
+ if (!systemPrompt || systemPrompt.trim().length === 0) {
1765
+ console.warn('[buildMessages] Warning: Empty system prompt detected, using fallback');
1766
+ systemPrompt = this.config.systemPrompt || 'You are a helpful AI assistant.';
1767
+ }
1768
+ messages.push({ role: 'system', content: systemPrompt });
1724
1769
  }
1725
- // Safety check: ensure system prompt is not empty
1726
- if (!systemPrompt || systemPrompt.trim().length === 0) {
1727
- console.warn('[buildMessages] Warning: Empty system prompt detected, using fallback');
1728
- systemPrompt = this.config.systemPrompt || 'You are a helpful AI assistant.';
1729
- }
1730
- messages.push({ role: 'system', content: systemPrompt });
1731
1770
  // Add existing conversation
1732
1771
  for (const msg of this.state.messages) {
1733
1772
  if (msg.role !== 'system') {
@@ -1744,6 +1783,22 @@ export class ProductionAgent {
1744
1783
  async callLLM(messages) {
1745
1784
  const spanId = this.observability?.tracer?.startSpan('llm.call');
1746
1785
  this.emit({ type: 'llm.start', model: this.config.model || 'default' });
1786
+ // Prompt caching (Improvement P1): Replace the system message with structured content
1787
+ // that includes cache_control markers, enabling 60-70% cache hit rates.
1788
+ // The original Message[] is kept for token estimation; the provider gets MessageWithContent[].
1789
+ let providerMessages = messages;
1790
+ if (this.cacheableSystemBlocks && this.cacheableSystemBlocks.length > 0) {
1791
+ providerMessages = messages.map((m, i) => {
1792
+ if (i === 0 && m.role === 'system') {
1793
+ // Replace system message with structured cacheable content
1794
+ return {
1795
+ role: 'system',
1796
+ content: this.cacheableSystemBlocks,
1797
+ };
1798
+ }
1799
+ return m;
1800
+ });
1801
+ }
1747
1802
  // Emit context insight for verbose feedback
1748
1803
  const estimatedTokens = messages.reduce((sum, m) => {
1749
1804
  const content = typeof m.content === 'string' ? m.content : JSON.stringify(m.content);
@@ -1859,7 +1914,7 @@ export class ProductionAgent {
1859
1914
  });
1860
1915
  }
1861
1916
  else {
1862
- response = await this.provider.chat(messages, {
1917
+ response = await this.provider.chat(providerMessages, {
1863
1918
  model: this.config.model,
1864
1919
  tools: Array.from(this.tools.values()),
1865
1920
  });
@@ -2132,6 +2187,29 @@ export class ProductionAgent {
2132
2187
  }
2133
2188
  }
2134
2189
  }
2190
+ // FILE CACHE: Check cache for read_file operations before executing
2191
+ if (this.fileCache && toolCall.name === 'read_file') {
2192
+ const args = toolCall.arguments;
2193
+ const readPath = String(args.path || '');
2194
+ if (readPath) {
2195
+ const cached = this.fileCache.get(readPath);
2196
+ if (cached !== undefined) {
2197
+ const lines = cached.split('\n').length;
2198
+ const cacheResult = { success: true, output: cached, metadata: { lines, bytes: cached.length, cached: true } };
2199
+ const duration = Date.now() - startTime;
2200
+ this.traceCollector?.record({ type: 'tool.end', data: { executionId, status: 'success', result: cacheResult, durationMs: duration } });
2201
+ this.observability?.metrics?.recordToolCall(toolCall.name, duration, true);
2202
+ this.state.metrics.toolCalls++;
2203
+ this.emit({ type: 'tool.complete', tool: toolCall.name, result: cacheResult });
2204
+ results.push({
2205
+ callId: toolCall.id,
2206
+ result: typeof cacheResult === 'string' ? cacheResult : JSON.stringify(cacheResult),
2207
+ });
2208
+ this.observability?.tracer?.endSpan(spanId);
2209
+ continue; // Skip actual file I/O
2210
+ }
2211
+ }
2212
+ }
2135
2213
  // Execute tool (with sandbox if available)
2136
2214
  let result;
2137
2215
  if (this.safety?.sandbox) {
@@ -2170,6 +2248,22 @@ export class ProductionAgent {
2170
2248
  this.observability?.metrics?.recordToolCall(toolCall.name, duration, true);
2171
2249
  this.state.metrics.toolCalls++;
2172
2250
  this.emit({ type: 'tool.complete', tool: toolCall.name, result });
2251
+ // FILE CACHE: Store read results and invalidate on writes
2252
+ if (this.fileCache) {
2253
+ const args = toolCall.arguments;
2254
+ const filePath = String(args.path || args.file_path || '');
2255
+ if (toolCall.name === 'read_file' && filePath) {
2256
+ // Cache successful read results
2257
+ const resultObj = result;
2258
+ if (resultObj?.success && typeof resultObj.output === 'string') {
2259
+ this.fileCache.set(filePath, resultObj.output);
2260
+ }
2261
+ }
2262
+ else if ((toolCall.name === 'write_file' || toolCall.name === 'edit_file' || toolCall.name === 'undo_file_change') && filePath) {
2263
+ // Invalidate cache when files are modified (including undo operations)
2264
+ this.fileCache.invalidate(filePath);
2265
+ }
2266
+ }
2173
2267
  // Emit tool insight with result summary
2174
2268
  const summary = this.summarizeToolResult(toolCall.name, result);
2175
2269
  this.emit({
@@ -3420,20 +3514,34 @@ export class ProductionAgent {
3420
3514
  }
3421
3515
  // Get subagent config with agent-type-specific timeouts and iteration limits
3422
3516
  // Uses dynamic configuration based on agent type (researcher needs more time than reviewer)
3517
+ // Precedence: per-type config > per-type default > global config > hardcoded fallback
3423
3518
  const subagentConfig = this.config.subagent;
3424
3519
  const hasSubagentConfig = subagentConfig !== false && subagentConfig !== undefined;
3425
- // Agent-type-specific timeout: researchers get 5min, reviewers get 2min, etc.
3520
+ // Timeout precedence: per-type config override > agent-type default > global config default
3426
3521
  const agentTypeTimeout = getSubagentTimeout(agentName);
3427
- const configTimeout = hasSubagentConfig
3522
+ const rawPerTypeTimeout = hasSubagentConfig
3523
+ ? subagentConfig.timeouts?.[agentName]
3524
+ : undefined;
3525
+ const rawGlobalTimeout = hasSubagentConfig
3428
3526
  ? subagentConfig.defaultTimeout
3429
3527
  : undefined;
3430
- const subagentTimeout = configTimeout ?? agentTypeTimeout;
3431
- // Agent-type-specific iteration limit: researchers get 25, documenters get 10, etc.
3528
+ // Validate: reject negative, NaN, or non-finite timeout values
3529
+ const isValidTimeout = (v) => v !== undefined && Number.isFinite(v) && v > 0;
3530
+ const perTypeConfigTimeout = isValidTimeout(rawPerTypeTimeout) ? rawPerTypeTimeout : undefined;
3531
+ const globalConfigTimeout = isValidTimeout(rawGlobalTimeout) ? rawGlobalTimeout : undefined;
3532
+ const subagentTimeout = perTypeConfigTimeout ?? agentTypeTimeout ?? globalConfigTimeout ?? 300000;
3533
+ // Iteration precedence: per-type config override > agent-type default > global config default
3432
3534
  const agentTypeMaxIter = getSubagentMaxIterations(agentName);
3433
- const configMaxIter = hasSubagentConfig
3535
+ const rawPerTypeMaxIter = hasSubagentConfig
3536
+ ? subagentConfig.maxIterations?.[agentName]
3537
+ : undefined;
3538
+ const rawGlobalMaxIter = hasSubagentConfig
3434
3539
  ? subagentConfig.defaultMaxIterations
3435
3540
  : undefined;
3436
- const defaultMaxIterations = agentDef.maxIterations ?? configMaxIter ?? agentTypeMaxIter;
3541
+ const isValidIter = (v) => v !== undefined && Number.isFinite(v) && v > 0 && Number.isInteger(v);
3542
+ const perTypeConfigMaxIter = isValidIter(rawPerTypeMaxIter) ? rawPerTypeMaxIter : undefined;
3543
+ const globalConfigMaxIter = isValidIter(rawGlobalMaxIter) ? rawGlobalMaxIter : undefined;
3544
+ const defaultMaxIterations = agentDef.maxIterations ?? perTypeConfigMaxIter ?? agentTypeMaxIter ?? globalConfigMaxIter ?? 15;
3437
3545
  // BLACKBOARD CONTEXT INJECTION
3438
3546
  // Gather relevant context from the blackboard for the subagent
3439
3547
  let blackboardContext = '';
@@ -3506,6 +3614,9 @@ export class ProductionAgent {
3506
3614
  const subagentSystemPrompt = parentMode === 'plan'
3507
3615
  ? `${agentDef.systemPrompt}\n\n${SUBAGENT_PLAN_MODE_ADDITION}${blackboardContext}${constraintContext}`
3508
3616
  : `${agentDef.systemPrompt}${blackboardContext}${constraintContext}`;
3617
+ // Allocate budget from pool (or use default) — track allocation ID for release later
3618
+ const pooledBudget = this.getSubagentBudget(agentName, constraints);
3619
+ const poolAllocationId = pooledBudget.allocationId;
3509
3620
  // Create a sub-agent with the agent's config
3510
3621
  // Use SUBAGENT_BUDGET to constrain resource usage (prevents runaway token consumption)
3511
3622
  const subAgent = new ProductionAgent({
@@ -3522,6 +3633,20 @@ export class ProductionAgent {
3522
3633
  memory: false,
3523
3634
  planning: false,
3524
3635
  reflection: false,
3636
+ // Enable lightweight compaction for subagents (Improvement P5)
3637
+ // tokenThreshold configures the Compactor's per-pass size limit
3638
+ // maxContextTokens constrains AutoCompactionManager's percentage thresholds
3639
+ // With maxContextTokens=80000 and default 80% threshold, compaction triggers at ~64K
3640
+ compaction: {
3641
+ enabled: true,
3642
+ mode: 'auto',
3643
+ tokenThreshold: 40000, // Compactor summarization size limit per pass
3644
+ preserveRecentCount: 4, // Preserve fewer messages (splits to 2 user + 2 assistant)
3645
+ preserveToolResults: false, // More aggressive — subagents can re-read files
3646
+ summaryMaxTokens: 500,
3647
+ },
3648
+ // Lower context window for subagents so percentage-based compaction triggers earlier
3649
+ maxContextTokens: 80000,
3525
3650
  observability: this.config.observability,
3526
3651
  sandbox: this.config.sandbox,
3527
3652
  humanInLoop: this.config.humanInLoop,
@@ -3535,11 +3660,11 @@ export class ProductionAgent {
3535
3660
  },
3536
3661
  // Share parent's blackboard for coordination between parallel subagents
3537
3662
  blackboard: this.blackboard || undefined,
3538
- // CONSTRAINED BUDGET: Subagents get smaller budget to prevent runaway consumption
3539
- // Uses SUBAGENT_BUDGET (100k tokens, 4 min) vs STANDARD_BUDGET (200k, 5 min)
3540
- budget: constraints?.maxTokens
3541
- ? { ...SUBAGENT_BUDGET, maxTokens: constraints.maxTokens }
3542
- : SUBAGENT_BUDGET,
3663
+ // Share parent's file cache to eliminate redundant reads across agents
3664
+ fileCache: this.fileCache || undefined,
3665
+ // CONSTRAINED BUDGET: Use pooled budget when available, falling back to SUBAGENT_BUDGET
3666
+ // Pooled budget ensures total tree cost stays bounded by parent's budget
3667
+ budget: pooledBudget.budget,
3543
3668
  });
3544
3669
  // CRITICAL: Subagent inherits parent's mode
3545
3670
  // This ensures that if parent is in plan mode:
@@ -3549,6 +3674,17 @@ export class ProductionAgent {
3549
3674
  if (parentMode !== 'build') {
3550
3675
  subAgent.setMode(parentMode);
3551
3676
  }
3677
+ // APPROVAL BATCHING (Improvement P6): Set approval scope for subagents
3678
+ // Read-only tools are auto-approved; write tools get scoped approval
3679
+ // This reduces interruptions from ~8 per session to ~1-2
3680
+ subAgent.setApprovalScope({
3681
+ autoApprove: ['read_file', 'list_files', 'glob', 'grep', 'show_file_history', 'show_session_changes'],
3682
+ scopedApprove: {
3683
+ write_file: { paths: ['src/', 'tests/', 'tools/'] },
3684
+ edit_file: { paths: ['src/', 'tests/', 'tools/'] },
3685
+ },
3686
+ requireApproval: ['bash', 'delete_file'],
3687
+ });
3552
3688
  // Pass parent's iteration count to subagent for accurate budget tracking
3553
3689
  // This prevents subagents from consuming excessive iterations when parent already used many
3554
3690
  subAgent.setParentIterations(this.getTotalIterations());
@@ -3899,6 +4035,13 @@ export class ProductionAgent {
3899
4035
  // Dispose both sources (linked source disposes its internal state, timeout source handles its timer)
3900
4036
  effectiveSource.dispose();
3901
4037
  progressAwareTimeout.dispose();
4038
+ // BUDGET POOL: Record actual usage and release the allocation
4039
+ // This must happen in finally to ensure cleanup on both success and error paths
4040
+ if (this.budgetPool && poolAllocationId) {
4041
+ const subMetrics = subAgent.getMetrics();
4042
+ this.budgetPool.recordUsage(poolAllocationId, subMetrics.totalTokens, subMetrics.estimatedCost);
4043
+ this.budgetPool.release(poolAllocationId);
4044
+ }
3902
4045
  }
3903
4046
  }
3904
4047
  catch (err) {
@@ -3926,6 +4069,49 @@ export class ProductionAgent {
3926
4069
  * Spawn multiple agents in parallel to work on independent tasks.
3927
4070
  * Uses the shared blackboard for coordination and conflict prevention.
3928
4071
  *
4072
+ * Get budget for a subagent, using the pooled budget when available.
4073
+ * Falls back to the static SUBAGENT_BUDGET if no pool is configured.
4074
+ * Returns both the budget and the pool allocation ID (if any) for tracking.
4075
+ */
4076
+ getSubagentBudget(agentName, constraints) {
4077
+ // If explicit maxTokens constraint, use that
4078
+ if (constraints?.maxTokens) {
4079
+ return {
4080
+ budget: { ...SUBAGENT_BUDGET, maxTokens: constraints.maxTokens },
4081
+ allocationId: null,
4082
+ };
4083
+ }
4084
+ // Try to allocate from the shared budget pool
4085
+ if (this.budgetPool) {
4086
+ const allocationId = `${agentName}-${Date.now()}`;
4087
+ const allocation = this.budgetPool.reserve(allocationId);
4088
+ if (allocation) {
4089
+ return {
4090
+ budget: {
4091
+ ...SUBAGENT_BUDGET,
4092
+ maxTokens: allocation.tokenBudget,
4093
+ softTokenLimit: Math.floor(allocation.tokenBudget * 0.7),
4094
+ maxCost: allocation.costBudget,
4095
+ },
4096
+ allocationId,
4097
+ };
4098
+ }
4099
+ // Pool exhausted — give a tiny emergency budget (just enough to report failure)
4100
+ // This does NOT bypass the pool — it's a fixed small cost for error messaging
4101
+ return {
4102
+ budget: {
4103
+ ...SUBAGENT_BUDGET,
4104
+ maxTokens: 5000,
4105
+ softTokenLimit: 3000,
4106
+ maxCost: 0.01,
4107
+ },
4108
+ allocationId: null,
4109
+ };
4110
+ }
4111
+ // No pool — use default subagent budget
4112
+ return { budget: SUBAGENT_BUDGET, allocationId: null };
4113
+ }
4114
+ /**
3929
4115
  * Uses Promise.allSettled to handle partial failures gracefully - if one
3930
4116
  * agent fails or times out, others can still complete successfully.
3931
4117
  */
@@ -4321,6 +4507,15 @@ If the task is a simple question or doesn't need specialized handling, set bestA
4321
4507
  setParentIterations(count) {
4322
4508
  this.parentIterations = count;
4323
4509
  }
4510
+ /**
4511
+ * Set an approval scope for this agent (used by parent when spawning subagents).
4512
+ * Enables pre-approved operations within a defined scope, reducing approval prompts.
4513
+ */
4514
+ setApprovalScope(scope) {
4515
+ if (this.safety?.humanInLoop) {
4516
+ this.safety.humanInLoop.setApprovalScope(scope);
4517
+ }
4518
+ }
4324
4519
  /**
4325
4520
  * Set an external cancellation token for this agent.
4326
4521
  * Used when spawning subagents to propagate parent timeout/cancellation.