diff options
| author | Adam Malczewski <[email protected]> | 2026-05-23 16:59:20 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-05-23 16:59:20 +0900 |
| commit | 236beefb708a6cd91b673978ddf4ebf045a9844c (patch) | |
| tree | 6522c65a0d490b41cc01297f2444f160f8dbb7f8 /packages/core/src/agent | |
| parent | 225d3ea65cfc35d211fc66e30cf05cbc693d37e4 (diff) | |
| download | dispatch-236beefb708a6cd91b673978ddf4ebf045a9844c.tar.gz dispatch-236beefb708a6cd91b673978ddf4ebf045a9844c.zip | |
feat: key fallback using agent models[] hierarchy, background tool modes, copy truncation
- Agent rate-limit fallback now iterates through agent's configured models[] in strict order
- Frontend sends agentModels with each /chat request; backend uses buildFallbackSequence()
- Emits notice event on fallback so chat shows which key failed and what's being tried next
- Child agents inherit parent's agentModels for fallback
- Added statusCode propagation from AI SDK errors for programmatic 429 detection
- Copy button truncates all tool results at 300 chars (was 200 for 4 specific tools)
- run_shell, summon, youtube_transcribe: background mode support
- summon: blocking mode by default with getResult callback
Diffstat (limited to 'packages/core/src/agent')
| -rw-r--r-- | packages/core/src/agent/agent.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/core/src/agent/agent.ts b/packages/core/src/agent/agent.ts index 6f1a5a4..bf9b22f 100644 --- a/packages/core/src/agent/agent.ts +++ b/packages/core/src/agent/agent.ts @@ -311,8 +311,15 @@ export class Agent { allToolCalls.push(toolCall); yield { type: "tool-call", toolCall }; } else if (event.type === "error") { + const errRecord = event.error as unknown as Record<string, unknown>; + const statusCode = + typeof errRecord.statusCode === "number" ? errRecord.statusCode : undefined; const errorMsg = formatError(event.error, this.config); - yield { type: "error", error: errorMsg }; + yield { + type: "error", + error: errorMsg, + ...(statusCode !== undefined ? { statusCode } : {}), + }; this.status = "error"; yield { type: "status", status: "error" }; return; @@ -471,8 +478,11 @@ export class Agent { yield { type: "done", message: assistantMessage }; } catch (err) { + const errRecord = err as unknown as Record<string, unknown>; + const statusCode = + typeof errRecord.statusCode === "number" ? errRecord.statusCode : undefined; const errorMsg = formatError(err, this.config); - yield { type: "error", error: errorMsg }; + yield { type: "error", error: errorMsg, ...(statusCode !== undefined ? { statusCode } : {}) }; this.status = "error"; yield { type: "status", status: "error" }; return; |
