@librechat/agents 3.0.17 → 3.0.19
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/cjs/graphs/Graph.cjs +80 -1
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/main.cjs +2 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/messages/format.cjs +242 -6
- package/dist/cjs/messages/format.cjs.map +1 -1
- package/dist/cjs/stream.cjs +3 -2
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/handlers.cjs +5 -5
- package/dist/cjs/tools/handlers.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +80 -1
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/main.mjs +1 -1
- package/dist/esm/messages/format.mjs +242 -8
- package/dist/esm/messages/format.mjs.map +1 -1
- package/dist/esm/stream.mjs +3 -2
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/handlers.mjs +5 -5
- package/dist/esm/tools/handlers.mjs.map +1 -1
- package/dist/types/graphs/Graph.d.ts +19 -2
- package/dist/types/messages/format.d.ts +25 -1
- package/dist/types/tools/handlers.d.ts +2 -1
- package/dist/types/types/stream.d.ts +1 -0
- package/package.json +9 -8
- package/src/graphs/Graph.ts +99 -2
- package/src/messages/ensureThinkingBlock.test.ts +393 -0
- package/src/messages/format.ts +312 -6
- package/src/messages/labelContentByAgent.test.ts +887 -0
- package/src/scripts/test-multi-agent-list-handoff.ts +169 -13
- package/src/scripts/test-parallel-agent-labeling.ts +325 -0
- package/src/scripts/test-thinking-handoff-bedrock.ts +153 -0
- package/src/scripts/test-thinking-handoff.ts +147 -0
- package/src/specs/thinking-handoff.test.ts +620 -0
- package/src/stream.ts +19 -10
- package/src/tools/handlers.ts +36 -18
- package/src/types/stream.ts +1 -0
package/src/tools/handlers.ts
CHANGED
|
@@ -26,10 +26,12 @@ export async function handleToolCallChunks({
|
|
|
26
26
|
graph,
|
|
27
27
|
stepKey,
|
|
28
28
|
toolCallChunks,
|
|
29
|
+
metadata,
|
|
29
30
|
}: {
|
|
30
31
|
graph: StandardGraph | MultiAgentGraph;
|
|
31
32
|
stepKey: string;
|
|
32
33
|
toolCallChunks: ToolCallChunk[];
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
33
35
|
}): Promise<void> {
|
|
34
36
|
let prevStepId: string;
|
|
35
37
|
let prevRunStep: t.RunStep | undefined;
|
|
@@ -39,12 +41,16 @@ export async function handleToolCallChunks({
|
|
|
39
41
|
} catch {
|
|
40
42
|
/** Edge Case: If no previous step exists, create a new message creation step */
|
|
41
43
|
const message_id = getMessageId(stepKey, graph, true) ?? '';
|
|
42
|
-
prevStepId = await graph.dispatchRunStep(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
prevStepId = await graph.dispatchRunStep(
|
|
45
|
+
stepKey,
|
|
46
|
+
{
|
|
47
|
+
type: StepTypes.MESSAGE_CREATION,
|
|
48
|
+
message_creation: {
|
|
49
|
+
message_id,
|
|
50
|
+
},
|
|
46
51
|
},
|
|
47
|
-
|
|
52
|
+
metadata
|
|
53
|
+
);
|
|
48
54
|
prevRunStep = graph.getRunStep(prevStepId);
|
|
49
55
|
}
|
|
50
56
|
|
|
@@ -92,10 +98,14 @@ export async function handleToolCallChunks({
|
|
|
92
98
|
],
|
|
93
99
|
});
|
|
94
100
|
graph.messageStepHasToolCalls.set(prevStepId, true);
|
|
95
|
-
stepId = await graph.dispatchRunStep(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
stepId = await graph.dispatchRunStep(
|
|
102
|
+
stepKey,
|
|
103
|
+
{
|
|
104
|
+
type: StepTypes.TOOL_CALLS,
|
|
105
|
+
tool_calls,
|
|
106
|
+
},
|
|
107
|
+
metadata
|
|
108
|
+
);
|
|
99
109
|
}
|
|
100
110
|
await graph.dispatchRunStepDelta(stepId, {
|
|
101
111
|
type: StepTypes.TOOL_CALLS,
|
|
@@ -166,20 +176,28 @@ export const handleToolCalls = async (
|
|
|
166
176
|
prevRunStep.type !== StepTypes.MESSAGE_CREATION
|
|
167
177
|
) {
|
|
168
178
|
const messageId = getMessageId(stepKey, graph, true) ?? '';
|
|
169
|
-
const stepId = await graph.dispatchRunStep(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
179
|
+
const stepId = await graph.dispatchRunStep(
|
|
180
|
+
stepKey,
|
|
181
|
+
{
|
|
182
|
+
type: StepTypes.MESSAGE_CREATION,
|
|
183
|
+
message_creation: {
|
|
184
|
+
message_id: messageId,
|
|
185
|
+
},
|
|
173
186
|
},
|
|
174
|
-
|
|
187
|
+
metadata
|
|
188
|
+
);
|
|
175
189
|
await dispatchToolCallIds(stepId);
|
|
176
190
|
graph.messageStepHasToolCalls.set(prevStepId, true);
|
|
177
191
|
}
|
|
178
192
|
|
|
179
|
-
await graph.dispatchRunStep(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
193
|
+
await graph.dispatchRunStep(
|
|
194
|
+
stepKey,
|
|
195
|
+
{
|
|
196
|
+
type: StepTypes.TOOL_CALLS,
|
|
197
|
+
tool_calls: [tool_call],
|
|
198
|
+
},
|
|
199
|
+
metadata
|
|
200
|
+
);
|
|
183
201
|
}
|
|
184
202
|
};
|
|
185
203
|
|
package/src/types/stream.ts
CHANGED
|
@@ -65,6 +65,7 @@ export type RunStep = {
|
|
|
65
65
|
// last_error: string | null;
|
|
66
66
|
id: string; // #new
|
|
67
67
|
runId?: string; // #new
|
|
68
|
+
agentId?: string; // #new - tracks which agent this step belongs to
|
|
68
69
|
index: number; // #new
|
|
69
70
|
stepIndex?: number; // #new
|
|
70
71
|
stepDetails: StepDetails;
|