@lota-sdk/core 0.1.31 → 0.1.32
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lota-sdk/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@chat-adapter/slack": "^4.23.0",
|
|
33
33
|
"@chat-adapter/state-ioredis": "^4.23.0",
|
|
34
34
|
"@logtape/logtape": "^2.0.5",
|
|
35
|
-
"@lota-sdk/shared": "0.1.
|
|
35
|
+
"@lota-sdk/shared": "0.1.32",
|
|
36
36
|
"@mendable/firecrawl-js": "^4.18.0",
|
|
37
37
|
"@surrealdb/node": "^3.0.3",
|
|
38
38
|
"ai": "^6.0.141",
|
|
@@ -363,6 +363,7 @@ async function streamAgentResponse(
|
|
|
363
363
|
mode: streamParams.mode,
|
|
364
364
|
tools: streamParams.tools,
|
|
365
365
|
extraInstructions: config.extraInstructions,
|
|
366
|
+
maxRetries: 3,
|
|
366
367
|
stopWhen: (agentResolution?.stopWhen as StopCondition<ToolSet> | Array<StopCondition<ToolSet>> | undefined) ??
|
|
367
368
|
streamParams.stopWhen ?? [stepCountIs(config.maxSteps as number)],
|
|
368
369
|
prepareStep: (agentResolution?.prepareStep as PrepareStepFunction<ToolSet> | undefined) ?? streamParams.prepareStep,
|
|
@@ -370,19 +371,32 @@ async function streamAgentResponse(
|
|
|
370
371
|
const agentAbortSignal = streamParams.abortSignal ?? ctx.runAbortSignal
|
|
371
372
|
agentTimer.step('agent-construction')
|
|
372
373
|
|
|
374
|
+
const MAX_STREAM_RETRIES = 3
|
|
373
375
|
let result: unknown
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
376
|
+
for (let attempt = 0; ; attempt++) {
|
|
377
|
+
try {
|
|
378
|
+
result = await streamParams.observer.run(() =>
|
|
379
|
+
agent.stream({ messages: modelMessages, abortSignal: agentAbortSignal }),
|
|
380
|
+
)
|
|
381
|
+
agentTimer.step('agent.stream()-resolved')
|
|
382
|
+
break
|
|
383
|
+
} catch (error) {
|
|
384
|
+
if (agentAbortSignal.aborted) {
|
|
385
|
+
streamParams.observer.recordAbort(error)
|
|
386
|
+
throw error
|
|
387
|
+
}
|
|
388
|
+
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
389
|
+
const isTransient =
|
|
390
|
+
errorMessage.includes('client disconnected') ||
|
|
391
|
+
errorMessage.includes('ECONNRESET') ||
|
|
392
|
+
errorMessage.includes('socket hang up') ||
|
|
393
|
+
errorMessage.includes('fetch failed')
|
|
394
|
+
if (!isTransient || attempt >= MAX_STREAM_RETRIES - 1) {
|
|
395
|
+
streamParams.observer.recordError(error)
|
|
396
|
+
throw error
|
|
397
|
+
}
|
|
398
|
+
aiLogger.warn`Transient stream error (attempt ${attempt + 1}/${MAX_STREAM_RETRIES}): ${errorMessage} — retrying`
|
|
384
399
|
}
|
|
385
|
-
throw error
|
|
386
400
|
}
|
|
387
401
|
if (!hasUIMessageStream(result)) {
|
|
388
402
|
throw new Error(`Agent run for ${resolvedAgentId} did not expose a UI message stream.`)
|