@ai-setting/roy-agent-core 1.5.67 → 1.5.69
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/dist/env/agent/index.js +4 -3
- package/dist/env/index.js +5 -4
- package/dist/env/llm/index.js +3 -2
- package/dist/env/session/index.js +4 -3
- package/dist/env/session/storage/index.js +3 -2
- package/dist/index.js +8 -7
- package/dist/shared/@ai-setting/{roy-agent-core-ew29335n.js → roy-agent-core-1r86pags.js} +10 -7
- package/dist/shared/@ai-setting/{roy-agent-core-pcjenbaf.js → roy-agent-core-33855dsc.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-fp6f15av.js +23 -0
- package/dist/shared/@ai-setting/{roy-agent-core-qskhsjmc.js → roy-agent-core-k8xx1h03.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-marga2es.js → roy-agent-core-pv0812hg.js} +13 -27
- package/dist/shared/@ai-setting/{roy-agent-core-ecth1zak.js → roy-agent-core-wmdrsbwe.js} +5 -12
- package/dist/shared/@ai-setting/{roy-agent-core-hkeegfq0.js → roy-agent-core-wnmtdnd7.js} +15 -8
- package/dist/shared/@ai-setting/{roy-agent-core-v61w8cmf.js → roy-agent-core-zm86k3rg.js} +3 -0
- package/package.json +1 -1
package/dist/env/agent/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponent,
|
|
3
3
|
AgentComponentConfigSchema
|
|
4
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
5
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
4
|
+
} from "../../shared/@ai-setting/roy-agent-core-pv0812hg.js";
|
|
5
|
+
import"../../shared/@ai-setting/roy-agent-core-wmdrsbwe.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
7
7
|
import"../../shared/@ai-setting/roy-agent-core-nx3c3ce2.js";
|
|
8
8
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
@@ -10,7 +10,8 @@ import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
|
10
10
|
import {
|
|
11
11
|
SummaryAgent
|
|
12
12
|
} from "../../shared/@ai-setting/roy-agent-core-x3gtyqax.js";
|
|
13
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
import"../../shared/@ai-setting/roy-agent-core-1r86pags.js";
|
|
14
|
+
import"../../shared/@ai-setting/roy-agent-core-fp6f15av.js";
|
|
14
15
|
import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
|
15
16
|
import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
|
|
16
17
|
import"../../shared/@ai-setting/roy-agent-core-b8r4tfqq.js";
|
package/dist/env/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseEnvironment
|
|
3
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../shared/@ai-setting/roy-agent-core-zm86k3rg.js";
|
|
4
4
|
import {
|
|
5
5
|
EventSourceComponent,
|
|
6
6
|
builtInHandlers,
|
|
@@ -39,8 +39,8 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
39
39
|
import {
|
|
40
40
|
AgentComponent,
|
|
41
41
|
AgentComponentConfigSchema
|
|
42
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
43
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
42
|
+
} from "../shared/@ai-setting/roy-agent-core-pv0812hg.js";
|
|
43
|
+
import"../shared/@ai-setting/roy-agent-core-wmdrsbwe.js";
|
|
44
44
|
import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
45
45
|
import {
|
|
46
46
|
TaskComponent
|
|
@@ -64,7 +64,8 @@ import"../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
|
64
64
|
import"../shared/@ai-setting/roy-agent-core-fnv3ev18.js";
|
|
65
65
|
import"../shared/@ai-setting/roy-agent-core-djtkntar.js";
|
|
66
66
|
import"../shared/@ai-setting/roy-agent-core-x3gtyqax.js";
|
|
67
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
67
|
+
import"../shared/@ai-setting/roy-agent-core-1r86pags.js";
|
|
68
|
+
import"../shared/@ai-setting/roy-agent-core-fp6f15av.js";
|
|
68
69
|
import"../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
|
69
70
|
import {
|
|
70
71
|
BaseComponent
|
package/dist/env/llm/index.js
CHANGED
|
@@ -8,14 +8,15 @@ import {
|
|
|
8
8
|
ProviderCapabilitiesSchema,
|
|
9
9
|
ProviderConfigSchema,
|
|
10
10
|
ProviderManager
|
|
11
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
} from "../../shared/@ai-setting/roy-agent-core-k8xx1h03.js";
|
|
12
12
|
import {
|
|
13
13
|
createInvokeConfig,
|
|
14
14
|
invoke,
|
|
15
15
|
invokeNonStream,
|
|
16
16
|
parseModelString
|
|
17
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
} from "../../shared/@ai-setting/roy-agent-core-wmdrsbwe.js";
|
|
18
18
|
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
19
|
+
import"../../shared/@ai-setting/roy-agent-core-fp6f15av.js";
|
|
19
20
|
import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
|
20
21
|
import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
|
|
21
22
|
import"../../shared/@ai-setting/roy-agent-core-b8r4tfqq.js";
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SessionComponent
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../shared/@ai-setting/roy-agent-core-wnmtdnd7.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
5
5
|
import {
|
|
6
6
|
MemorySessionStore
|
|
7
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
7
|
+
} from "../../shared/@ai-setting/roy-agent-core-33855dsc.js";
|
|
8
8
|
import"../../shared/@ai-setting/roy-agent-core-x3gtyqax.js";
|
|
9
9
|
import {
|
|
10
10
|
SessionMessageConverter
|
|
11
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
} from "../../shared/@ai-setting/roy-agent-core-1r86pags.js";
|
|
12
|
+
import"../../shared/@ai-setting/roy-agent-core-fp6f15av.js";
|
|
12
13
|
import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
|
13
14
|
import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
|
|
14
15
|
import"../../shared/@ai-setting/roy-agent-core-b8r4tfqq.js";
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
SQLiteSessionStore,
|
|
4
4
|
getDefaultDataDir,
|
|
5
5
|
getDefaultSessionDbPath
|
|
6
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
7
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../../shared/@ai-setting/roy-agent-core-33855dsc.js";
|
|
7
|
+
import"../../../shared/@ai-setting/roy-agent-core-1r86pags.js";
|
|
8
|
+
import"../../../shared/@ai-setting/roy-agent-core-fp6f15av.js";
|
|
8
9
|
import"../../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
9
10
|
export {
|
|
10
11
|
getDefaultSessionDbPath,
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ModelLimitsSchema,
|
|
12
12
|
ProviderCapabilitiesSchema,
|
|
13
13
|
ProviderConfigSchema
|
|
14
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
14
|
+
} from "./shared/@ai-setting/roy-agent-core-k8xx1h03.js";
|
|
15
15
|
import {
|
|
16
16
|
ConfigComponent
|
|
17
17
|
} from "./shared/@ai-setting/roy-agent-core-prdngx28.js";
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
BaseEnvironment,
|
|
58
58
|
generateDescendingId,
|
|
59
59
|
generateId
|
|
60
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
60
|
+
} from "./shared/@ai-setting/roy-agent-core-zm86k3rg.js";
|
|
61
61
|
import {
|
|
62
62
|
EventSourceComponent,
|
|
63
63
|
builtInHandlers,
|
|
@@ -116,13 +116,13 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
116
116
|
import {
|
|
117
117
|
AgentComponent,
|
|
118
118
|
AgentComponentConfigSchema
|
|
119
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
119
|
+
} from "./shared/@ai-setting/roy-agent-core-pv0812hg.js";
|
|
120
120
|
import {
|
|
121
121
|
createInvokeConfig,
|
|
122
122
|
invoke,
|
|
123
123
|
invokeNonStream,
|
|
124
124
|
parseModelString
|
|
125
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
125
|
+
} from "./shared/@ai-setting/roy-agent-core-wmdrsbwe.js";
|
|
126
126
|
import {
|
|
127
127
|
AskUserError,
|
|
128
128
|
init_workflow_hil
|
|
@@ -171,13 +171,14 @@ import"./shared/@ai-setting/roy-agent-core-fnv3ev18.js";
|
|
|
171
171
|
import"./shared/@ai-setting/roy-agent-core-djtkntar.js";
|
|
172
172
|
import {
|
|
173
173
|
SessionComponent
|
|
174
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
174
|
+
} from "./shared/@ai-setting/roy-agent-core-wnmtdnd7.js";
|
|
175
175
|
import"./shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
176
176
|
import {
|
|
177
177
|
MemorySessionStore
|
|
178
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
178
|
+
} from "./shared/@ai-setting/roy-agent-core-33855dsc.js";
|
|
179
179
|
import"./shared/@ai-setting/roy-agent-core-x3gtyqax.js";
|
|
180
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
180
|
+
import"./shared/@ai-setting/roy-agent-core-1r86pags.js";
|
|
181
|
+
import"./shared/@ai-setting/roy-agent-core-fp6f15av.js";
|
|
181
182
|
import"./shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
|
182
183
|
import {
|
|
183
184
|
BaseComponent
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
safeParseToolArgs
|
|
3
|
+
} from "./roy-agent-core-fp6f15av.js";
|
|
4
|
+
|
|
1
5
|
// src/env/session/session-message-converter.ts
|
|
2
6
|
import { randomUUID } from "crypto";
|
|
3
7
|
var DEFAULT_REASONING_BUDGET_TOKENS = 1e4;
|
|
@@ -25,12 +29,7 @@ class SessionMessageConverter {
|
|
|
25
29
|
const toolPart = part;
|
|
26
30
|
let parsedArgs = {};
|
|
27
31
|
if (typeof toolPart.arguments === "string") {
|
|
28
|
-
|
|
29
|
-
const parsed = JSON.parse(toolPart.arguments);
|
|
30
|
-
parsedArgs = typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
31
|
-
} catch {
|
|
32
|
-
parsedArgs = { _raw: toolPart.arguments };
|
|
33
|
-
}
|
|
32
|
+
parsedArgs = safeParseToolArgs(toolPart.arguments);
|
|
34
33
|
} else {
|
|
35
34
|
parsedArgs = toolPart.arguments;
|
|
36
35
|
}
|
|
@@ -95,11 +94,15 @@ class SessionMessageConverter {
|
|
|
95
94
|
});
|
|
96
95
|
} else if (p.type === "tool-call") {
|
|
97
96
|
hasToolCallPart = true;
|
|
97
|
+
let args = p.input;
|
|
98
|
+
if (typeof p.input === "string") {
|
|
99
|
+
args = safeParseToolArgs(p.input);
|
|
100
|
+
}
|
|
98
101
|
parts.push({
|
|
99
102
|
type: "tool-call",
|
|
100
103
|
toolCallId: p.toolCallId,
|
|
101
104
|
toolName: p.toolName,
|
|
102
|
-
arguments:
|
|
105
|
+
arguments: args,
|
|
103
106
|
state: "pending"
|
|
104
107
|
});
|
|
105
108
|
} else if (p.type === "tool-result") {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/env/llm/tool-args-parser.ts
|
|
2
|
+
function safeParseToolArgs(args) {
|
|
3
|
+
if (typeof args === "object" && args !== null) {
|
|
4
|
+
return args;
|
|
5
|
+
}
|
|
6
|
+
if (typeof args === "string") {
|
|
7
|
+
try {
|
|
8
|
+
const parsed = JSON.parse(args);
|
|
9
|
+
if (typeof parsed === "string") {
|
|
10
|
+
return safeParseToolArgs(parsed);
|
|
11
|
+
}
|
|
12
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
13
|
+
return parsed;
|
|
14
|
+
}
|
|
15
|
+
return { value: parsed };
|
|
16
|
+
} catch {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { safeParseToolArgs };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withTimeout
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-wmdrsbwe.js";
|
|
4
4
|
import {
|
|
5
5
|
AskUserError,
|
|
6
6
|
init_workflow_hil
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
14
14
|
import {
|
|
15
15
|
SessionMessageConverter
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-1r86pags.js";
|
|
17
|
+
import {
|
|
18
|
+
safeParseToolArgs
|
|
19
|
+
} from "./roy-agent-core-fp6f15av.js";
|
|
17
20
|
import {
|
|
18
21
|
envKeyToConfigKey
|
|
19
22
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
@@ -684,12 +687,7 @@ class AgentComponent extends BaseComponent {
|
|
|
684
687
|
if (tc.function?.arguments) {
|
|
685
688
|
if (typeof tc.function.arguments === "string") {
|
|
686
689
|
argsStr = tc.function.arguments;
|
|
687
|
-
|
|
688
|
-
const parsed = JSON.parse(argsStr);
|
|
689
|
-
argsObj = typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
690
|
-
} catch {
|
|
691
|
-
argsObj = { _raw: argsStr };
|
|
692
|
-
}
|
|
690
|
+
argsObj = safeParseToolArgs(argsStr);
|
|
693
691
|
} else {
|
|
694
692
|
argsObj = tc.function.arguments;
|
|
695
693
|
argsStr = JSON.stringify(argsObj);
|
|
@@ -697,12 +695,7 @@ class AgentComponent extends BaseComponent {
|
|
|
697
695
|
} else if (tc.arguments) {
|
|
698
696
|
if (typeof tc.arguments === "string") {
|
|
699
697
|
argsStr = tc.arguments;
|
|
700
|
-
|
|
701
|
-
const parsed = JSON.parse(argsStr);
|
|
702
|
-
argsObj = typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
703
|
-
} catch {
|
|
704
|
-
argsObj = { _raw: argsStr };
|
|
705
|
-
}
|
|
698
|
+
argsObj = safeParseToolArgs(argsStr);
|
|
706
699
|
} else {
|
|
707
700
|
argsObj = tc.arguments;
|
|
708
701
|
argsStr = JSON.stringify(argsObj);
|
|
@@ -737,14 +730,7 @@ class AgentComponent extends BaseComponent {
|
|
|
737
730
|
}
|
|
738
731
|
const func = toolCall.function;
|
|
739
732
|
const tcName = func?.name || toolCall.name || "unknown";
|
|
740
|
-
const tcArgs = func?.arguments ? typeof func.arguments === "string" ? (
|
|
741
|
-
const parsed = JSON.parse(func.arguments);
|
|
742
|
-
if (typeof parsed === "string") {
|
|
743
|
-
logger.warn(`[agent.component] Tool "${tcName}" arguments are double-stringified, wrapping in { _raw }`);
|
|
744
|
-
return { _raw: parsed };
|
|
745
|
-
}
|
|
746
|
-
return parsed;
|
|
747
|
-
})() : func.arguments : toolCall.arguments;
|
|
733
|
+
const tcArgs = func?.arguments ? typeof func.arguments === "string" ? safeParseToolArgs(func.arguments) : func.arguments : toolCall.arguments;
|
|
748
734
|
hookCtx.currentToolCall = {
|
|
749
735
|
id: toolCall.id,
|
|
750
736
|
name: tcName,
|
|
@@ -794,7 +780,7 @@ class AgentComponent extends BaseComponent {
|
|
|
794
780
|
} catch (error) {
|
|
795
781
|
logger.error(`Iteration ${iteration} error`, { error });
|
|
796
782
|
hookCtx.error = error instanceof Error ? error : new Error(String(error));
|
|
797
|
-
if (error instanceof
|
|
783
|
+
if (error instanceof ContextError && error.llmOutput) {
|
|
798
784
|
const llmOutput = error.llmOutput;
|
|
799
785
|
if (llmOutput.toolCalls?.length) {
|
|
800
786
|
const assistantParts = [];
|
|
@@ -812,10 +798,7 @@ class AgentComponent extends BaseComponent {
|
|
|
812
798
|
});
|
|
813
799
|
}
|
|
814
800
|
for (const tc of llmOutput.toolCalls) {
|
|
815
|
-
const tcInput = typeof tc.function?.arguments === "string" ? (
|
|
816
|
-
const parsed = JSON.parse(tc.function.arguments);
|
|
817
|
-
return typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
818
|
-
})() : tc.arguments || {};
|
|
801
|
+
const tcInput = typeof tc.function?.arguments === "string" ? safeParseToolArgs(tc.function.arguments) : tc.arguments || {};
|
|
819
802
|
assistantParts.push({
|
|
820
803
|
type: "tool-call",
|
|
821
804
|
toolCallId: tc.id,
|
|
@@ -877,6 +860,9 @@ class AgentComponent extends BaseComponent {
|
|
|
877
860
|
result.error = `__ASK_USER_ERROR__:${JSON.stringify(errorInfo)}`;
|
|
878
861
|
} else {
|
|
879
862
|
result.error = hookCtx.error.message;
|
|
863
|
+
if (error instanceof Error) {
|
|
864
|
+
result.originalError = error;
|
|
865
|
+
}
|
|
880
866
|
if (error?.name === "AbortError") {
|
|
881
867
|
hookCtx._stopReason = hookCtx._stopReason || "aborted";
|
|
882
868
|
} else {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
safeParseToolArgs
|
|
3
|
+
} from "./roy-agent-core-fp6f15av.js";
|
|
1
4
|
import {
|
|
2
5
|
createLogger,
|
|
3
6
|
init_logger
|
|
@@ -92,23 +95,13 @@ function convertToSDKMessages(messages) {
|
|
|
92
95
|
let input = {};
|
|
93
96
|
if (tc.function?.arguments) {
|
|
94
97
|
if (typeof tc.function.arguments === "string") {
|
|
95
|
-
|
|
96
|
-
const parsed = JSON.parse(tc.function.arguments);
|
|
97
|
-
input = typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
98
|
-
} catch {
|
|
99
|
-
input = { _raw: tc.function.arguments };
|
|
100
|
-
}
|
|
98
|
+
input = safeParseToolArgs(tc.function.arguments);
|
|
101
99
|
} else {
|
|
102
100
|
input = tc.function.arguments;
|
|
103
101
|
}
|
|
104
102
|
} else if (tc.arguments) {
|
|
105
103
|
if (typeof tc.arguments === "string") {
|
|
106
|
-
|
|
107
|
-
const parsed = JSON.parse(tc.arguments);
|
|
108
|
-
input = typeof parsed === "string" ? { _raw: parsed } : parsed;
|
|
109
|
-
} catch {
|
|
110
|
-
input = { _raw: tc.arguments };
|
|
111
|
-
}
|
|
104
|
+
input = safeParseToolArgs(tc.arguments);
|
|
112
105
|
} else {
|
|
113
106
|
input = tc.arguments;
|
|
114
107
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
MemorySessionStore,
|
|
8
8
|
SQLiteSessionStore
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-33855dsc.js";
|
|
10
10
|
import {
|
|
11
11
|
SummaryAgent
|
|
12
12
|
} from "./roy-agent-core-x3gtyqax.js";
|
|
@@ -450,12 +450,19 @@ class SessionComponent extends BaseComponent {
|
|
|
450
450
|
const recentMessages = this.extractRecentMessages(messages, 2);
|
|
451
451
|
this.ensureSummaryAgent();
|
|
452
452
|
await this.executeBeforeHooks("compact", { session, options });
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
453
|
+
let summaryResult;
|
|
454
|
+
try {
|
|
455
|
+
summaryResult = await this.summaryAgent.run({
|
|
456
|
+
messages: messages.map((m) => ({ role: m.role, content: m.content })),
|
|
457
|
+
userContext: options?.summary,
|
|
458
|
+
outputFormat: "json",
|
|
459
|
+
scenarioHint: options?.scenarioHint
|
|
460
|
+
});
|
|
461
|
+
} catch (error) {
|
|
462
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
463
|
+
logger.error(`[SessionComponent] SummaryAgent.run failed: ${errorMessage}`);
|
|
464
|
+
throw new Error(`Session compaction failed: SummaryAgent error - ${errorMessage}`);
|
|
465
|
+
}
|
|
459
466
|
const checkpointId = `cp_${Date.now().toString(36)}_${Math.random().toString(36).substring(2, 8)}`;
|
|
460
467
|
const checkpoint = {
|
|
461
468
|
id: checkpointId,
|
|
@@ -476,9 +483,9 @@ class SessionComponent extends BaseComponent {
|
|
|
476
483
|
recentMessages
|
|
477
484
|
};
|
|
478
485
|
await this.store.saveCheckpoint(sessionId, checkpoint);
|
|
479
|
-
await this.store.archiveMessages(sessionId, checkpointId, messages.length);
|
|
480
486
|
const checkpointMessage = this.createCheckpointMessage(checkpoint);
|
|
481
487
|
await this.store.addMessage(sessionId, checkpointMessage);
|
|
488
|
+
await this.store.archiveMessages(sessionId, checkpointId, messages.length);
|
|
482
489
|
const updatedSession = await this.get(sessionId);
|
|
483
490
|
const remainingMessageCount = updatedSession?.messageCount ?? 0;
|
|
484
491
|
const checkpointCount = updatedSession?.metadata?.checkpoints?.checkpoints?.length ?? 0;
|
|
@@ -225,6 +225,9 @@ class BaseEnvironment extends BaseComponent {
|
|
|
225
225
|
}
|
|
226
226
|
const result = await agentComponent.run(agent.name, query, context);
|
|
227
227
|
if (result.error) {
|
|
228
|
+
if (result.originalError instanceof ContextError) {
|
|
229
|
+
throw result.originalError;
|
|
230
|
+
}
|
|
228
231
|
const errorMsg = result.error.toLowerCase();
|
|
229
232
|
if (errorMsg.includes("context") || errorMsg.includes("threshold") || errorMsg.includes("token") || result.error.includes("CTX_001")) {
|
|
230
233
|
const usageMatch = result.error.match(/(\d+)\/(\d+)\s*\(([\d.]+)%\)/);
|