attocode 0.1.0 → 0.1.2
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.
- package/CHANGELOG.md +32 -1
- package/README.md +14 -10
- package/dist/src/agent.d.ts +2 -0
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +265 -7
- package/dist/src/agent.js.map +1 -1
- package/dist/src/defaults.d.ts +9 -1
- package/dist/src/defaults.d.ts.map +1 -1
- package/dist/src/defaults.js +22 -0
- package/dist/src/defaults.js.map +1 -1
- package/dist/src/integrations/index.d.ts +6 -0
- package/dist/src/integrations/index.d.ts.map +1 -1
- package/dist/src/integrations/index.js +12 -0
- package/dist/src/integrations/index.js.map +1 -1
- package/dist/src/integrations/interactive-planning.d.ts +322 -0
- package/dist/src/integrations/interactive-planning.d.ts.map +1 -0
- package/dist/src/integrations/interactive-planning.js +655 -0
- package/dist/src/integrations/interactive-planning.js.map +1 -0
- package/dist/src/integrations/learning-store.d.ts +291 -0
- package/dist/src/integrations/learning-store.d.ts.map +1 -0
- package/dist/src/integrations/learning-store.js +640 -0
- package/dist/src/integrations/learning-store.js.map +1 -0
- package/dist/src/integrations/pending-plan.d.ts.map +1 -1
- package/dist/src/integrations/pending-plan.js +69 -10
- package/dist/src/integrations/pending-plan.js.map +1 -1
- package/dist/src/providers/circuit-breaker.d.ts +180 -0
- package/dist/src/providers/circuit-breaker.d.ts.map +1 -0
- package/dist/src/providers/circuit-breaker.js +349 -0
- package/dist/src/providers/circuit-breaker.js.map +1 -0
- package/dist/src/providers/fallback-chain.d.ts +194 -0
- package/dist/src/providers/fallback-chain.d.ts.map +1 -0
- package/dist/src/providers/fallback-chain.js +363 -0
- package/dist/src/providers/fallback-chain.js.map +1 -0
- package/dist/src/providers/llm-resilience.d.ts +126 -0
- package/dist/src/providers/llm-resilience.d.ts.map +1 -0
- package/dist/src/providers/llm-resilience.js +261 -0
- package/dist/src/providers/llm-resilience.js.map +1 -0
- package/dist/src/providers/resilient-provider.d.ts +124 -0
- package/dist/src/providers/resilient-provider.d.ts.map +1 -0
- package/dist/src/providers/resilient-provider.js +242 -0
- package/dist/src/providers/resilient-provider.js.map +1 -0
- package/dist/src/tricks/recursive-context.d.ts +296 -0
- package/dist/src/tricks/recursive-context.d.ts.map +1 -0
- package/dist/src/tricks/recursive-context.js +518 -0
- package/dist/src/tricks/recursive-context.js.map +1 -0
- package/dist/src/tui/app.d.ts.map +1 -1
- package/dist/src/tui/app.js +97 -17
- package/dist/src/tui/app.js.map +1 -1
- package/dist/src/tui/components/ApprovalDialog.d.ts.map +1 -1
- package/dist/src/tui/components/ApprovalDialog.js +1 -1
- package/dist/src/tui/components/ApprovalDialog.js.map +1 -1
- package/dist/src/types.d.ts +61 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.2] - 2026-01-28
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Interactive Planning** - Step-by-step collaborative planning with user approval gates
|
|
14
|
+
- Plan creation, modification, and execution workflows
|
|
15
|
+
- Plan step dependencies and status tracking
|
|
16
|
+
- TUI integration for plan display
|
|
17
|
+
- **Learning Store** - Session-to-session learning from successes and failures
|
|
18
|
+
- Pattern extraction from outcomes
|
|
19
|
+
- Contextual learning retrieval for similar tasks
|
|
20
|
+
- SQLite persistence for learning data
|
|
21
|
+
- **LLM Resilience** - Production-grade provider reliability
|
|
22
|
+
- Circuit breaker pattern with configurable thresholds
|
|
23
|
+
- Fallback chain for multi-provider redundancy
|
|
24
|
+
- Automatic retry with exponential backoff
|
|
25
|
+
- Health monitoring and recovery
|
|
26
|
+
- **Recursive Context** - Context engineering for complex hierarchical tasks
|
|
27
|
+
- Nested context management with parent-child relationships
|
|
28
|
+
- Automatic context inheritance and scoping
|
|
29
|
+
- **Subagent Event Context** - Enhanced subagent spawning with event propagation
|
|
30
|
+
- **Context Token Metrics** - Track token usage across context operations
|
|
31
|
+
|
|
32
|
+
### Documentation
|
|
33
|
+
- New `docs/architecture.md` - Comprehensive architecture overview with diagrams
|
|
34
|
+
- New `docs/extending.md` - Guide for extending attocode with custom providers, tools, and tricks
|
|
35
|
+
|
|
36
|
+
## [0.1.1] - 2026-01-27
|
|
37
|
+
|
|
10
38
|
### Added
|
|
39
|
+
- "Always Allow" option (`[A]`) in TUI approval dialog - auto-approves matching commands for the session
|
|
11
40
|
- TUI permission approval system with safety fallbacks
|
|
12
41
|
- Architecture diagrams in CLAUDE.md documentation
|
|
13
42
|
|
|
@@ -44,5 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
44
73
|
- Sandbox execution for bash commands (macOS Seatbelt)
|
|
45
74
|
- Dangerous operation blocking in strict mode
|
|
46
75
|
|
|
47
|
-
[Unreleased]: https://github.com/eren23/attocode/compare/v0.1.
|
|
76
|
+
[Unreleased]: https://github.com/eren23/attocode/compare/v0.1.2...HEAD
|
|
77
|
+
[0.1.2]: https://github.com/eren23/attocode/compare/v0.1.1...v0.1.2
|
|
78
|
+
[0.1.1]: https://github.com/eren23/attocode/compare/v0.1.0...v0.1.1
|
|
48
79
|
[0.1.0]: https://github.com/eren23/attocode/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -15,20 +15,21 @@ A production-ready AI coding agent for your terminal.
|
|
|
15
15
|
|
|
16
16
|
## Quick Start
|
|
17
17
|
|
|
18
|
-
### 1. Install
|
|
18
|
+
### 1. Install
|
|
19
|
+
|
|
20
|
+
**From npm (recommended):**
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g attocode
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Or build from source:**
|
|
19
27
|
|
|
20
28
|
```bash
|
|
21
|
-
# Clone the repo
|
|
22
29
|
git clone https://github.com/eren23/attocode.git
|
|
23
30
|
cd attocode
|
|
24
|
-
|
|
25
|
-
# Install dependencies
|
|
26
31
|
npm install
|
|
27
|
-
|
|
28
|
-
# Build
|
|
29
32
|
npm run build
|
|
30
|
-
|
|
31
|
-
# Install globally
|
|
32
33
|
npm link
|
|
33
34
|
```
|
|
34
35
|
|
|
@@ -153,10 +154,13 @@ Options:
|
|
|
153
154
|
## Uninstall
|
|
154
155
|
|
|
155
156
|
```bash
|
|
156
|
-
#
|
|
157
|
+
# If installed from npm
|
|
158
|
+
npm uninstall -g attocode
|
|
159
|
+
|
|
160
|
+
# If installed from source
|
|
157
161
|
npm unlink -g attocode
|
|
158
162
|
|
|
159
|
-
# Remove config (optional)
|
|
163
|
+
# Remove config and data (optional)
|
|
160
164
|
rm -rf ~/.config/attocode
|
|
161
165
|
rm -rf ~/.local/share/attocode
|
|
162
166
|
rm -rf ~/.local/state/attocode
|
package/dist/src/agent.d.ts
CHANGED
package/dist/src/agent.d.ts.map
CHANGED
|
@@ -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;AAQpB,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EA0BL,UAAU,EAaV,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,KAA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a,CAAC,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"}
|
package/dist/src/agent.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import { buildConfig, isFeatureEnabled, getEnabledFeatures, } from './defaults.js';
|
|
22
22
|
import { createModeManager, formatModeList, parseMode, } 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, AgentRegistry, filterToolsForAgent, formatAgentList, createCancellationManager, isCancellationError, createResourceManager, createLSPManager, createSemanticCacheManager, createSkillManager, formatSkillList, createContextEngineering, stableStringify, createCodebaseContext, buildContextFromChunks, createPendingPlanManager, } from './integrations/index.js';
|
|
24
|
+
import { HookManager, MemoryManager, PlanningManager, ObservabilityManager, SafetyManager, RoutingManager, MultiAgentManager, ReActManager, ExecutionPolicyManager, ThreadManager, RulesManager, DEFAULT_RULE_SOURCES, ExecutionEconomicsManager, STANDARD_BUDGET, AgentRegistry, filterToolsForAgent, formatAgentList, createCancellationManager, isCancellationError, createResourceManager, createLSPManager, createSemanticCacheManager, createSkillManager, formatSkillList, createContextEngineering, stableStringify, createCodebaseContext, buildContextFromChunks, createPendingPlanManager, createInteractivePlanner, createRecursiveContext, } from './integrations/index.js';
|
|
25
25
|
// Lesson 26: Tracing & Evaluation integration
|
|
26
26
|
import { createTraceCollector } from './tracing/trace-collector.js';
|
|
27
27
|
// Spawn agent tool for LLM-driven subagent delegation
|
|
@@ -60,6 +60,8 @@ export class ProductionAgent {
|
|
|
60
60
|
traceCollector = null;
|
|
61
61
|
modeManager;
|
|
62
62
|
pendingPlanManager;
|
|
63
|
+
interactivePlanner = null;
|
|
64
|
+
recursiveContext = null;
|
|
63
65
|
toolResolver = null;
|
|
64
66
|
// Initialization tracking
|
|
65
67
|
initPromises = [];
|
|
@@ -327,6 +329,87 @@ export class ProductionAgent {
|
|
|
327
329
|
break;
|
|
328
330
|
}
|
|
329
331
|
});
|
|
332
|
+
// Interactive Planning (conversational + editable planning)
|
|
333
|
+
if (isFeatureEnabled(this.config.interactivePlanning)) {
|
|
334
|
+
const interactiveConfig = typeof this.config.interactivePlanning === 'object'
|
|
335
|
+
? this.config.interactivePlanning
|
|
336
|
+
: {};
|
|
337
|
+
this.interactivePlanner = createInteractivePlanner({
|
|
338
|
+
autoCheckpoint: interactiveConfig.enableCheckpoints ?? true,
|
|
339
|
+
confirmBeforeExecute: interactiveConfig.requireApproval ?? true,
|
|
340
|
+
maxCheckpoints: 20,
|
|
341
|
+
autoPauseAtDecisions: true,
|
|
342
|
+
});
|
|
343
|
+
// Forward planner events to observability
|
|
344
|
+
this.interactivePlanner.on(event => {
|
|
345
|
+
switch (event.type) {
|
|
346
|
+
case 'plan.created':
|
|
347
|
+
this.observability?.logger?.info('Interactive plan created', {
|
|
348
|
+
planId: event.plan.id,
|
|
349
|
+
stepCount: event.plan.steps.length,
|
|
350
|
+
});
|
|
351
|
+
break;
|
|
352
|
+
case 'step.completed':
|
|
353
|
+
this.observability?.logger?.debug('Plan step completed', {
|
|
354
|
+
stepId: event.step.id,
|
|
355
|
+
status: event.step.status,
|
|
356
|
+
});
|
|
357
|
+
break;
|
|
358
|
+
case 'plan.cancelled':
|
|
359
|
+
this.observability?.logger?.info('Plan cancelled', { reason: event.reason });
|
|
360
|
+
break;
|
|
361
|
+
case 'checkpoint.created':
|
|
362
|
+
this.observability?.logger?.debug('Plan checkpoint created', {
|
|
363
|
+
checkpointId: event.checkpoint.id,
|
|
364
|
+
});
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
// Recursive Context (RLM - Recursive Language Models)
|
|
370
|
+
// Enables on-demand context exploration for large codebases
|
|
371
|
+
if (isFeatureEnabled(this.config.recursiveContext)) {
|
|
372
|
+
const recursiveConfig = typeof this.config.recursiveContext === 'object'
|
|
373
|
+
? this.config.recursiveContext
|
|
374
|
+
: {};
|
|
375
|
+
this.recursiveContext = createRecursiveContext({
|
|
376
|
+
maxDepth: recursiveConfig.maxRecursionDepth ?? 5,
|
|
377
|
+
snippetTokens: recursiveConfig.maxSnippetTokens ?? 2000,
|
|
378
|
+
synthesisTokens: 1000,
|
|
379
|
+
totalBudget: 50000,
|
|
380
|
+
cacheResults: recursiveConfig.cacheNavigationResults ?? true,
|
|
381
|
+
});
|
|
382
|
+
// Note: File system source should be registered when needed with proper glob/readFile functions
|
|
383
|
+
// This is deferred to allow flexible configuration
|
|
384
|
+
// Forward RLM events
|
|
385
|
+
this.recursiveContext.on(event => {
|
|
386
|
+
switch (event.type) {
|
|
387
|
+
case 'process.started':
|
|
388
|
+
this.observability?.logger?.debug('RLM process started', {
|
|
389
|
+
query: event.query,
|
|
390
|
+
depth: event.depth,
|
|
391
|
+
});
|
|
392
|
+
break;
|
|
393
|
+
case 'navigation.command':
|
|
394
|
+
this.observability?.logger?.debug('RLM navigation command', {
|
|
395
|
+
command: event.command,
|
|
396
|
+
depth: event.depth,
|
|
397
|
+
});
|
|
398
|
+
break;
|
|
399
|
+
case 'process.completed':
|
|
400
|
+
this.observability?.logger?.debug('RLM process completed', {
|
|
401
|
+
stats: event.stats,
|
|
402
|
+
});
|
|
403
|
+
break;
|
|
404
|
+
case 'budget.warning':
|
|
405
|
+
this.observability?.logger?.warn('RLM budget warning', {
|
|
406
|
+
remaining: event.remaining,
|
|
407
|
+
total: event.total,
|
|
408
|
+
});
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
330
413
|
}
|
|
331
414
|
/**
|
|
332
415
|
* Ensure all async initialization is complete before running.
|
|
@@ -518,11 +601,82 @@ export class ProductionAgent {
|
|
|
518
601
|
}
|
|
519
602
|
// =======================================================================
|
|
520
603
|
// ECONOMICS CHECK (Token Budget) - replaces hard iteration limit
|
|
604
|
+
// With recovery: try compaction before giving up on token limits
|
|
521
605
|
// =======================================================================
|
|
522
606
|
if (this.economics) {
|
|
523
607
|
const budgetCheck = this.economics.checkBudget();
|
|
524
608
|
if (!budgetCheck.canContinue) {
|
|
525
|
-
//
|
|
609
|
+
// ===================================================================
|
|
610
|
+
// RECOVERY ATTEMPT: Try emergency context reduction before giving up
|
|
611
|
+
// Only for token-based limits, not iteration limits
|
|
612
|
+
// ===================================================================
|
|
613
|
+
const isTokenLimit = budgetCheck.budgetType === 'tokens' || budgetCheck.budgetType === 'cost';
|
|
614
|
+
const alreadyTriedRecovery = this.state._recoveryAttempted === true;
|
|
615
|
+
if (isTokenLimit && !alreadyTriedRecovery) {
|
|
616
|
+
this.observability?.logger?.info('Budget limit reached, attempting recovery via context reduction', {
|
|
617
|
+
reason: budgetCheck.reason,
|
|
618
|
+
percentUsed: budgetCheck.percentUsed,
|
|
619
|
+
});
|
|
620
|
+
this.emit({
|
|
621
|
+
type: 'resilience.retry',
|
|
622
|
+
reason: 'budget_limit_compaction',
|
|
623
|
+
attempt: 1,
|
|
624
|
+
maxAttempts: 1,
|
|
625
|
+
});
|
|
626
|
+
// Mark that we've attempted recovery to prevent infinite loops
|
|
627
|
+
this.state._recoveryAttempted = true;
|
|
628
|
+
const tokensBefore = this.estimateContextTokens(messages);
|
|
629
|
+
// Step 1: Compact tool outputs aggressively
|
|
630
|
+
this.compactToolOutputs();
|
|
631
|
+
// Step 2: Emergency truncation - keep system + last N messages
|
|
632
|
+
const PRESERVE_RECENT = 10;
|
|
633
|
+
if (messages.length > PRESERVE_RECENT + 2) {
|
|
634
|
+
const systemMessage = messages.find(m => m.role === 'system');
|
|
635
|
+
const recentMessages = messages.slice(-(PRESERVE_RECENT));
|
|
636
|
+
// Rebuild message array
|
|
637
|
+
messages.length = 0;
|
|
638
|
+
if (systemMessage) {
|
|
639
|
+
messages.push(systemMessage);
|
|
640
|
+
}
|
|
641
|
+
messages.push({
|
|
642
|
+
role: 'system',
|
|
643
|
+
content: `[CONTEXT REDUCED: Earlier messages were removed to stay within budget. Conversation continues from recent context.]`,
|
|
644
|
+
});
|
|
645
|
+
messages.push(...recentMessages);
|
|
646
|
+
// Update state messages too
|
|
647
|
+
this.state.messages.length = 0;
|
|
648
|
+
this.state.messages.push(...messages);
|
|
649
|
+
}
|
|
650
|
+
const tokensAfter = this.estimateContextTokens(messages);
|
|
651
|
+
const reduction = Math.round((1 - tokensAfter / tokensBefore) * 100);
|
|
652
|
+
if (tokensAfter < tokensBefore * 0.8) {
|
|
653
|
+
// Significant reduction achieved
|
|
654
|
+
this.observability?.logger?.info('Context reduction successful, continuing execution', {
|
|
655
|
+
tokensBefore,
|
|
656
|
+
tokensAfter,
|
|
657
|
+
reduction,
|
|
658
|
+
});
|
|
659
|
+
this.emit({
|
|
660
|
+
type: 'resilience.recovered',
|
|
661
|
+
reason: 'budget_limit_compaction',
|
|
662
|
+
attempts: 1,
|
|
663
|
+
});
|
|
664
|
+
this.emit({
|
|
665
|
+
type: 'compaction.auto',
|
|
666
|
+
tokensBefore,
|
|
667
|
+
tokensAfter,
|
|
668
|
+
messagesCompacted: tokensBefore - tokensAfter,
|
|
669
|
+
});
|
|
670
|
+
// Continue execution instead of breaking
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
this.observability?.logger?.warn('Context reduction insufficient', {
|
|
674
|
+
tokensBefore,
|
|
675
|
+
tokensAfter,
|
|
676
|
+
reduction,
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
// Hard limit reached and recovery failed (or not applicable)
|
|
526
680
|
this.observability?.logger?.warn('Budget limit reached', {
|
|
527
681
|
reason: budgetCheck.reason,
|
|
528
682
|
budgetType: budgetCheck.budgetType,
|
|
@@ -617,8 +771,97 @@ export class ProductionAgent {
|
|
|
617
771
|
}
|
|
618
772
|
}
|
|
619
773
|
}
|
|
620
|
-
//
|
|
621
|
-
|
|
774
|
+
// =====================================================================
|
|
775
|
+
// RESILIENT LLM CALL: Empty response retries + max_tokens continuation
|
|
776
|
+
// =====================================================================
|
|
777
|
+
const MAX_EMPTY_RETRIES = 2;
|
|
778
|
+
const MAX_CONTINUATIONS = 3;
|
|
779
|
+
let response = await this.callLLM(messages);
|
|
780
|
+
let emptyRetries = 0;
|
|
781
|
+
let continuations = 0;
|
|
782
|
+
// Phase 1: Handle empty responses with retry
|
|
783
|
+
while (emptyRetries < MAX_EMPTY_RETRIES) {
|
|
784
|
+
const hasContent = response.content && response.content.length > 0;
|
|
785
|
+
const hasToolCalls = response.toolCalls && response.toolCalls.length > 0;
|
|
786
|
+
if (hasContent || hasToolCalls) {
|
|
787
|
+
// Valid response received
|
|
788
|
+
if (emptyRetries > 0) {
|
|
789
|
+
this.emit({
|
|
790
|
+
type: 'resilience.recovered',
|
|
791
|
+
reason: 'empty_response',
|
|
792
|
+
attempts: emptyRetries,
|
|
793
|
+
});
|
|
794
|
+
this.observability?.logger?.info('Recovered from empty response', {
|
|
795
|
+
retries: emptyRetries,
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
break;
|
|
799
|
+
}
|
|
800
|
+
// Empty response - retry with nudge
|
|
801
|
+
emptyRetries++;
|
|
802
|
+
this.emit({
|
|
803
|
+
type: 'resilience.retry',
|
|
804
|
+
reason: 'empty_response',
|
|
805
|
+
attempt: emptyRetries,
|
|
806
|
+
maxAttempts: MAX_EMPTY_RETRIES,
|
|
807
|
+
});
|
|
808
|
+
this.observability?.logger?.warn('Empty LLM response, retrying', {
|
|
809
|
+
attempt: emptyRetries,
|
|
810
|
+
maxAttempts: MAX_EMPTY_RETRIES,
|
|
811
|
+
});
|
|
812
|
+
// Add gentle nudge and retry
|
|
813
|
+
const nudgeMessage = {
|
|
814
|
+
role: 'user',
|
|
815
|
+
content: '[System: Your previous response was empty. Please provide a response or use a tool.]',
|
|
816
|
+
};
|
|
817
|
+
messages.push(nudgeMessage);
|
|
818
|
+
this.state.messages.push(nudgeMessage);
|
|
819
|
+
response = await this.callLLM(messages);
|
|
820
|
+
}
|
|
821
|
+
// Phase 2: Handle max_tokens truncation with continuation
|
|
822
|
+
if (response.stopReason === 'max_tokens' && !response.toolCalls?.length) {
|
|
823
|
+
let accumulatedContent = response.content || '';
|
|
824
|
+
while (continuations < MAX_CONTINUATIONS && response.stopReason === 'max_tokens') {
|
|
825
|
+
continuations++;
|
|
826
|
+
this.emit({
|
|
827
|
+
type: 'resilience.continue',
|
|
828
|
+
reason: 'max_tokens',
|
|
829
|
+
continuation: continuations,
|
|
830
|
+
maxContinuations: MAX_CONTINUATIONS,
|
|
831
|
+
accumulatedLength: accumulatedContent.length,
|
|
832
|
+
});
|
|
833
|
+
this.observability?.logger?.info('Response truncated at max_tokens, continuing', {
|
|
834
|
+
continuation: continuations,
|
|
835
|
+
accumulatedLength: accumulatedContent.length,
|
|
836
|
+
});
|
|
837
|
+
// Add continuation request
|
|
838
|
+
const continuationMessage = {
|
|
839
|
+
role: 'assistant',
|
|
840
|
+
content: accumulatedContent,
|
|
841
|
+
};
|
|
842
|
+
const continueRequest = {
|
|
843
|
+
role: 'user',
|
|
844
|
+
content: '[System: Please continue from where you left off. Do not repeat what you already said.]',
|
|
845
|
+
};
|
|
846
|
+
messages.push(continuationMessage, continueRequest);
|
|
847
|
+
this.state.messages.push(continuationMessage, continueRequest);
|
|
848
|
+
response = await this.callLLM(messages);
|
|
849
|
+
// Accumulate content
|
|
850
|
+
if (response.content) {
|
|
851
|
+
accumulatedContent += response.content;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
// Update response with accumulated content
|
|
855
|
+
if (continuations > 0) {
|
|
856
|
+
response = { ...response, content: accumulatedContent };
|
|
857
|
+
this.emit({
|
|
858
|
+
type: 'resilience.completed',
|
|
859
|
+
reason: 'max_tokens_continuation',
|
|
860
|
+
continuations,
|
|
861
|
+
finalLength: accumulatedContent.length,
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
}
|
|
622
865
|
// Record LLM usage for economics
|
|
623
866
|
if (this.economics && response.usage) {
|
|
624
867
|
this.economics.recordLLMUsage(response.usage.inputTokens, response.usage.outputTokens, this.config.model, response.usage.cost // Use actual cost from provider when available
|
|
@@ -639,6 +882,20 @@ export class ProductionAgent {
|
|
|
639
882
|
// The model has "consumed" the tool outputs and produced a response,
|
|
640
883
|
// so we can replace verbose outputs with compact summaries
|
|
641
884
|
this.compactToolOutputs();
|
|
885
|
+
// Final validation: warn if response is still empty after all retries
|
|
886
|
+
if (!response.content || response.content.length === 0) {
|
|
887
|
+
this.observability?.logger?.error('Agent finished with empty response after all retries', {
|
|
888
|
+
emptyRetries,
|
|
889
|
+
continuations,
|
|
890
|
+
iteration: this.state.iteration,
|
|
891
|
+
});
|
|
892
|
+
this.emit({
|
|
893
|
+
type: 'resilience.failed',
|
|
894
|
+
reason: 'empty_final_response',
|
|
895
|
+
emptyRetries,
|
|
896
|
+
continuations,
|
|
897
|
+
});
|
|
898
|
+
}
|
|
642
899
|
break;
|
|
643
900
|
}
|
|
644
901
|
// Execute tool calls
|
|
@@ -2054,10 +2311,11 @@ export class ProductionAgent {
|
|
|
2054
2311
|
custom: [],
|
|
2055
2312
|
},
|
|
2056
2313
|
});
|
|
2057
|
-
// Forward events from subagent
|
|
2314
|
+
// Forward events from subagent with context
|
|
2058
2315
|
subAgent.subscribe(event => {
|
|
2059
|
-
//
|
|
2060
|
-
|
|
2316
|
+
// Tag event with subagent source so TUI can display it properly
|
|
2317
|
+
const taggedEvent = { ...event, subagent: agentName };
|
|
2318
|
+
this.emit(taggedEvent);
|
|
2061
2319
|
});
|
|
2062
2320
|
// Run the task
|
|
2063
2321
|
const result = await subAgent.run(task);
|