Skip to content

Commit 0310fd6

Browse files
authored
fix(scout-agent): extract out of context error properly (#112)
1 parent 232e713 commit 0310fd6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/scout-agent/lib/compaction.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import util from "node:util";
12
import {
23
APICallError,
34
type StreamTextTransform,
@@ -44,14 +45,19 @@ export function findAPICallError(error: unknown): APICallError | null {
4445

4546
/**
4647
* Check if an error is an out-of-context error based on known patterns.
48+
*
49+
* TODO: the current patterns only really handle anthropic via the vercel
50+
* gateway - we need to test with other providers.
4751
*/
4852
export function isOutOfContextError(error: unknown): boolean {
4953
const apiError = findAPICallError(error);
5054
if (!apiError) {
5155
return false;
5256
}
5357
return OUT_OF_CONTEXT_PATTERNS.some((pattern) =>
54-
pattern.test(apiError.message)
58+
pattern.test(
59+
apiError.responseBody ?? util.inspect(apiError, { depth: null })
60+
)
5561
);
5662
}
5763

packages/scout-agent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@blink-sdk/scout-agent",
33
"description": "A general-purpose AI agent with GitHub, Slack, web search, and compute capabilities built on Blink SDK.",
4-
"version": "0.0.12",
4+
"version": "0.0.13",
55
"type": "module",
66
"keywords": [
77
"blink",

0 commit comments

Comments
 (0)