@librechat/agents 3.3.8 → 3.3.10
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/agents/AgentContext.cjs +4 -0
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +66 -13
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +35 -2
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/hitl/askUserQuestion.cjs +3 -2
- package/dist/cjs/hitl/askUserQuestion.cjs.map +1 -1
- package/dist/cjs/instrumentation.cjs +18 -48
- package/dist/cjs/instrumentation.cjs.map +1 -1
- package/dist/cjs/langfuse.cjs +174 -29
- package/dist/cjs/langfuse.cjs.map +1 -1
- package/dist/cjs/langfuseConfig.cjs +12 -0
- package/dist/cjs/langfuseConfig.cjs.map +1 -1
- package/dist/cjs/langfuseRuntimeContext.cjs +23 -2
- package/dist/cjs/langfuseRuntimeContext.cjs.map +1 -1
- package/dist/cjs/langfuseRuntimeScope.cjs +39 -8
- package/dist/cjs/langfuseRuntimeScope.cjs.map +1 -1
- package/dist/cjs/langfuseSpanRegistry.cjs +95 -0
- package/dist/cjs/langfuseSpanRegistry.cjs.map +1 -0
- package/dist/cjs/langfuseTraceShaping.cjs +121 -4
- package/dist/cjs/langfuseTraceShaping.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +39 -15
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +25 -5
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/init.cjs +3 -3
- package/dist/cjs/llm/invoke.cjs +5 -5
- package/dist/cjs/llm/openai/index.cjs +1 -1
- package/dist/cjs/main.cjs +10 -10
- package/dist/cjs/messages/prune.cjs +13 -1
- package/dist/cjs/messages/prune.cjs.map +1 -1
- package/dist/cjs/prompts/activityLabel.cjs +24 -12
- package/dist/cjs/prompts/activityLabel.cjs.map +1 -1
- package/dist/cjs/run.cjs +57 -22
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/session/messageSerialization.cjs +6 -0
- package/dist/cjs/session/messageSerialization.cjs.map +1 -1
- package/dist/cjs/stream.cjs +21 -10
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +5 -0
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +253 -24
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/handlers.cjs +1 -1
- package/dist/cjs/tools/search/tool.cjs +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +1 -1
- package/dist/cjs/utils/index.cjs +2 -2
- package/dist/esm/agents/AgentContext.mjs +4 -0
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +67 -14
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +35 -2
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/hitl/askUserQuestion.mjs +3 -2
- package/dist/esm/hitl/askUserQuestion.mjs.map +1 -1
- package/dist/esm/instrumentation.mjs +18 -48
- package/dist/esm/instrumentation.mjs.map +1 -1
- package/dist/esm/langfuse.mjs +176 -28
- package/dist/esm/langfuse.mjs.map +1 -1
- package/dist/esm/langfuseConfig.mjs +10 -1
- package/dist/esm/langfuseConfig.mjs.map +1 -1
- package/dist/esm/langfuseRuntimeContext.mjs +21 -3
- package/dist/esm/langfuseRuntimeContext.mjs.map +1 -1
- package/dist/esm/langfuseRuntimeScope.mjs +39 -10
- package/dist/esm/langfuseRuntimeScope.mjs.map +1 -1
- package/dist/esm/langfuseSpanRegistry.mjs +91 -0
- package/dist/esm/langfuseSpanRegistry.mjs.map +1 -0
- package/dist/esm/langfuseTraceShaping.mjs +121 -4
- package/dist/esm/langfuseTraceShaping.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +39 -15
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs +25 -5
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/init.mjs +2 -2
- package/dist/esm/llm/invoke.mjs +5 -5
- package/dist/esm/llm/openai/index.mjs +1 -1
- package/dist/esm/main.mjs +8 -8
- package/dist/esm/messages/prune.mjs +13 -1
- package/dist/esm/messages/prune.mjs.map +1 -1
- package/dist/esm/prompts/activityLabel.mjs +24 -12
- package/dist/esm/prompts/activityLabel.mjs.map +1 -1
- package/dist/esm/run.mjs +57 -22
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/session/messageSerialization.mjs +6 -0
- package/dist/esm/session/messageSerialization.mjs.map +1 -1
- package/dist/esm/stream.mjs +21 -10
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +5 -0
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +254 -25
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/handlers.mjs +1 -1
- package/dist/esm/tools/search/tool.mjs +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +1 -1
- package/dist/esm/utils/index.mjs +2 -2
- package/dist/types/agents/AgentContext.d.ts +2 -0
- package/dist/types/graphs/Graph.d.ts +24 -0
- package/dist/types/hitl/askUserQuestion.d.ts +11 -1
- package/dist/types/langfuse.d.ts +16 -8
- package/dist/types/langfuseConfig.d.ts +6 -0
- package/dist/types/langfuseRuntimeContext.d.ts +27 -1
- package/dist/types/langfuseRuntimeScope.d.ts +17 -2
- package/dist/types/langfuseSpanRegistry.d.ts +17 -0
- package/dist/types/langfuseTraceShaping.d.ts +2 -1
- package/dist/types/llm/anthropic/utils/message_inputs.d.ts +1 -0
- package/dist/types/run.d.ts +7 -0
- package/dist/types/session/types.d.ts +1 -0
- package/dist/types/tools/ToolNode.d.ts +7 -1
- package/dist/types/types/hitl.d.ts +8 -0
- package/dist/types/types/tools.d.ts +30 -0
- package/package.json +7 -4
- package/src/__tests__/stream.eagerArgsDivergence.test.ts +753 -0
- package/src/agents/AgentContext.ts +5 -0
- package/src/graphs/Graph.ts +108 -20
- package/src/graphs/MultiAgentGraph.ts +56 -2
- package/src/graphs/__tests__/composition.smoke.test.ts +4 -0
- package/src/hitl/askUserQuestion.ts +14 -1
- package/src/instrumentation.ts +35 -77
- package/src/langfuse.ts +320 -43
- package/src/langfuseConfig.ts +24 -0
- package/src/langfuseRuntimeContext.ts +43 -1
- package/src/langfuseRuntimeScope.ts +94 -21
- package/src/langfuseSpanRegistry.ts +131 -0
- package/src/langfuseTraceShaping.ts +194 -7
- package/src/llm/anthropic/utils/message_inputs.ts +70 -19
- package/src/llm/anthropic/utils/streaming-tool-input.test.ts +186 -11
- package/src/llm/bedrock/utils/message_inputs.test.ts +120 -4
- package/src/llm/bedrock/utils/message_inputs.ts +32 -7
- package/src/messages/prune.ts +12 -1
- package/src/prompts/activityLabel.ts +23 -6
- package/src/run.ts +91 -45
- package/src/scripts/activity-labels/captured.json +56 -0
- package/src/scripts/activity-labels/checks.cjs +205 -0
- package/src/scripts/activity-labels/corpus.cjs +473 -0
- package/src/scripts/activity-labels/report.cjs +203 -0
- package/src/scripts/activity-labels/rescore.cjs +102 -0
- package/src/scripts/activity-labels/run.ts +705 -0
- package/src/scripts/activity-labels/variants.ts +71 -0
- package/src/session/messageSerialization.ts +12 -1
- package/src/session/types.ts +1 -0
- package/src/specs/activity-label-prompt.test.ts +26 -10
- package/src/specs/agent-handoffs.test.ts +306 -0
- package/src/specs/discovered-tools.test.ts +217 -0
- package/src/specs/langfuse-callbacks.test.ts +456 -0
- package/src/specs/langfuse-routing.integration.test.ts +138 -1
- package/src/specs/langfuse-span-registry.test.ts +70 -0
- package/src/specs/langfuse-trace-shaping.test.ts +294 -0
- package/src/specs/prune.test.ts +38 -1
- package/src/stream.ts +70 -6
- package/src/summarization/node.ts +5 -0
- package/src/tools/ToolNode.ts +400 -9
- package/src/tools/__tests__/ToolNode.invalidToolCalls.test.ts +757 -0
- package/src/tools/__tests__/hitl.test.ts +58 -0
- package/src/types/hitl.ts +8 -0
- package/src/types/tools.ts +35 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { resolveLangfuseConfig } from "../langfuseConfig.mjs";
|
|
1
|
+
import { hasToolOutputTracingConfig, resolveLangfuseConfig, resolveToolOutputTracingConfig } from "../langfuseConfig.mjs";
|
|
2
2
|
import { resolveLangfuseRuntimeScope, withLangfuseRuntimeScope } from "../langfuseRuntimeScope.mjs";
|
|
3
3
|
import { createLangfuseHandler, createLangfuseTraceMetadata, disposeLangfuseHandler, isLangfuseCallbackHandler } from "../langfuse.mjs";
|
|
4
|
-
import { shouldTraceToolNodeForLangfuse } from "../langfuseToolOutputTracing.mjs";
|
|
5
|
-
import { appendCallbacks, findCallback } from "../utils/callbacks.mjs";
|
|
6
4
|
import { PREEMPT_BOUNDARY_HOOK_TIMEOUT_MS } from "../common/constants.mjs";
|
|
7
5
|
import { GraphNodeKeys } from "../common/enum.mjs";
|
|
8
6
|
import "../common/index.mjs";
|
|
7
|
+
import { shouldTraceToolNodeForLangfuse } from "../langfuseToolOutputTracing.mjs";
|
|
8
|
+
import { appendCallbacks, findCallback } from "../utils/callbacks.mjs";
|
|
9
9
|
import { calculateMaxToolResultChars } from "../utils/truncation.mjs";
|
|
10
10
|
import { compactToolContent, getToolContentCharLength, serializeToolContentBounded } from "../utils/toolContent.mjs";
|
|
11
11
|
import { apportionTokenCounts } from "../utils/tokens.mjs";
|
|
12
|
-
import { resolveMaxSeals } from "../llm/preempt.mjs";
|
|
13
12
|
import { initializeLangfuseTracing } from "../instrumentation.mjs";
|
|
14
13
|
import { addBedrockTailCacheControl, addTailCacheControl, resolveBedrockPromptCacheTtl, resolvePromptCacheTtl, supportsBedrockToolCache } from "../messages/cache.mjs";
|
|
15
14
|
import { convertMessagesToContent, projectAnthropicArtifactContent, projectArtifactPayload, projectToolStreamContentForProvider } from "../messages/core.mjs";
|
|
@@ -27,14 +26,15 @@ import { appendPredecessorHandoffCue, removePredecessorHandoffCue } from "../mes
|
|
|
27
26
|
import { messagesStateReducer as messagesStateReducer$1 } from "../messages/reducer.mjs";
|
|
28
27
|
import { splitAtRecencyBoundary } from "../messages/recency.mjs";
|
|
29
28
|
import "../messages/index.mjs";
|
|
30
|
-
import { joinKeys, resetIfNotEmpty } from "../utils/graph.mjs";
|
|
31
|
-
import { isAnthropicLike, isGoogleLike, isOpenAILike } from "../utils/llm.mjs";
|
|
32
|
-
import { handleToolCalls } from "../tools/handlers.mjs";
|
|
33
29
|
import { ToolOutputReferenceRegistry, annotateMessagesForLLM } from "../tools/toolOutputReferences.mjs";
|
|
30
|
+
import { partitionAndMarkBedrockToolCache } from "../llm/bedrock/toolCache.mjs";
|
|
31
|
+
import { resolveMaxSeals } from "../llm/preempt.mjs";
|
|
32
|
+
import { handleToolCalls } from "../tools/handlers.mjs";
|
|
33
|
+
import { isAnthropicLike, isGoogleLike, isOpenAILike } from "../utils/llm.mjs";
|
|
34
|
+
import { joinKeys, resetIfNotEmpty } from "../utils/graph.mjs";
|
|
34
35
|
import { HandlerRegistry } from "../events.mjs";
|
|
35
36
|
import { sleep } from "../utils/run.mjs";
|
|
36
37
|
import "../utils/index.mjs";
|
|
37
|
-
import { partitionAndMarkBedrockToolCache } from "../llm/bedrock/toolCache.mjs";
|
|
38
38
|
import { initializeModel } from "../llm/init.mjs";
|
|
39
39
|
import { attemptInvoke, getFallbackErrorContext, getFallbackOverflowCandidates, projectMessagesForProvider, resolveServingModelId, tryFallbackProviders } from "../llm/invoke.mjs";
|
|
40
40
|
import { getBlindRecoveryBudget, planContextOverflowRecovery, translateRecoveryBudget } from "../llm/contextOverflowRecovery.mjs";
|
|
@@ -56,12 +56,12 @@ import { createSummarizeNode } from "../summarization/node.mjs";
|
|
|
56
56
|
import { createSchemaOnlyTools } from "../tools/schema.mjs";
|
|
57
57
|
import { AgentContext } from "../agents/AgentContext.mjs";
|
|
58
58
|
import { createFakeStreamingLLM } from "../llm/fake.mjs";
|
|
59
|
+
import { nanoid } from "nanoid";
|
|
59
60
|
import { AIMessageChunk, HumanMessage, ToolMessage } from "@langchain/core/messages";
|
|
60
61
|
import { Annotation, END, START, StateGraph } from "@langchain/langgraph";
|
|
61
62
|
import { tool } from "@langchain/core/tools";
|
|
62
|
-
import { nanoid } from "nanoid";
|
|
63
|
-
import { ContextOverflowError } from "@langchain/core/errors";
|
|
64
63
|
import { v4 } from "uuid";
|
|
64
|
+
import { ContextOverflowError } from "@langchain/core/errors";
|
|
65
65
|
//#region src/graphs/Graph.ts
|
|
66
66
|
const { AGENT, TOOLS, SUMMARIZE } = GraphNodeKeys;
|
|
67
67
|
const EMPTY_PREEMPT_BOUNDARY = {
|
|
@@ -271,6 +271,10 @@ function getDispatchableFinalReasoningContent({ agentContext, responseReasoningC
|
|
|
271
271
|
return responseReasoningContent;
|
|
272
272
|
}
|
|
273
273
|
var Graph = class {
|
|
274
|
+
/** Returns a snapshot of deferred tools discovered by this graph. */
|
|
275
|
+
getDiscoveredTools(_agentId) {
|
|
276
|
+
return [];
|
|
277
|
+
}
|
|
274
278
|
messageStepHasTextDeltas = /* @__PURE__ */ new Set();
|
|
275
279
|
messageStepHasToolCalls = /* @__PURE__ */ new Map();
|
|
276
280
|
messageIdsByStepKey = /* @__PURE__ */ new Map();
|
|
@@ -354,6 +358,15 @@ var Graph = class {
|
|
|
354
358
|
eagerEventToolUsageCountsByAgentId = /* @__PURE__ */ new Map();
|
|
355
359
|
eagerEventToolCallChunks = /* @__PURE__ */ new Map();
|
|
356
360
|
/**
|
|
361
|
+
* Per-run eager prestart circuit breaker, shared by reference with every
|
|
362
|
+
* ToolNode this graph compiles. When a prestarted execution's args turn
|
|
363
|
+
* out to differ from the final request, ToolNode records the tool name
|
|
364
|
+
* here and the stream handler stops prestarting that tool for the rest of
|
|
365
|
+
* the run — the retry then executes normally instead of re-diverging in a
|
|
366
|
+
* loop (LibreChat#14371).
|
|
367
|
+
*/
|
|
368
|
+
eagerEventToolSuppressions = /* @__PURE__ */ new Set();
|
|
369
|
+
/**
|
|
357
370
|
* Run-scoped execution backend for built-in code tools. Defaults to the
|
|
358
371
|
* remote Code API sandbox when unset.
|
|
359
372
|
*/
|
|
@@ -401,6 +414,7 @@ var Graph = class {
|
|
|
401
414
|
this.eagerEventToolExecutions.clear();
|
|
402
415
|
this.clearEagerEventToolUsageCounts();
|
|
403
416
|
this.eagerEventToolCallChunks.clear();
|
|
417
|
+
this.eagerEventToolSuppressions.clear();
|
|
404
418
|
this.toolExecution = void 0;
|
|
405
419
|
this.handlerDispatchedEventCounts.clear();
|
|
406
420
|
/**
|
|
@@ -519,12 +533,24 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
519
533
|
messages = [];
|
|
520
534
|
/** Cached run messages preserved before clearHeavyState() so getRunMessages() works after cleanup. */
|
|
521
535
|
cachedRunMessages;
|
|
536
|
+
/** Per-agent discovery snapshots preserved before contexts are reset on cleanup. */
|
|
537
|
+
cachedDiscoveredTools;
|
|
522
538
|
/** Ids of AI turns the agent node returned THIS run; see isRunProducedMessage. */
|
|
523
539
|
runProducedAiMessageIds = /* @__PURE__ */ new Set();
|
|
524
540
|
/** Checkpoint scope whose messages match index-keyed tool snapshots. */
|
|
525
541
|
originalToolContentCheckpointScope;
|
|
526
542
|
runId;
|
|
527
543
|
/**
|
|
544
|
+
* Identity used to stamp Langfuse runtime scopes and handlers (see
|
|
545
|
+
* `LangfuseRuntimeContext.runId`). Carries an opaque per-instance
|
|
546
|
+
* component: public run ids are unrestricted and may repeat across
|
|
547
|
+
* concurrently executing runs (retries, duplicate submissions,
|
|
548
|
+
* tenant-local message ids), and equal stamps would let those runs adopt
|
|
549
|
+
* each other's scopes. One graph instance = one execution's stamp, shared
|
|
550
|
+
* by the stream handler and every graph-level scope of that execution.
|
|
551
|
+
*/
|
|
552
|
+
langfuseScopeRunId;
|
|
553
|
+
/**
|
|
528
554
|
* Boundary between historical messages (loaded from conversation state)
|
|
529
555
|
* and messages produced during the current run. Set once in the state
|
|
530
556
|
* reducer when messages first arrive. Used by `getRunMessages()` and
|
|
@@ -596,6 +622,7 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
596
622
|
constructor({ runId, signal, agents, langfuse, tokenCounter, indexTokenCountMap, calibrationRatio, subagentUsageSink, subagentScope, preemption }) {
|
|
597
623
|
super();
|
|
598
624
|
this.runId = runId;
|
|
625
|
+
this.langfuseScopeRunId = `${runId ?? "graph"}:${nanoid()}`;
|
|
599
626
|
this.signal = signal;
|
|
600
627
|
this.langfuse = langfuse;
|
|
601
628
|
this.subagentUsageSink = subagentUsageSink;
|
|
@@ -612,6 +639,7 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
612
639
|
resetValues(keepContent, checkpointScope) {
|
|
613
640
|
this.messages = [];
|
|
614
641
|
this.cachedRunMessages = void 0;
|
|
642
|
+
this.cachedDiscoveredTools = void 0;
|
|
615
643
|
this.config = resetIfNotEmpty(this.config, void 0);
|
|
616
644
|
if (keepContent !== true) {
|
|
617
645
|
this.contentData = resetIfNotEmpty(this.contentData, []);
|
|
@@ -629,6 +657,7 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
629
657
|
this.eagerEventToolExecutions.clear();
|
|
630
658
|
this.clearEagerEventToolUsageCounts();
|
|
631
659
|
this.eagerEventToolCallChunks.clear();
|
|
660
|
+
this.eagerEventToolSuppressions.clear();
|
|
632
661
|
this.handlerDispatchedStepIds = resetIfNotEmpty(this.handlerDispatchedStepIds, /* @__PURE__ */ new Set());
|
|
633
662
|
this.handlerDispatchedEventCounts = resetIfNotEmpty(this.handlerDispatchedEventCounts, /* @__PURE__ */ new Map());
|
|
634
663
|
this.messageIdsByStepKey = resetIfNotEmpty(this.messageIdsByStepKey, /* @__PURE__ */ new Map());
|
|
@@ -646,6 +675,7 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
646
675
|
}
|
|
647
676
|
clearHeavyState() {
|
|
648
677
|
this.cachedRunMessages = this.messages.slice(this.startIndex);
|
|
678
|
+
this.cachedDiscoveredTools = new Map(Array.from(this.agentContexts, ([agentId, context]) => [agentId, context.getDiscoveredTools()]));
|
|
649
679
|
super.clearHeavyState();
|
|
650
680
|
this.messages = [];
|
|
651
681
|
this.overrideModel = void 0;
|
|
@@ -824,6 +854,17 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
824
854
|
if (this.messages.length === 0 && this.cachedRunMessages != null) return this.cachedRunMessages;
|
|
825
855
|
return this.messages.slice(this.startIndex);
|
|
826
856
|
}
|
|
857
|
+
getDiscoveredTools(agentId) {
|
|
858
|
+
if (agentId != null) {
|
|
859
|
+
const current = this.agentContexts.get(agentId)?.getDiscoveredTools() ?? [];
|
|
860
|
+
if (current.length > 0 || this.cachedDiscoveredTools == null) return current;
|
|
861
|
+
return [...this.cachedDiscoveredTools.get(agentId) ?? []];
|
|
862
|
+
}
|
|
863
|
+
const discoveredTools = /* @__PURE__ */ new Set();
|
|
864
|
+
for (const context of this.agentContexts.values()) for (const toolName of context.getDiscoveredTools()) discoveredTools.add(toolName);
|
|
865
|
+
if (discoveredTools.size === 0 && this.cachedDiscoveredTools != null) for (const snapshot of this.cachedDiscoveredTools.values()) for (const toolName of snapshot) discoveredTools.add(toolName);
|
|
866
|
+
return Array.from(discoveredTools);
|
|
867
|
+
}
|
|
827
868
|
/**
|
|
828
869
|
* True when THIS RUN produced `message` — the provenance the handoff cue
|
|
829
870
|
* gate needs. Tracked as an id set rather than inferred from `startIndex`
|
|
@@ -930,6 +971,7 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
930
971
|
codeSessionToolNames: this.codeSessionToolNames,
|
|
931
972
|
eagerEventToolExecutions: this.eagerEventToolExecutions,
|
|
932
973
|
eagerEventToolUsageCount: this.getEagerEventToolUsageCount(agentContext?.agentId),
|
|
974
|
+
eagerEventToolSuppressions: this.eagerEventToolSuppressions,
|
|
933
975
|
toolExecution: this.toolExecution,
|
|
934
976
|
directToolNames: directToolNames.size > 0 ? directToolNames : void 0,
|
|
935
977
|
interruptingToolNames: this.interruptingToolNames != null && this.interruptingToolNames.length > 0 ? new Set(this.interruptingToolNames) : void 0,
|
|
@@ -1630,7 +1672,12 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
1630
1672
|
...config,
|
|
1631
1673
|
metadata: {
|
|
1632
1674
|
...config.metadata ?? {},
|
|
1633
|
-
...traceMetadata
|
|
1675
|
+
...traceMetadata,
|
|
1676
|
+
/** Canonical agent identity, stamped OUTSIDE trace-metadata
|
|
1677
|
+
* filtering: `createLangfuseTraceMetadata` drops values over its
|
|
1678
|
+
* length cap, but scope trust (`isForeignScope`) needs the id
|
|
1679
|
+
* verbatim regardless of length. */
|
|
1680
|
+
agentId
|
|
1634
1681
|
}
|
|
1635
1682
|
};
|
|
1636
1683
|
initializeLangfuseTracing(langfuse);
|
|
@@ -1641,7 +1688,9 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
1641
1688
|
sessionId: config.configurable?.thread_id,
|
|
1642
1689
|
traceMetadata,
|
|
1643
1690
|
tags: ["librechat", "agent"],
|
|
1644
|
-
traceIdSeed: langfuse?.deterministicTraceId === true ? this.runId : void 0
|
|
1691
|
+
traceIdSeed: langfuse?.deterministicTraceId === true ? this.runId : void 0,
|
|
1692
|
+
runId: this.langfuseScopeRunId,
|
|
1693
|
+
toolOutputTracing: hasToolOutputTracingConfig(this.langfuse, agentContext.langfuse) ? resolveToolOutputTracingConfig(this.langfuse, agentContext.langfuse) : void 0
|
|
1645
1694
|
});
|
|
1646
1695
|
if (langfuseHandler != null) invokeConfig = {
|
|
1647
1696
|
...invokeConfig,
|
|
@@ -1653,7 +1702,9 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
1653
1702
|
if (preInvokeContextOverflowError != null) throw preInvokeContextOverflowError;
|
|
1654
1703
|
result = await withLangfuseRuntimeScope(resolveLangfuseRuntimeScope({
|
|
1655
1704
|
runLangfuse: this.langfuse,
|
|
1656
|
-
langfuseOverlay: agentContext.langfuse
|
|
1705
|
+
langfuseOverlay: agentContext.langfuse,
|
|
1706
|
+
runId: this.langfuseScopeRunId,
|
|
1707
|
+
agentId
|
|
1657
1708
|
}), () => attemptInvoke({
|
|
1658
1709
|
model: this.overrideModel ?? model,
|
|
1659
1710
|
messages: finalMessages,
|
|
@@ -1746,7 +1797,9 @@ var StandardGraph = class StandardGraph extends Graph {
|
|
|
1746
1797
|
try {
|
|
1747
1798
|
result = await withLangfuseRuntimeScope(resolveLangfuseRuntimeScope({
|
|
1748
1799
|
runLangfuse: this.langfuse,
|
|
1749
|
-
langfuseOverlay: agentContext.langfuse
|
|
1800
|
+
langfuseOverlay: agentContext.langfuse,
|
|
1801
|
+
runId: this.langfuseScopeRunId,
|
|
1802
|
+
agentId
|
|
1750
1803
|
}), () => tryFallbackProviders({
|
|
1751
1804
|
fallbacks,
|
|
1752
1805
|
tools: agentContext.tools,
|