@causyne/agent 1.20.22 → 1.20.23
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/package.json +1 -1
- package/src/agentLoop.js +21 -0
- package/src/agentLoop.ts +22 -0
- package/src/providers/antigravity.js +26 -9
- package/src/providers/antigravity.ts +25 -8
package/package.json
CHANGED
package/src/agentLoop.js
CHANGED
|
@@ -1744,6 +1744,7 @@ export class AgentLoop {
|
|
|
1744
1744
|
let planHandoffRecoveries = 0;
|
|
1745
1745
|
let incompleteTurnContinuations = 0;
|
|
1746
1746
|
let toolRoutingRecoveries = 0;
|
|
1747
|
+
let emptyResponseRecoveries = 0;
|
|
1747
1748
|
// The core loop governed by Sovereign Human-in-the-Loop Checkpoints
|
|
1748
1749
|
while (!this.stopRequested) {
|
|
1749
1750
|
if (this.stopRequested) {
|
|
@@ -4033,6 +4034,26 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4033
4034
|
this.emitEvent({ type: 'error', message: 'The provider continued read-only inspection after a corrective checkpoint. The task remains unfinished; no edit was verified.' });
|
|
4034
4035
|
break;
|
|
4035
4036
|
}
|
|
4037
|
+
if (e?.code === 'PROVIDER_EMPTY_RESPONSE'
|
|
4038
|
+
|| (typeof e?.message === 'string' && e.message.includes('returned no response'))) {
|
|
4039
|
+
if (emptyResponseRecoveries++ < 5) {
|
|
4040
|
+
this.emitEvent({
|
|
4041
|
+
type: 'notice',
|
|
4042
|
+
message: `Peer connection was interrupted or returned no response (${emptyResponseRecoveries}/5). Auto-reconnecting session and resuming task…`
|
|
4043
|
+
});
|
|
4044
|
+
auditLog.log({ event: 'peer_empty_response_recovery', taskId: this.taskId, attempt: emptyResponseRecoveries, error: e.message });
|
|
4045
|
+
const planNotice = this._implementationPlan?.length > 0
|
|
4046
|
+
? ` Active plan has ${this._implementationPlan.filter((s) => s.status === 'completed' || s.completed).length}/${this._implementationPlan.length} steps completed.`
|
|
4047
|
+
: '';
|
|
4048
|
+
this.messages.push({
|
|
4049
|
+
role: 'system',
|
|
4050
|
+
content: `[RECONNECTION RECOVERY: The previous peer turn disconnected or returned no response.${planNotice} Disk files and modifications are preserved. Do NOT repeat completed work. Continue executing the next unfinished step of the task directly.]`
|
|
4051
|
+
});
|
|
4052
|
+
this.memoryManager.saveHistory(this.messages);
|
|
4053
|
+
await this.backoff(emptyResponseRecoveries);
|
|
4054
|
+
continue;
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4036
4057
|
if (this.stopRequested || this.abortController?.signal?.aborted || e?.name === 'AbortError') {
|
|
4037
4058
|
this.debugLog(`agent loop interrupted: ${e?.message || 'aborted'}`);
|
|
4038
4059
|
auditLog.log({ event: 'task_interrupted', taskId: this.taskId });
|
package/src/agentLoop.ts
CHANGED
|
@@ -1841,6 +1841,7 @@ export class AgentLoop {
|
|
|
1841
1841
|
let planHandoffRecoveries = 0;
|
|
1842
1842
|
let incompleteTurnContinuations = 0;
|
|
1843
1843
|
let toolRoutingRecoveries = 0;
|
|
1844
|
+
let emptyResponseRecoveries = 0;
|
|
1844
1845
|
|
|
1845
1846
|
// The core loop governed by Sovereign Human-in-the-Loop Checkpoints
|
|
1846
1847
|
while (!this.stopRequested) {
|
|
@@ -4282,6 +4283,27 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
4282
4283
|
'The provider continued read-only inspection after a corrective checkpoint. The task remains unfinished; no edit was verified.' });
|
|
4283
4284
|
break;
|
|
4284
4285
|
}
|
|
4286
|
+
if (e?.code === 'PROVIDER_EMPTY_RESPONSE'
|
|
4287
|
+
|| (typeof e?.message === 'string' && e.message.includes('returned no response'))) {
|
|
4288
|
+
if (emptyResponseRecoveries++ < 5) {
|
|
4289
|
+
this.emitEvent({
|
|
4290
|
+
type: 'notice',
|
|
4291
|
+
message: `Peer connection was interrupted or returned no response (${emptyResponseRecoveries}/5). Auto-reconnecting session and resuming task…`
|
|
4292
|
+
});
|
|
4293
|
+
auditLog.log({ event: 'peer_empty_response_recovery', taskId: this.taskId, attempt: emptyResponseRecoveries, error: e.message });
|
|
4294
|
+
|
|
4295
|
+
const planNotice = this._implementationPlan?.length > 0
|
|
4296
|
+
? ` Active plan has ${this._implementationPlan.filter((s: any) => s.status === 'completed' || s.completed).length}/${this._implementationPlan.length} steps completed.`
|
|
4297
|
+
: '';
|
|
4298
|
+
this.messages.push({
|
|
4299
|
+
role: 'system',
|
|
4300
|
+
content: `[RECONNECTION RECOVERY: The previous peer turn disconnected or returned no response.${planNotice} Disk files and modifications are preserved. Do NOT repeat completed work. Continue executing the next unfinished step of the task directly.]`
|
|
4301
|
+
});
|
|
4302
|
+
this.memoryManager.saveHistory(this.messages);
|
|
4303
|
+
await this.backoff(emptyResponseRecoveries);
|
|
4304
|
+
continue;
|
|
4305
|
+
}
|
|
4306
|
+
}
|
|
4285
4307
|
if (this.stopRequested || this.abortController?.signal?.aborted || e?.name === 'AbortError') {
|
|
4286
4308
|
this.debugLog(`agent loop interrupted: ${e?.message || 'aborted'}`);
|
|
4287
4309
|
auditLog.log({ event: 'task_interrupted', taskId: this.taskId });
|
|
@@ -1487,10 +1487,20 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1487
1487
|
content = '';
|
|
1488
1488
|
}
|
|
1489
1489
|
const completedNativeActions = nativeActions.filter((a) => a.status === 'completed');
|
|
1490
|
-
if (!content &&
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
.
|
|
1490
|
+
if (!content && toolCalls.length === 0 && deniedActions.length === 0) {
|
|
1491
|
+
const anyActions = completedNativeActions.length > 0
|
|
1492
|
+
? completedNativeActions
|
|
1493
|
+
: nativeActions.length > 0
|
|
1494
|
+
? nativeActions
|
|
1495
|
+
: attemptedNativeTools;
|
|
1496
|
+
if (anyActions.length > 0) {
|
|
1497
|
+
content = `Antigravity executed: ${anyActions
|
|
1498
|
+
.map((a) => `${a.name}${a.detail ? ` (${a.detail})` : ''}`)
|
|
1499
|
+
.join(', ')}`;
|
|
1500
|
+
}
|
|
1501
|
+
else if (rawContent.trim()) {
|
|
1502
|
+
content = rawContent.trim();
|
|
1503
|
+
}
|
|
1494
1504
|
}
|
|
1495
1505
|
const usageIsReported = finalResultObj?.usage?.input_tokens != null
|
|
1496
1506
|
&& finalResultObj?.usage?.output_tokens != null
|
|
@@ -1599,17 +1609,24 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1599
1609
|
if (options.signal?.aborted || err?.name === 'AbortError') {
|
|
1600
1610
|
throw err;
|
|
1601
1611
|
}
|
|
1602
|
-
if (err?.code === 'PROVIDER_NO_PROGRESS')
|
|
1603
|
-
throw err;
|
|
1604
|
-
if (err?.partialUsage?.promptTokens + err?.partialUsage?.completionTokens > 0) {
|
|
1612
|
+
if (err?.code === 'AGY_NATIVE_ACTION_DENIED' || err?.code === 'AGY_TOKEN_BUDGET' || err?.code === 'PROVIDER_NO_PROGRESS') {
|
|
1605
1613
|
throw err;
|
|
1606
1614
|
}
|
|
1615
|
+
const msg = String(err?.message || '').toLowerCase();
|
|
1616
|
+
const isTransient = this._isTransientError(msg)
|
|
1617
|
+
|| err?.code === 'PROVIDER_EMPTY_RESPONSE'
|
|
1618
|
+
|| msg.includes('returned no response')
|
|
1619
|
+
|| msg.includes('connection reset')
|
|
1620
|
+
|| msg.includes('econnreset')
|
|
1621
|
+
|| msg.includes('socket hang up')
|
|
1622
|
+
|| msg.includes('streamgeneratecontent');
|
|
1607
1623
|
const canRetryResetConversation = hadConversation && !this.currentConversationId
|
|
1608
1624
|
&& err?.code !== 'AGY_NATIVE_ACTION_DENIED'
|
|
1609
1625
|
&& err?.code !== 'AGY_TOKEN_BUDGET';
|
|
1610
|
-
if (attempt < maxRetries && (
|
|
1626
|
+
if (attempt < maxRetries && (isTransient || canRetryResetConversation)) {
|
|
1611
1627
|
attempt++;
|
|
1612
|
-
|
|
1628
|
+
this.currentConversationId = null;
|
|
1629
|
+
const delay = Math.min(attempt * 1200, 3000);
|
|
1613
1630
|
await new Promise(r => setTimeout(r, delay));
|
|
1614
1631
|
continue;
|
|
1615
1632
|
}
|
|
@@ -1539,10 +1539,19 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1539
1539
|
|
|
1540
1540
|
const completedNativeActions = nativeActions.filter((a: ChatResponseAction) => a.status === 'completed');
|
|
1541
1541
|
|
|
1542
|
-
if (!content &&
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
.
|
|
1542
|
+
if (!content && toolCalls.length === 0 && deniedActions.length === 0) {
|
|
1543
|
+
const anyActions = completedNativeActions.length > 0
|
|
1544
|
+
? completedNativeActions
|
|
1545
|
+
: nativeActions.length > 0
|
|
1546
|
+
? nativeActions
|
|
1547
|
+
: attemptedNativeTools;
|
|
1548
|
+
if (anyActions.length > 0) {
|
|
1549
|
+
content = `Antigravity executed: ${anyActions
|
|
1550
|
+
.map((a: any) => `${a.name}${a.detail ? ` (${a.detail})` : ''}`)
|
|
1551
|
+
.join(', ')}`;
|
|
1552
|
+
} else if (rawContent.trim()) {
|
|
1553
|
+
content = rawContent.trim();
|
|
1554
|
+
}
|
|
1546
1555
|
}
|
|
1547
1556
|
|
|
1548
1557
|
const usageIsReported = finalResultObj?.usage?.input_tokens != null
|
|
@@ -1663,17 +1672,25 @@ export class AntigravityProvider extends LLMProvider {
|
|
|
1663
1672
|
if (options.signal?.aborted || err?.name === 'AbortError') {
|
|
1664
1673
|
throw err;
|
|
1665
1674
|
}
|
|
1666
|
-
if (err?.code === 'PROVIDER_NO_PROGRESS')
|
|
1667
|
-
if (err?.partialUsage?.promptTokens + err?.partialUsage?.completionTokens > 0) {
|
|
1675
|
+
if (err?.code === 'AGY_NATIVE_ACTION_DENIED' || err?.code === 'AGY_TOKEN_BUDGET' || err?.code === 'PROVIDER_NO_PROGRESS') {
|
|
1668
1676
|
throw err;
|
|
1669
1677
|
}
|
|
1678
|
+
const msg = String(err?.message || '').toLowerCase();
|
|
1679
|
+
const isTransient = this._isTransientError(msg)
|
|
1680
|
+
|| err?.code === 'PROVIDER_EMPTY_RESPONSE'
|
|
1681
|
+
|| msg.includes('returned no response')
|
|
1682
|
+
|| msg.includes('connection reset')
|
|
1683
|
+
|| msg.includes('econnreset')
|
|
1684
|
+
|| msg.includes('socket hang up')
|
|
1685
|
+
|| msg.includes('streamgeneratecontent');
|
|
1670
1686
|
const canRetryResetConversation =
|
|
1671
1687
|
hadConversation && !this.currentConversationId
|
|
1672
1688
|
&& (err as any)?.code !== 'AGY_NATIVE_ACTION_DENIED'
|
|
1673
1689
|
&& (err as any)?.code !== 'AGY_TOKEN_BUDGET';
|
|
1674
|
-
if (attempt < maxRetries && (
|
|
1690
|
+
if (attempt < maxRetries && (isTransient || canRetryResetConversation)) {
|
|
1675
1691
|
attempt++;
|
|
1676
|
-
|
|
1692
|
+
this.currentConversationId = null;
|
|
1693
|
+
const delay = Math.min(attempt * 1200, 3000);
|
|
1677
1694
|
await new Promise(r => setTimeout(r, delay));
|
|
1678
1695
|
continue;
|
|
1679
1696
|
}
|