@librechat/agents 3.4.6 → 3.5.0
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 +0 -356
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/agents/projection.cjs +0 -9
- package/dist/cjs/agents/projection.cjs.map +1 -1
- package/dist/cjs/common/constants.cjs +0 -26
- package/dist/cjs/common/constants.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +0 -85
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/events.cjs +0 -14
- package/dist/cjs/events.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +1 -909
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +7 -272
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/graphs/applyGraphRuntimeConfig.cjs.map +1 -1
- package/dist/cjs/graphs/createGraph.cjs.map +1 -1
- package/dist/cjs/hitl/askUserQuestion.cjs +0 -53
- package/dist/cjs/hitl/askUserQuestion.cjs.map +1 -1
- package/dist/cjs/hitl/askUserQuestions.cjs +0 -20
- package/dist/cjs/hitl/askUserQuestions.cjs.map +1 -1
- package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs +0 -6
- package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs.map +1 -1
- package/dist/cjs/hooks/HookRegistry.cjs +0 -127
- package/dist/cjs/hooks/HookRegistry.cjs.map +1 -1
- package/dist/cjs/hooks/createToolPolicyHook.cjs +0 -38
- package/dist/cjs/hooks/createToolPolicyHook.cjs.map +1 -1
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +0 -77
- package/dist/cjs/hooks/createWorkspacePolicyHook.cjs.map +1 -1
- package/dist/cjs/hooks/executeHooks.cjs +0 -79
- package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
- package/dist/cjs/hooks/index.cjs +0 -16
- package/dist/cjs/hooks/index.cjs.map +1 -1
- package/dist/cjs/hooks/matchers.cjs +0 -104
- package/dist/cjs/hooks/matchers.cjs.map +1 -1
- package/dist/cjs/hooks/types.cjs +0 -8
- package/dist/cjs/hooks/types.cjs.map +1 -1
- package/dist/cjs/instrumentation.cjs +0 -14
- package/dist/cjs/instrumentation.cjs.map +1 -1
- package/dist/cjs/langfuse.cjs +0 -75
- package/dist/cjs/langfuse.cjs.map +1 -1
- package/dist/cjs/langfuseConfig.cjs.map +1 -1
- package/dist/cjs/langfuseRuntimeContext.cjs +0 -13
- package/dist/cjs/langfuseRuntimeContext.cjs.map +1 -1
- package/dist/cjs/langfuseRuntimeScope.cjs +0 -4
- package/dist/cjs/langfuseRuntimeScope.cjs.map +1 -1
- package/dist/cjs/langfuseSpanRegistry.cjs +0 -28
- package/dist/cjs/langfuseSpanRegistry.cjs.map +1 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs +0 -3
- package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
- package/dist/cjs/langfuseTraceShaping.cjs +0 -74
- package/dist/cjs/langfuseTraceShaping.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/index.cjs +0 -3
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +1 -111
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +0 -1
- package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/stream_events.cjs +0 -8
- package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/cachePoints.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +1 -95
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/toolCache.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +0 -78
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/utils/message_outputs.cjs +0 -24
- package/dist/cjs/llm/bedrock/utils/message_outputs.cjs.map +1 -1
- package/dist/cjs/llm/contextOverflowRecovery.cjs +0 -62
- package/dist/cjs/llm/contextOverflowRecovery.cjs.map +1 -1
- package/dist/cjs/llm/fake.cjs.map +1 -1
- package/dist/cjs/llm/google/index.cjs +2 -21
- package/dist/cjs/llm/google/index.cjs.map +1 -1
- package/dist/cjs/llm/google/utils/common.cjs +5 -35
- package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
- package/dist/cjs/llm/init.cjs +0 -9
- package/dist/cjs/llm/init.cjs.map +1 -1
- package/dist/cjs/llm/invoke.cjs +1 -270
- package/dist/cjs/llm/invoke.cjs.map +1 -1
- package/dist/cjs/llm/mistral/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +0 -99
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/streamMetadata.cjs +0 -21
- package/dist/cjs/llm/openai/streamMetadata.cjs.map +1 -1
- package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/index.cjs +0 -1
- package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/toolCache.cjs +0 -6
- package/dist/cjs/llm/openrouter/toolCache.cjs.map +1 -1
- package/dist/cjs/llm/preempt.cjs +0 -75
- package/dist/cjs/llm/preempt.cjs.map +1 -1
- package/dist/cjs/llm/providers.cjs.map +1 -1
- package/dist/cjs/llm/request.cjs +0 -10
- package/dist/cjs/llm/request.cjs.map +1 -1
- package/dist/cjs/llm/stream/chunkAdapters.cjs +0 -62
- package/dist/cjs/llm/stream/chunkAdapters.cjs.map +1 -1
- package/dist/cjs/llm/stream/smoother.cjs +0 -58
- package/dist/cjs/llm/stream/smoother.cjs.map +1 -1
- package/dist/cjs/llm/streamLimits.cjs +4 -293
- package/dist/cjs/llm/streamLimits.cjs.map +1 -1
- package/dist/cjs/llm/truncation.cjs +0 -36
- package/dist/cjs/llm/truncation.cjs.map +1 -1
- package/dist/cjs/llm/vertexai/index.cjs +0 -330
- package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
- package/dist/cjs/messages/alternation.cjs +0 -43
- package/dist/cjs/messages/alternation.cjs.map +1 -1
- package/dist/cjs/messages/anthropicToolCache.cjs +0 -45
- package/dist/cjs/messages/anthropicToolCache.cjs.map +1 -1
- package/dist/cjs/messages/assistantPhase.cjs +0 -12
- package/dist/cjs/messages/assistantPhase.cjs.map +1 -1
- package/dist/cjs/messages/budget.cjs +0 -9
- package/dist/cjs/messages/budget.cjs.map +1 -1
- package/dist/cjs/messages/cache.cjs +0 -172
- package/dist/cjs/messages/cache.cjs.map +1 -1
- package/dist/cjs/messages/content.cjs +0 -9
- package/dist/cjs/messages/content.cjs.map +1 -1
- package/dist/cjs/messages/contextPruning.cjs +0 -15
- package/dist/cjs/messages/contextPruning.cjs.map +1 -1
- package/dist/cjs/messages/contextPruningSettings.cjs +0 -3
- package/dist/cjs/messages/contextPruningSettings.cjs.map +1 -1
- package/dist/cjs/messages/core.cjs +0 -48
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/cjs/messages/format.cjs +1 -345
- package/dist/cjs/messages/format.cjs.map +1 -1
- package/dist/cjs/messages/handoffCue.cjs +0 -36
- package/dist/cjs/messages/handoffCue.cjs.map +1 -1
- package/dist/cjs/messages/ids.cjs.map +1 -1
- package/dist/cjs/messages/injected.cjs +0 -33
- package/dist/cjs/messages/injected.cjs.map +1 -1
- package/dist/cjs/messages/langchain.cjs +0 -14
- package/dist/cjs/messages/langchain.cjs.map +1 -1
- package/dist/cjs/messages/prune.cjs +1 -184
- package/dist/cjs/messages/prune.cjs.map +1 -1
- package/dist/cjs/messages/recency.cjs +0 -32
- package/dist/cjs/messages/recency.cjs.map +1 -1
- package/dist/cjs/messages/reducer.cjs +0 -30
- package/dist/cjs/messages/reducer.cjs.map +1 -1
- package/dist/cjs/messages/tools.cjs +0 -14
- package/dist/cjs/messages/tools.cjs.map +1 -1
- package/dist/cjs/openai/index.cjs.map +1 -1
- package/dist/cjs/prompts/activityLabel.cjs +9 -79
- package/dist/cjs/prompts/activityLabel.cjs.map +1 -1
- package/dist/cjs/responses/index.cjs.map +1 -1
- package/dist/cjs/run.cjs +2 -538
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/session/AgentSession.cjs +1 -17
- package/dist/cjs/session/AgentSession.cjs.map +1 -1
- package/dist/cjs/session/JsonlSessionStore.cjs.map +1 -1
- package/dist/cjs/session/handlers.cjs +0 -7
- package/dist/cjs/session/handlers.cjs.map +1 -1
- package/dist/cjs/session/ids.cjs.map +1 -1
- package/dist/cjs/session/messageSerialization.cjs +0 -4
- package/dist/cjs/session/messageSerialization.cjs.map +1 -1
- package/dist/cjs/stream.cjs +1 -93
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/summarization/index.cjs +0 -27
- package/dist/cjs/summarization/index.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +0 -273
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/BashExecutor.cjs +0 -35
- package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +0 -24
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/Calculator.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +0 -13
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/CodeSessionFileSummary.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +0 -101
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ReadFile.cjs.map +1 -1
- package/dist/cjs/tools/SkillTool.cjs +0 -5
- package/dist/cjs/tools/SkillTool.cjs.map +1 -1
- package/dist/cjs/tools/SubagentTool.cjs +0 -10
- package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +6 -1038
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearch.cjs +0 -179
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareBridgeRuntime.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs +0 -39
- package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs.map +1 -1
- package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs.map +1 -1
- package/dist/cjs/tools/eagerEventExecution.cjs +0 -6
- package/dist/cjs/tools/eagerEventExecution.cjs.map +1 -1
- package/dist/cjs/tools/handlers.cjs +1 -41
- package/dist/cjs/tools/handlers.cjs.map +1 -1
- package/dist/cjs/tools/intentArg.cjs +1 -132
- package/dist/cjs/tools/intentArg.cjs.map +1 -1
- package/dist/cjs/tools/local/CompileCheckTool.cjs +0 -25
- package/dist/cjs/tools/local/CompileCheckTool.cjs.map +1 -1
- package/dist/cjs/tools/local/FileCheckpointer.cjs +0 -23
- package/dist/cjs/tools/local/FileCheckpointer.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalCodingTools.cjs +0 -80
- package/dist/cjs/tools/local/LocalCodingTools.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs +0 -126
- package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalExecutionTools.cjs.map +1 -1
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +0 -12
- package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/local/attachments.cjs +0 -44
- package/dist/cjs/tools/local/attachments.cjs.map +1 -1
- package/dist/cjs/tools/local/bashAst.cjs +0 -16
- package/dist/cjs/tools/local/bashAst.cjs.map +1 -1
- package/dist/cjs/tools/local/editStrategies.cjs +0 -14
- package/dist/cjs/tools/local/editStrategies.cjs.map +1 -1
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
- package/dist/cjs/tools/local/syntaxCheck.cjs +0 -31
- package/dist/cjs/tools/local/syntaxCheck.cjs.map +1 -1
- package/dist/cjs/tools/local/textEncoding.cjs +0 -11
- package/dist/cjs/tools/local/textEncoding.cjs.map +1 -1
- package/dist/cjs/tools/local/workspaceFS.cjs +0 -33
- package/dist/cjs/tools/local/workspaceFS.cjs.map +1 -1
- package/dist/cjs/tools/ptcTimeout.cjs.map +1 -1
- package/dist/cjs/tools/schema.cjs +0 -8
- package/dist/cjs/tools/schema.cjs.map +1 -1
- package/dist/cjs/tools/search/anthropic.cjs +0 -9
- package/dist/cjs/tools/search/anthropic.cjs.map +1 -1
- package/dist/cjs/tools/search/content.cjs.map +1 -1
- package/dist/cjs/tools/search/crw-scraper.cjs +0 -33
- package/dist/cjs/tools/search/crw-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/crw-search.cjs +0 -2
- package/dist/cjs/tools/search/crw-search.cjs.map +1 -1
- package/dist/cjs/tools/search/firecrawl.cjs +0 -25
- package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
- package/dist/cjs/tools/search/format.cjs +0 -30
- package/dist/cjs/tools/search/format.cjs.map +1 -1
- package/dist/cjs/tools/search/highlights.cjs +0 -16
- package/dist/cjs/tools/search/highlights.cjs.map +1 -1
- package/dist/cjs/tools/search/keenable-scraper.cjs +0 -8
- package/dist/cjs/tools/search/keenable-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/keenable-search.cjs +0 -7
- package/dist/cjs/tools/search/keenable-search.cjs.map +1 -1
- package/dist/cjs/tools/search/rerankers.cjs +0 -35
- package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
- package/dist/cjs/tools/search/schema.cjs +0 -1
- package/dist/cjs/tools/search/schema.cjs.map +1 -1
- package/dist/cjs/tools/search/search.cjs +1 -14
- package/dist/cjs/tools/search/search.cjs.map +1 -1
- package/dist/cjs/tools/search/serper-scraper.cjs +0 -46
- package/dist/cjs/tools/search/serper-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/tavily-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/tavily-search.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +0 -25
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/tools/search/utils.cjs +0 -8
- package/dist/cjs/tools/search/utils.cjs.map +1 -1
- package/dist/cjs/tools/skillCatalog.cjs +0 -6
- package/dist/cjs/tools/skillCatalog.cjs.map +1 -1
- package/dist/cjs/tools/streamedToolCallSeals.cjs +0 -6
- package/dist/cjs/tools/streamedToolCallSeals.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs +0 -2
- package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +3 -213
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentReplay.cjs.map +1 -1
- package/dist/cjs/tools/subagent/childGraphConfig.cjs +0 -4
- package/dist/cjs/tools/subagent/childGraphConfig.cjs.map +1 -1
- package/dist/cjs/tools/subagent/runtimeLimits.cjs.map +1 -1
- package/dist/cjs/tools/toolOutputReferences.cjs +1 -322
- package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -1
- package/dist/cjs/types/hitl.cjs +0 -5
- package/dist/cjs/types/hitl.cjs.map +1 -1
- package/dist/cjs/utils/callbacks.cjs.map +1 -1
- package/dist/cjs/utils/errors.cjs +14 -165
- package/dist/cjs/utils/errors.cjs.map +1 -1
- package/dist/cjs/utils/events.cjs +0 -10
- package/dist/cjs/utils/events.cjs.map +1 -1
- package/dist/cjs/utils/graph.cjs.map +1 -1
- package/dist/cjs/utils/handlers.cjs +0 -3
- package/dist/cjs/utils/handlers.cjs.map +1 -1
- package/dist/cjs/utils/llm.cjs +0 -1
- package/dist/cjs/utils/llm.cjs.map +1 -1
- package/dist/cjs/utils/misc.cjs +0 -16
- package/dist/cjs/utils/misc.cjs.map +1 -1
- package/dist/cjs/utils/proxy.cjs +0 -26
- package/dist/cjs/utils/proxy.cjs.map +1 -1
- package/dist/cjs/utils/run.cjs +0 -6
- package/dist/cjs/utils/run.cjs.map +1 -1
- package/dist/cjs/utils/schema.cjs +0 -5
- package/dist/cjs/utils/schema.cjs.map +1 -1
- package/dist/cjs/utils/title.cjs +0 -6
- package/dist/cjs/utils/title.cjs.map +1 -1
- package/dist/cjs/utils/tokens.cjs +0 -113
- package/dist/cjs/utils/tokens.cjs.map +1 -1
- package/dist/cjs/utils/toolContent.cjs +0 -41
- package/dist/cjs/utils/toolContent.cjs.map +1 -1
- package/dist/cjs/utils/truncation.cjs +0 -61
- package/dist/cjs/utils/truncation.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +0 -356
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/agents/projection.mjs +0 -9
- package/dist/esm/agents/projection.mjs.map +1 -1
- package/dist/esm/common/constants.mjs +0 -26
- package/dist/esm/common/constants.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +0 -85
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/events.mjs +0 -14
- package/dist/esm/events.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +1 -909
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +7 -272
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/graphs/applyGraphRuntimeConfig.mjs.map +1 -1
- package/dist/esm/graphs/createGraph.mjs.map +1 -1
- package/dist/esm/hitl/askUserQuestion.mjs +0 -53
- package/dist/esm/hitl/askUserQuestion.mjs.map +1 -1
- package/dist/esm/hitl/askUserQuestions.mjs +0 -20
- package/dist/esm/hitl/askUserQuestions.mjs.map +1 -1
- package/dist/esm/hitl/askUserQuestionsInterrupt.mjs +0 -6
- package/dist/esm/hitl/askUserQuestionsInterrupt.mjs.map +1 -1
- package/dist/esm/hooks/HookRegistry.mjs +0 -127
- package/dist/esm/hooks/HookRegistry.mjs.map +1 -1
- package/dist/esm/hooks/createToolPolicyHook.mjs +0 -38
- package/dist/esm/hooks/createToolPolicyHook.mjs.map +1 -1
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs +0 -77
- package/dist/esm/hooks/createWorkspacePolicyHook.mjs.map +1 -1
- package/dist/esm/hooks/executeHooks.mjs +0 -79
- package/dist/esm/hooks/executeHooks.mjs.map +1 -1
- package/dist/esm/hooks/index.mjs +0 -16
- package/dist/esm/hooks/index.mjs.map +1 -1
- package/dist/esm/hooks/matchers.mjs +0 -104
- package/dist/esm/hooks/matchers.mjs.map +1 -1
- package/dist/esm/hooks/types.mjs +0 -8
- package/dist/esm/hooks/types.mjs.map +1 -1
- package/dist/esm/instrumentation.mjs +0 -14
- package/dist/esm/instrumentation.mjs.map +1 -1
- package/dist/esm/langfuse.mjs +0 -75
- package/dist/esm/langfuse.mjs.map +1 -1
- package/dist/esm/langfuseConfig.mjs.map +1 -1
- package/dist/esm/langfuseRuntimeContext.mjs +0 -13
- package/dist/esm/langfuseRuntimeContext.mjs.map +1 -1
- package/dist/esm/langfuseRuntimeScope.mjs +0 -4
- package/dist/esm/langfuseRuntimeScope.mjs.map +1 -1
- package/dist/esm/langfuseSpanRegistry.mjs +0 -28
- package/dist/esm/langfuseSpanRegistry.mjs.map +1 -1
- package/dist/esm/langfuseToolOutputTracing.mjs +0 -3
- package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
- package/dist/esm/langfuseTraceShaping.mjs +0 -74
- package/dist/esm/langfuseTraceShaping.mjs.map +1 -1
- package/dist/esm/llm/anthropic/index.mjs +0 -3
- package/dist/esm/llm/anthropic/index.mjs.map +1 -1
- package/dist/esm/llm/anthropic/types.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +1 -111
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs +0 -1
- package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/stream_events.mjs +0 -8
- package/dist/esm/llm/anthropic/utils/stream_events.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -1
- package/dist/esm/llm/bedrock/cachePoints.mjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +1 -95
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/dist/esm/llm/bedrock/toolCache.mjs.map +1 -1
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs +0 -78
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/bedrock/utils/message_outputs.mjs +0 -24
- package/dist/esm/llm/bedrock/utils/message_outputs.mjs.map +1 -1
- package/dist/esm/llm/contextOverflowRecovery.mjs +0 -62
- package/dist/esm/llm/contextOverflowRecovery.mjs.map +1 -1
- package/dist/esm/llm/fake.mjs.map +1 -1
- package/dist/esm/llm/google/index.mjs +2 -21
- package/dist/esm/llm/google/index.mjs.map +1 -1
- package/dist/esm/llm/google/utils/common.mjs +5 -35
- package/dist/esm/llm/google/utils/common.mjs.map +1 -1
- package/dist/esm/llm/init.mjs +0 -9
- package/dist/esm/llm/init.mjs.map +1 -1
- package/dist/esm/llm/invoke.mjs +1 -270
- package/dist/esm/llm/invoke.mjs.map +1 -1
- package/dist/esm/llm/mistral/index.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +0 -99
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/openai/streamMetadata.mjs +0 -21
- package/dist/esm/llm/openai/streamMetadata.mjs.map +1 -1
- package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/index.mjs +0 -1
- package/dist/esm/llm/openrouter/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/toolCache.mjs +0 -6
- package/dist/esm/llm/openrouter/toolCache.mjs.map +1 -1
- package/dist/esm/llm/preempt.mjs +0 -75
- package/dist/esm/llm/preempt.mjs.map +1 -1
- package/dist/esm/llm/providers.mjs.map +1 -1
- package/dist/esm/llm/request.mjs +0 -10
- package/dist/esm/llm/request.mjs.map +1 -1
- package/dist/esm/llm/stream/chunkAdapters.mjs +0 -62
- package/dist/esm/llm/stream/chunkAdapters.mjs.map +1 -1
- package/dist/esm/llm/stream/smoother.mjs +0 -58
- package/dist/esm/llm/stream/smoother.mjs.map +1 -1
- package/dist/esm/llm/streamLimits.mjs +4 -293
- package/dist/esm/llm/streamLimits.mjs.map +1 -1
- package/dist/esm/llm/truncation.mjs +0 -36
- package/dist/esm/llm/truncation.mjs.map +1 -1
- package/dist/esm/llm/vertexai/index.mjs +0 -330
- package/dist/esm/llm/vertexai/index.mjs.map +1 -1
- package/dist/esm/messages/alternation.mjs +0 -43
- package/dist/esm/messages/alternation.mjs.map +1 -1
- package/dist/esm/messages/anthropicToolCache.mjs +0 -45
- package/dist/esm/messages/anthropicToolCache.mjs.map +1 -1
- package/dist/esm/messages/assistantPhase.mjs +0 -12
- package/dist/esm/messages/assistantPhase.mjs.map +1 -1
- package/dist/esm/messages/budget.mjs +0 -9
- package/dist/esm/messages/budget.mjs.map +1 -1
- package/dist/esm/messages/cache.mjs +0 -172
- package/dist/esm/messages/cache.mjs.map +1 -1
- package/dist/esm/messages/content.mjs +0 -9
- package/dist/esm/messages/content.mjs.map +1 -1
- package/dist/esm/messages/contextPruning.mjs +0 -15
- package/dist/esm/messages/contextPruning.mjs.map +1 -1
- package/dist/esm/messages/contextPruningSettings.mjs +0 -3
- package/dist/esm/messages/contextPruningSettings.mjs.map +1 -1
- package/dist/esm/messages/core.mjs +0 -48
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/esm/messages/format.mjs +1 -345
- package/dist/esm/messages/format.mjs.map +1 -1
- package/dist/esm/messages/handoffCue.mjs +0 -36
- package/dist/esm/messages/handoffCue.mjs.map +1 -1
- package/dist/esm/messages/ids.mjs.map +1 -1
- package/dist/esm/messages/injected.mjs +0 -33
- package/dist/esm/messages/injected.mjs.map +1 -1
- package/dist/esm/messages/langchain.mjs +0 -14
- package/dist/esm/messages/langchain.mjs.map +1 -1
- package/dist/esm/messages/prune.mjs +1 -184
- package/dist/esm/messages/prune.mjs.map +1 -1
- package/dist/esm/messages/recency.mjs +0 -32
- package/dist/esm/messages/recency.mjs.map +1 -1
- package/dist/esm/messages/reducer.mjs +0 -30
- package/dist/esm/messages/reducer.mjs.map +1 -1
- package/dist/esm/messages/tools.mjs +0 -14
- package/dist/esm/messages/tools.mjs.map +1 -1
- package/dist/esm/openai/index.mjs.map +1 -1
- package/dist/esm/prompts/activityLabel.mjs +9 -79
- package/dist/esm/prompts/activityLabel.mjs.map +1 -1
- package/dist/esm/responses/index.mjs.map +1 -1
- package/dist/esm/run.mjs +2 -538
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/session/AgentSession.mjs +1 -17
- package/dist/esm/session/AgentSession.mjs.map +1 -1
- package/dist/esm/session/JsonlSessionStore.mjs.map +1 -1
- package/dist/esm/session/handlers.mjs +0 -7
- package/dist/esm/session/handlers.mjs.map +1 -1
- package/dist/esm/session/ids.mjs.map +1 -1
- package/dist/esm/session/messageSerialization.mjs +0 -4
- package/dist/esm/session/messageSerialization.mjs.map +1 -1
- package/dist/esm/stream.mjs +1 -93
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/summarization/index.mjs +0 -27
- package/dist/esm/summarization/index.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +0 -273
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/BashExecutor.mjs +0 -35
- package/dist/esm/tools/BashExecutor.mjs.map +1 -1
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +0 -24
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/Calculator.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +0 -13
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/CodeSessionFileSummary.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +0 -101
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ReadFile.mjs.map +1 -1
- package/dist/esm/tools/SkillTool.mjs +0 -5
- package/dist/esm/tools/SkillTool.mjs.map +1 -1
- package/dist/esm/tools/SubagentTool.mjs +0 -10
- package/dist/esm/tools/SubagentTool.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +6 -1038
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearch.mjs +0 -179
- package/dist/esm/tools/ToolSearch.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareBridgeRuntime.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs +0 -39
- package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs.map +1 -1
- package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs.map +1 -1
- package/dist/esm/tools/eagerEventExecution.mjs +0 -6
- package/dist/esm/tools/eagerEventExecution.mjs.map +1 -1
- package/dist/esm/tools/handlers.mjs +1 -41
- package/dist/esm/tools/handlers.mjs.map +1 -1
- package/dist/esm/tools/intentArg.mjs +1 -132
- package/dist/esm/tools/intentArg.mjs.map +1 -1
- package/dist/esm/tools/local/CompileCheckTool.mjs +0 -25
- package/dist/esm/tools/local/CompileCheckTool.mjs.map +1 -1
- package/dist/esm/tools/local/FileCheckpointer.mjs +0 -23
- package/dist/esm/tools/local/FileCheckpointer.mjs.map +1 -1
- package/dist/esm/tools/local/LocalCodingTools.mjs +0 -80
- package/dist/esm/tools/local/LocalCodingTools.mjs.map +1 -1
- package/dist/esm/tools/local/LocalExecutionEngine.mjs +0 -126
- package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -1
- package/dist/esm/tools/local/LocalExecutionTools.mjs.map +1 -1
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +0 -12
- package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/local/attachments.mjs +0 -44
- package/dist/esm/tools/local/attachments.mjs.map +1 -1
- package/dist/esm/tools/local/bashAst.mjs +0 -16
- package/dist/esm/tools/local/bashAst.mjs.map +1 -1
- package/dist/esm/tools/local/editStrategies.mjs +0 -14
- package/dist/esm/tools/local/editStrategies.mjs.map +1 -1
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
- package/dist/esm/tools/local/syntaxCheck.mjs +0 -31
- package/dist/esm/tools/local/syntaxCheck.mjs.map +1 -1
- package/dist/esm/tools/local/textEncoding.mjs +0 -11
- package/dist/esm/tools/local/textEncoding.mjs.map +1 -1
- package/dist/esm/tools/local/workspaceFS.mjs +0 -33
- package/dist/esm/tools/local/workspaceFS.mjs.map +1 -1
- package/dist/esm/tools/ptcTimeout.mjs.map +1 -1
- package/dist/esm/tools/schema.mjs +0 -8
- package/dist/esm/tools/schema.mjs.map +1 -1
- package/dist/esm/tools/search/anthropic.mjs +0 -9
- package/dist/esm/tools/search/anthropic.mjs.map +1 -1
- package/dist/esm/tools/search/content.mjs.map +1 -1
- package/dist/esm/tools/search/crw-scraper.mjs +0 -33
- package/dist/esm/tools/search/crw-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/crw-search.mjs +0 -2
- package/dist/esm/tools/search/crw-search.mjs.map +1 -1
- package/dist/esm/tools/search/firecrawl.mjs +0 -25
- package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
- package/dist/esm/tools/search/format.mjs +0 -30
- package/dist/esm/tools/search/format.mjs.map +1 -1
- package/dist/esm/tools/search/highlights.mjs +0 -16
- package/dist/esm/tools/search/highlights.mjs.map +1 -1
- package/dist/esm/tools/search/keenable-scraper.mjs +0 -8
- package/dist/esm/tools/search/keenable-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/keenable-search.mjs +0 -7
- package/dist/esm/tools/search/keenable-search.mjs.map +1 -1
- package/dist/esm/tools/search/rerankers.mjs +0 -35
- package/dist/esm/tools/search/rerankers.mjs.map +1 -1
- package/dist/esm/tools/search/schema.mjs +0 -1
- package/dist/esm/tools/search/schema.mjs.map +1 -1
- package/dist/esm/tools/search/search.mjs +1 -14
- package/dist/esm/tools/search/search.mjs.map +1 -1
- package/dist/esm/tools/search/serper-scraper.mjs +0 -46
- package/dist/esm/tools/search/serper-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/tavily-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/tavily-search.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +0 -25
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/tools/search/utils.mjs +0 -8
- package/dist/esm/tools/search/utils.mjs.map +1 -1
- package/dist/esm/tools/skillCatalog.mjs +0 -6
- package/dist/esm/tools/skillCatalog.mjs.map +1 -1
- package/dist/esm/tools/streamedToolCallSeals.mjs +0 -6
- package/dist/esm/tools/streamedToolCallSeals.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs +0 -2
- package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +3 -213
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentReplay.mjs.map +1 -1
- package/dist/esm/tools/subagent/childGraphConfig.mjs +0 -4
- package/dist/esm/tools/subagent/childGraphConfig.mjs.map +1 -1
- package/dist/esm/tools/subagent/runtimeLimits.mjs.map +1 -1
- package/dist/esm/tools/toolOutputReferences.mjs +1 -322
- package/dist/esm/tools/toolOutputReferences.mjs.map +1 -1
- package/dist/esm/types/hitl.mjs +0 -5
- package/dist/esm/types/hitl.mjs.map +1 -1
- package/dist/esm/utils/callbacks.mjs.map +1 -1
- package/dist/esm/utils/errors.mjs +14 -165
- package/dist/esm/utils/errors.mjs.map +1 -1
- package/dist/esm/utils/events.mjs +0 -10
- package/dist/esm/utils/events.mjs.map +1 -1
- package/dist/esm/utils/graph.mjs.map +1 -1
- package/dist/esm/utils/handlers.mjs +0 -3
- package/dist/esm/utils/handlers.mjs.map +1 -1
- package/dist/esm/utils/llm.mjs +0 -1
- package/dist/esm/utils/llm.mjs.map +1 -1
- package/dist/esm/utils/misc.mjs +0 -16
- package/dist/esm/utils/misc.mjs.map +1 -1
- package/dist/esm/utils/proxy.mjs +0 -26
- package/dist/esm/utils/proxy.mjs.map +1 -1
- package/dist/esm/utils/run.mjs +0 -6
- package/dist/esm/utils/run.mjs.map +1 -1
- package/dist/esm/utils/schema.mjs +0 -5
- package/dist/esm/utils/schema.mjs.map +1 -1
- package/dist/esm/utils/title.mjs +0 -6
- package/dist/esm/utils/title.mjs.map +1 -1
- package/dist/esm/utils/tokens.mjs +0 -113
- package/dist/esm/utils/tokens.mjs.map +1 -1
- package/dist/esm/utils/toolContent.mjs +0 -41
- package/dist/esm/utils/toolContent.mjs.map +1 -1
- package/dist/esm/utils/truncation.mjs +0 -61
- package/dist/esm/utils/truncation.mjs.map +1 -1
- package/dist/types/agents/AgentContext.d.ts +3 -3
- package/dist/types/agents/__tests__/promptCacheLiveHelpers.d.ts +3 -3
- package/dist/types/agents/projection.d.ts +1 -1
- package/dist/types/events.d.ts +2 -2
- package/dist/types/graphs/Graph.d.ts +11 -11
- package/dist/types/graphs/MultiAgentGraph.d.ts +2 -2
- package/dist/types/graphs/createGraph.d.ts +4 -4
- package/dist/types/graphs/graphFactory.d.ts +1 -1
- package/dist/types/hitl/askUserQuestion.d.ts +1 -1
- package/dist/types/hitl/askUserQuestions.d.ts +1 -1
- package/dist/types/hitl/askUserQuestionsInterrupt.d.ts +1 -1
- package/dist/types/hooks/types.d.ts +1 -1
- package/dist/types/instrumentation.d.ts +1 -1
- package/dist/types/langfuse.d.ts +3 -3
- package/dist/types/langfuseConfig.d.ts +2 -2
- package/dist/types/langfuseRuntimeContext.d.ts +1 -1
- package/dist/types/langfuseRuntimeScope.d.ts +2 -2
- package/dist/types/langfuseSpanRegistry.d.ts +1 -1
- package/dist/types/langfuseToolOutputTracing.d.ts +3 -3
- package/dist/types/llm/anthropic/index.d.ts +1 -1
- package/dist/types/llm/bedrock/index.d.ts +1 -1
- package/dist/types/llm/bedrock/toolCache.d.ts +2 -2
- package/dist/types/llm/contextOverflowRecovery.d.ts +2 -2
- package/dist/types/llm/google/index.d.ts +1 -1
- package/dist/types/llm/init.d.ts +2 -2
- package/dist/types/llm/invoke.d.ts +6 -6
- package/dist/types/llm/mistral/index.d.ts +1 -1
- package/dist/types/llm/openai/index.d.ts +2 -2
- package/dist/types/llm/openrouter/index.d.ts +2 -2
- package/dist/types/llm/openrouter/toolCache.d.ts +2 -2
- package/dist/types/llm/providers.d.ts +2 -2
- package/dist/types/llm/request.d.ts +2 -2
- package/dist/types/llm/stream/chunkAdapters.d.ts +1 -1
- package/dist/types/llm/streamLimits.d.ts +1 -1
- package/dist/types/llm/truncation.d.ts +1 -1
- package/dist/types/llm/vertexai/index.d.ts +1 -1
- package/dist/types/messages/alternation.d.ts +1 -1
- package/dist/types/messages/anthropicToolCache.d.ts +2 -2
- package/dist/types/messages/assistantPhase.d.ts +3 -3
- package/dist/types/messages/budget.d.ts +1 -1
- package/dist/types/messages/cache.d.ts +1 -1
- package/dist/types/messages/contextPruning.d.ts +2 -2
- package/dist/types/messages/core.d.ts +2 -2
- package/dist/types/messages/format.d.ts +2 -2
- package/dist/types/messages/ids.d.ts +2 -2
- package/dist/types/messages/injected.d.ts +1 -1
- package/dist/types/messages/langchain.d.ts +1 -1
- package/dist/types/messages/prune.d.ts +3 -3
- package/dist/types/openai/index.d.ts +1 -1
- package/dist/types/prompts/activityLabel.d.ts +2 -2
- package/dist/types/responses/index.d.ts +1 -1
- package/dist/types/run.d.ts +3 -3
- package/dist/types/session/handlers.d.ts +1 -1
- package/dist/types/session/types.d.ts +1 -1
- package/dist/types/stream.d.ts +4 -4
- package/dist/types/summarization/index.d.ts +1 -1
- package/dist/types/summarization/node.d.ts +6 -6
- package/dist/types/test/mockTools.d.ts +1 -1
- package/dist/types/tools/BashExecutor.d.ts +2 -2
- package/dist/types/tools/BashProgrammaticToolCalling.d.ts +2 -2
- package/dist/types/tools/CodeExecutor.d.ts +3 -3
- package/dist/types/tools/CodeSessionFileSummary.d.ts +1 -1
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +2 -2
- package/dist/types/tools/ReadFile.d.ts +1 -1
- package/dist/types/tools/SkillTool.d.ts +1 -1
- package/dist/types/tools/SubagentTool.d.ts +3 -3
- package/dist/types/tools/ToolNode.d.ts +5 -5
- package/dist/types/tools/ToolSearch.d.ts +2 -2
- package/dist/types/tools/cloudflare/CloudflareBridgeRuntime.d.ts +1 -1
- package/dist/types/tools/cloudflare/CloudflareProgrammaticToolCalling.d.ts +1 -1
- package/dist/types/tools/cloudflare/CloudflareSandboxExecutionEngine.d.ts +2 -2
- package/dist/types/tools/cloudflare/CloudflareSandboxTools.d.ts +1 -1
- package/dist/types/tools/eagerEventExecution.d.ts +1 -1
- package/dist/types/tools/handlers.d.ts +3 -3
- package/dist/types/tools/intentArg.d.ts +1 -1
- package/dist/types/tools/local/CompileCheckTool.d.ts +2 -2
- package/dist/types/tools/local/FileCheckpointer.d.ts +1 -1
- package/dist/types/tools/local/LocalCodingTools.d.ts +2 -2
- package/dist/types/tools/local/LocalExecutionEngine.d.ts +1 -1
- package/dist/types/tools/local/LocalExecutionTools.d.ts +1 -1
- package/dist/types/tools/local/LocalProgrammaticToolCalling.d.ts +1 -1
- package/dist/types/tools/local/bashAst.d.ts +1 -1
- package/dist/types/tools/local/resolveLocalExecutionTools.d.ts +1 -1
- package/dist/types/tools/local/syntaxCheck.d.ts +1 -1
- package/dist/types/tools/ptcTimeout.d.ts +1 -1
- package/dist/types/tools/schema.d.ts +1 -1
- package/dist/types/tools/search/anthropic.d.ts +1 -1
- package/dist/types/tools/skillCatalog.d.ts +1 -1
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +5 -5
- package/dist/types/tools/subagent/SubagentReplay.d.ts +3 -3
- package/dist/types/tools/subagent/childGraphConfig.d.ts +2 -2
- package/dist/types/types/activityLabel.d.ts +3 -3
- package/dist/types/types/graph.d.ts +7 -7
- package/dist/types/types/llm.d.ts +9 -9
- package/dist/types/types/run.d.ts +7 -7
- package/dist/types/types/stream.d.ts +5 -5
- package/dist/types/types/summarize.d.ts +2 -2
- package/dist/types/types/tools.d.ts +5 -5
- package/dist/types/utils/__tests__/fixtures/contextOverflowSignatures.d.ts +1 -1
- package/dist/types/utils/errors.d.ts +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/handlers.d.ts +3 -3
- package/dist/types/utils/llm.d.ts +1 -1
- package/dist/types/utils/llmConfig.d.ts +1 -1
- package/dist/types/utils/title.d.ts +1 -1
- package/package.json +10 -3
- package/src/llm/google/utils/common.ts +6 -4
- package/src/__tests__/stream.eagerArgsDivergence.test.ts +0 -911
- package/src/__tests__/stream.eagerEventExecution.test.ts +0 -5046
- package/src/__tests__/stream.streamLimits.test.ts +0 -1982
- package/src/agents/__tests__/AgentContext.anthropic.live.test.ts +0 -448
- package/src/agents/__tests__/AgentContext.bedrock.live.test.ts +0 -655
- package/src/agents/__tests__/AgentContext.openrouter.live.test.ts +0 -128
- package/src/agents/__tests__/AgentContext.overflow.test.ts +0 -205
- package/src/agents/__tests__/AgentContext.test.ts +0 -2425
- package/src/agents/__tests__/projection.test.ts +0 -73
- package/src/agents/__tests__/promptCacheLiveHelpers.ts +0 -175
- package/src/aggregator.test.ts +0 -1214
- package/src/graphs/__tests__/Graph.breakerLifecycle.test.ts +0 -273
- package/src/graphs/__tests__/Graph.closeRunStep.test.ts +0 -385
- package/src/graphs/__tests__/Graph.contextOverflow.test.ts +0 -1766
- package/src/graphs/__tests__/Graph.preemptSignal.test.ts +0 -126
- package/src/graphs/__tests__/Graph.reasoning.test.ts +0 -1717
- package/src/graphs/__tests__/Graph.subagentResumeState.test.ts +0 -80
- package/src/graphs/__tests__/MultiAgentGraph.test.ts +0 -177
- package/src/graphs/__tests__/composition.smoke.test.ts +0 -509
- package/src/graphs/__tests__/createGraph.test.ts +0 -206
- package/src/hooks/__tests__/HookRegistry.test.ts +0 -334
- package/src/hooks/__tests__/compactHooks.test.ts +0 -250
- package/src/hooks/__tests__/createToolPolicyHook.test.ts +0 -268
- package/src/hooks/__tests__/createWorkspacePolicyHook.test.ts +0 -405
- package/src/hooks/__tests__/executeHooks.test.ts +0 -1294
- package/src/hooks/__tests__/integration.test.ts +0 -337
- package/src/hooks/__tests__/matchers.test.ts +0 -238
- package/src/hooks/__tests__/preemptBoundary.test.ts +0 -152
- package/src/hooks/__tests__/toolHooks.test.ts +0 -669
- package/src/llm/__tests__/contextOverflowRecovery.test.ts +0 -401
- package/src/llm/__tests__/fallbackOverflow.test.ts +0 -287
- package/src/llm/anthropic/Jacob_Lee_Resume_2023.pdf +0 -0
- package/src/llm/anthropic/inherited-content-utils.spec.ts +0 -249
- package/src/llm/anthropic/inherited-stream-events.spec.ts +0 -1259
- package/src/llm/anthropic/inherited-strict.spec.ts +0 -302
- package/src/llm/anthropic/llm.spec.ts +0 -3394
- package/src/llm/anthropic/utils/cross-provider-reasoning.test.ts +0 -383
- package/src/llm/anthropic/utils/cross-provider-server-tools.test.ts +0 -110
- package/src/llm/anthropic/utils/server-tool-inputs.test.ts +0 -508
- package/src/llm/anthropic/utils/streaming-tool-input.test.ts +0 -361
- package/src/llm/anthropic/utils/stripPrefillCache.test.ts +0 -111
- package/src/llm/anthropic/utils/tool-id-normalization.test.ts +0 -287
- package/src/llm/bedrock/inherited-cache.spec.ts +0 -144
- package/src/llm/bedrock/inherited.spec.ts +0 -724
- package/src/llm/bedrock/llm.spec.ts +0 -1533
- package/src/llm/bedrock/streamSealDispatch.test.ts +0 -331
- package/src/llm/bedrock/toolCache.test.ts +0 -194
- package/src/llm/bedrock/utils/cross-provider-reasoning.test.ts +0 -131
- package/src/llm/bedrock/utils/cross-provider-server-tools.test.ts +0 -122
- package/src/llm/bedrock/utils/message_inputs.test.ts +0 -650
- package/src/llm/bedrock/utils/message_outputs.test.ts +0 -85
- package/src/llm/bedrock/utils/toolResultCachePoint.test.ts +0 -118
- package/src/llm/custom-chat-models.smoke.test.ts +0 -1966
- package/src/llm/google/data/gettysburg10.wav +0 -0
- package/src/llm/google/data/hotdog.jpg +0 -0
- package/src/llm/google/inherited-stream-events.spec.ts +0 -350
- package/src/llm/google/llm.spec.ts +0 -1388
- package/src/llm/google/streamSmoothing.test.ts +0 -121
- package/src/llm/google/utils/common.test.ts +0 -185
- package/src/llm/invoke.alternation.test.ts +0 -87
- package/src/llm/invoke.handoffCue.test.ts +0 -112
- package/src/llm/invoke.streamLimits.test.ts +0 -142
- package/src/llm/invoke.test.ts +0 -1198
- package/src/llm/mistral/streamSmoothing.test.ts +0 -97
- package/src/llm/openai/cacheWriteTokens.test.ts +0 -112
- package/src/llm/openai/contentBlocks.test.ts +0 -381
- package/src/llm/openai/deepseek.test.ts +0 -747
- package/src/llm/openai/inherited-deepseek.spec.ts +0 -347
- package/src/llm/openai/inherited-xai.spec.ts +0 -416
- package/src/llm/openai/llm.spec.ts +0 -1774
- package/src/llm/openai/managedRequests.test.ts +0 -182
- package/src/llm/openai/sequentialToolCallSeals.test.ts +0 -199
- package/src/llm/openai/streamMetadata.spec.ts +0 -86
- package/src/llm/openai/streamMetadataDedup.spec.ts +0 -166
- package/src/llm/openai/utils/isReasoningModel.test.ts +0 -90
- package/src/llm/openai/utils/messages.test.ts +0 -488
- package/src/llm/openrouter/reasoning.test.ts +0 -561
- package/src/llm/openrouter/toolCache.test.ts +0 -134
- package/src/llm/preempt.test.ts +0 -323
- package/src/llm/stream/chunkAdapters.test.ts +0 -202
- package/src/llm/stream/reassembly.test.ts +0 -241
- package/src/llm/stream/smoother.bench.test.ts +0 -155
- package/src/llm/stream/smoother.test.ts +0 -519
- package/src/llm/streamLimits.test.ts +0 -450
- package/src/llm/truncation.test.ts +0 -242
- package/src/llm/vertexai/fixThoughtSignatures.test.ts +0 -154
- package/src/llm/vertexai/inherited-stream-events.spec.ts +0 -271
- package/src/llm/vertexai/llm.spec.ts +0 -159
- package/src/llm/vertexai/repairUsageMetadata.test.ts +0 -54
- package/src/llm/vertexai/sealStreamedToolCalls.test.ts +0 -88
- package/src/llm/vertexai/streamSealDispatch.test.ts +0 -148
- package/src/llm/vertexai/streamSmoothing.test.ts +0 -109
- package/src/messages/__tests__/anthropicToolCache.test.ts +0 -339
- package/src/messages/__tests__/observationMasking.test.ts +0 -312
- package/src/messages/__tests__/recency.test.ts +0 -267
- package/src/messages/__tests__/tools.test.ts +0 -473
- package/src/messages/alternation.test.ts +0 -212
- package/src/messages/assistantPhase.test.ts +0 -75
- package/src/messages/cache.tail.test.ts +0 -533
- package/src/messages/cache.test.ts +0 -2166
- package/src/messages/content.test.ts +0 -362
- package/src/messages/contextPruning.test.ts +0 -184
- package/src/messages/ensureThinkingBlock.test.ts +0 -1427
- package/src/messages/foldToollessToolBlocks.test.ts +0 -596
- package/src/messages/formatAgentMessages.reducer.test.ts +0 -162
- package/src/messages/formatAgentMessages.skills.test.ts +0 -513
- package/src/messages/formatAgentMessages.steer.test.ts +0 -598
- package/src/messages/formatAgentMessages.test.ts +0 -8111
- package/src/messages/formatAgentMessages.tools.test.ts +0 -522
- package/src/messages/formatMessage.test.ts +0 -693
- package/src/messages/handoffCue.test.ts +0 -96
- package/src/messages/injected.test.ts +0 -107
- package/src/messages/labelContentByAgent.test.ts +0 -962
- package/src/messages/reducer.spec.ts +0 -32
- package/src/messages/shiftIndexTokenCountMap.test.ts +0 -81
- package/src/messages/tailCacheConversion.test.ts +0 -161
- package/src/openai/__tests__/openai.test.ts +0 -337
- package/src/responses/__tests__/responses.test.ts +0 -652
- package/src/scripts/abort.ts +0 -157
- package/src/scripts/activity-labels/captured.json +0 -56
- package/src/scripts/activity-labels/checks.cjs +0 -205
- package/src/scripts/activity-labels/corpus.cjs +0 -473
- package/src/scripts/activity-labels/report.cjs +0 -203
- package/src/scripts/activity-labels/rescore.cjs +0 -102
- package/src/scripts/activity-labels/run.ts +0 -705
- package/src/scripts/activity-labels/variants.ts +0 -71
- package/src/scripts/ant_web_search.ts +0 -159
- package/src/scripts/ant_web_search_edge_case.ts +0 -163
- package/src/scripts/ant_web_search_error_edge_case.ts +0 -149
- package/src/scripts/args.ts +0 -48
- package/src/scripts/bedrock-cache-debug.ts +0 -250
- package/src/scripts/bedrock-content-aggregation-test.ts +0 -266
- package/src/scripts/bedrock-merge-test.ts +0 -107
- package/src/scripts/bedrock-parallel-tools-test.ts +0 -204
- package/src/scripts/bench-prompt-cache.ts +0 -479
- package/src/scripts/caching.ts +0 -132
- package/src/scripts/cli.ts +0 -172
- package/src/scripts/cli2.ts +0 -133
- package/src/scripts/cli3.ts +0 -184
- package/src/scripts/cli4.ts +0 -191
- package/src/scripts/cli5.ts +0 -191
- package/src/scripts/code_exec.ts +0 -214
- package/src/scripts/code_exec_files.ts +0 -237
- package/src/scripts/code_exec_multi_session.ts +0 -237
- package/src/scripts/code_exec_ptc.ts +0 -335
- package/src/scripts/code_exec_session.ts +0 -283
- package/src/scripts/code_exec_simple.ts +0 -148
- package/src/scripts/compare_pi_vs_ours.ts +0 -1259
- package/src/scripts/content.ts +0 -139
- package/src/scripts/context-overflow-probe.ts +0 -997
- package/src/scripts/empty_input.ts +0 -137
- package/src/scripts/handoff-test.ts +0 -134
- package/src/scripts/local_engine.ts +0 -166
- package/src/scripts/local_engine_checkpointer.ts +0 -205
- package/src/scripts/local_engine_compile.ts +0 -263
- package/src/scripts/local_engine_hooks.ts +0 -226
- package/src/scripts/local_engine_image.ts +0 -201
- package/src/scripts/local_engine_ptc.ts +0 -151
- package/src/scripts/local_engine_workspace.ts +0 -258
- package/src/scripts/memory.ts +0 -107
- package/src/scripts/multi-agent-chain.ts +0 -332
- package/src/scripts/multi-agent-conditional.ts +0 -222
- package/src/scripts/multi-agent-document-review-chain.ts +0 -198
- package/src/scripts/multi-agent-hybrid-flow.ts +0 -311
- package/src/scripts/multi-agent-parallel-start.ts +0 -265
- package/src/scripts/multi-agent-parallel.ts +0 -395
- package/src/scripts/multi-agent-sequence.ts +0 -217
- package/src/scripts/multi-agent-subagent.ts +0 -246
- package/src/scripts/multi-agent-supervisor.ts +0 -366
- package/src/scripts/multi-agent-test.ts +0 -187
- package/src/scripts/openrouter_prompt_cache_live.ts +0 -310
- package/src/scripts/parallel-asymmetric-tools-test.ts +0 -275
- package/src/scripts/parallel-full-metadata-test.ts +0 -241
- package/src/scripts/parallel-tools-test.ts +0 -341
- package/src/scripts/preempt-probe.ts +0 -330
- package/src/scripts/preempt-scenarios.ts +0 -388
- package/src/scripts/programmatic_exec.ts +0 -387
- package/src/scripts/programmatic_exec_agent.ts +0 -232
- package/src/scripts/search.ts +0 -147
- package/src/scripts/sequential-full-metadata-test.ts +0 -198
- package/src/scripts/session_live.ts +0 -548
- package/src/scripts/simple.ts +0 -226
- package/src/scripts/single-agent-metadata-test.ts +0 -196
- package/src/scripts/stream.ts +0 -141
- package/src/scripts/subagent-configurable-inheritance.ts +0 -252
- package/src/scripts/subagent-event-driven-debug.ts +0 -190
- package/src/scripts/subagent-tools-debug.ts +0 -160
- package/src/scripts/subagent-usage-sink.ts +0 -176
- package/src/scripts/summarization-recency.ts +0 -462
- package/src/scripts/test-custom-prompt-key.ts +0 -145
- package/src/scripts/test-handoff-input.ts +0 -170
- package/src/scripts/test-handoff-preamble.ts +0 -278
- package/src/scripts/test-handoff-steering.ts +0 -430
- package/src/scripts/test-multi-agent-list-handoff.ts +0 -418
- package/src/scripts/test-parallel-agent-labeling.ts +0 -327
- package/src/scripts/test-parallel-handoffs.ts +0 -292
- package/src/scripts/test-thinking-handoff-bedrock.ts +0 -154
- package/src/scripts/test-thinking-handoff.ts +0 -156
- package/src/scripts/test-thinking-to-thinking-handoff-bedrock.ts +0 -166
- package/src/scripts/test-tool-before-handoff-role-order.ts +0 -276
- package/src/scripts/test-tools-before-handoff.ts +0 -222
- package/src/scripts/test_code_api.ts +0 -354
- package/src/scripts/thinking-bedrock.ts +0 -160
- package/src/scripts/thinking-vertexai.ts +0 -168
- package/src/scripts/thinking.ts +0 -172
- package/src/scripts/tool_search.ts +0 -153
- package/src/scripts/tools.ts +0 -163
- package/src/session/__tests__/JsonlSessionStore.test.ts +0 -1463
- package/src/session/__tests__/handlers.test.ts +0 -161
- package/src/specs/activity-label-observability.live.test.ts +0 -262
- package/src/specs/activity-label-observability.test.ts +0 -167
- package/src/specs/activity-label-prompt.test.ts +0 -359
- package/src/specs/activity-label-trace-seed.test.ts +0 -47
- package/src/specs/activity-phase-label.test.ts +0 -306
- package/src/specs/agent-handoffs.live.test.ts +0 -140
- package/src/specs/agent-handoffs.test.ts +0 -2465
- package/src/specs/anthropic.simple.test.ts +0 -453
- package/src/specs/ask-user-question-batch.test.ts +0 -289
- package/src/specs/ask-user-questions.live.test.ts +0 -185
- package/src/specs/ask-user-questions.test.ts +0 -293
- package/src/specs/azure.simple.test.ts +0 -502
- package/src/specs/bedrock-toolless.live.test.ts +0 -123
- package/src/specs/bedrock-truncation.live.test.ts +0 -191
- package/src/specs/cache.simple.test.ts +0 -416
- package/src/specs/context-accuracy.live.test.ts +0 -409
- package/src/specs/context-overflow-recovery.live.test.ts +0 -213
- package/src/specs/context-usage-event.test.ts +0 -117
- package/src/specs/context-usage.live.test.ts +0 -297
- package/src/specs/custom-event-await.test.ts +0 -304
- package/src/specs/deepseek.simple.test.ts +0 -290
- package/src/specs/deterministic-trace-id.test.ts +0 -43
- package/src/specs/discovered-tools.test.ts +0 -217
- package/src/specs/durability-checkpoint.integration.test.ts +0 -243
- package/src/specs/graph-subagent.live.test.ts +0 -242
- package/src/specs/graph-subagent.test.ts +0 -322
- package/src/specs/handoffCue.test.ts +0 -165
- package/src/specs/langfuse-callbacks.test.ts +0 -1578
- package/src/specs/langfuse-config.test.ts +0 -247
- package/src/specs/langfuse-instrumentation.test.ts +0 -393
- package/src/specs/langfuse-metadata.test.ts +0 -245
- package/src/specs/langfuse-routing.integration.test.ts +0 -844
- package/src/specs/langfuse-runtime-context.test.ts +0 -92
- package/src/specs/langfuse-span-registry.test.ts +0 -87
- package/src/specs/langfuse-tool-output-tracing.test.ts +0 -1858
- package/src/specs/langfuse-trace-shaping.test.ts +0 -591
- package/src/specs/moonshot.simple.test.ts +0 -367
- package/src/specs/multi-agent-summarization.test.ts +0 -396
- package/src/specs/openai.simple.test.ts +0 -315
- package/src/specs/openrouter.simple.test.ts +0 -275
- package/src/specs/preemptSeal.test.ts +0 -678
- package/src/specs/prune.test.ts +0 -3741
- package/src/specs/reasoning.test.ts +0 -201
- package/src/specs/run-step-timestamps.test.ts +0 -414
- package/src/specs/spec.utils.ts +0 -15
- package/src/specs/subagent.test.ts +0 -864
- package/src/specs/summarization-unit.test.ts +0 -973
- package/src/specs/summarization.test.ts +0 -3823
- package/src/specs/summarize-prune.test.ts +0 -376
- package/src/specs/thinking-handoff.test.ts +0 -621
- package/src/specs/thinking-prune.test.ts +0 -827
- package/src/specs/token-accounting-e2e.test.ts +0 -1034
- package/src/specs/token-accounting-pipeline.test.ts +0 -1008
- package/src/specs/token-distribution-edge-case.test.ts +0 -315
- package/src/specs/token-memoization.test.ts +0 -40
- package/src/specs/tokens.test.ts +0 -1000
- package/src/specs/tool-error-resume.test.ts +0 -194
- package/src/specs/tool-error.test.ts +0 -198
- package/src/specs/vllm-reasoning-toolcalls.test.ts +0 -340
- package/src/stream.dispatch.test.ts +0 -63
- package/src/stream.test.ts +0 -144
- package/src/summarization/__tests__/aggregator.test.ts +0 -236
- package/src/summarization/__tests__/node.test.ts +0 -1996
- package/src/summarization/__tests__/trigger.test.ts +0 -149
- package/src/summarization/chunkHandler.test.ts +0 -196
- package/src/test/mockTools.ts +0 -386
- package/src/tools/Calculator.test.ts +0 -278
- package/src/tools/__tests__/BashExecutor.test.ts +0 -108
- package/src/tools/__tests__/CloudflareSandboxExecution.test.ts +0 -939
- package/src/tools/__tests__/CodeApiAuthHeaders.test.ts +0 -858
- package/src/tools/__tests__/CodeExecutor.stateful.test.ts +0 -124
- package/src/tools/__tests__/LocalExecutionRoots.test.ts +0 -8
- package/src/tools/__tests__/LocalExecutionTools.test.ts +0 -2733
- package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +0 -318
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +0 -1557
- package/src/tools/__tests__/ReadFile.test.ts +0 -44
- package/src/tools/__tests__/SkillTool.test.ts +0 -442
- package/src/tools/__tests__/SubagentExecutor.test.ts +0 -3728
- package/src/tools/__tests__/SubagentReplay.test.ts +0 -329
- package/src/tools/__tests__/SubagentTool.test.ts +0 -149
- package/src/tools/__tests__/ToolNode.breakerSignal.test.ts +0 -595
- package/src/tools/__tests__/ToolNode.eagerEventExecution.test.ts +0 -1191
- package/src/tools/__tests__/ToolNode.invalidToolCalls.test.ts +0 -757
- package/src/tools/__tests__/ToolNode.langfuse.test.ts +0 -57
- package/src/tools/__tests__/ToolNode.onResultCompletion.test.ts +0 -736
- package/src/tools/__tests__/ToolNode.outputReferences.test.ts +0 -1710
- package/src/tools/__tests__/ToolNode.runtimeState.test.ts +0 -120
- package/src/tools/__tests__/ToolNode.session.test.ts +0 -1352
- package/src/tools/__tests__/ToolNode.streamLimits.test.ts +0 -69
- package/src/tools/__tests__/ToolSearch.integration.test.ts +0 -161
- package/src/tools/__tests__/ToolSearch.test.ts +0 -1227
- package/src/tools/__tests__/annotateMessagesForLLM.test.ts +0 -561
- package/src/tools/__tests__/directToolHITLResumeScope.test.ts +0 -980
- package/src/tools/__tests__/directToolHooks.test.ts +0 -700
- package/src/tools/__tests__/eagerEventExecution.session.test.ts +0 -92
- package/src/tools/__tests__/handlers.test.ts +0 -997
- package/src/tools/__tests__/hitl.test.ts +0 -4663
- package/src/tools/__tests__/intentArg.test.ts +0 -357
- package/src/tools/__tests__/intentCoverage.test.ts +0 -139
- package/src/tools/__tests__/localToolNames.test.ts +0 -75
- package/src/tools/__tests__/skillCatalog.test.ts +0 -161
- package/src/tools/__tests__/subagentHooks.test.ts +0 -1651
- package/src/tools/__tests__/toolOutputReferences.test.ts +0 -515
- package/src/tools/__tests__/workspaceSeam.test.ts +0 -147
- package/src/tools/local/__tests__/FileCheckpointer.test.ts +0 -162
- package/src/tools/local/__tests__/editStrategies.test.ts +0 -134
- package/src/tools/search/content.test.ts +0 -173
- package/src/tools/search/crw.test.ts +0 -836
- package/src/tools/search/format.test.ts +0 -242
- package/src/tools/search/http-agent.test.ts +0 -133
- package/src/tools/search/jina-reranker.test.ts +0 -306
- package/src/tools/search/keenable-scraper.test.ts +0 -153
- package/src/tools/search/keenable.test.ts +0 -183
- package/src/tools/search/outcome.test.ts +0 -90
- package/src/tools/search/output.md +0 -2775
- package/src/tools/search/rag-api-reranker.test.ts +0 -891
- package/src/tools/search/source-processing.test.ts +0 -516
- package/src/tools/search/tavily.test.ts +0 -965
- package/src/tools/search/test.html +0 -884
- package/src/tools/search/test.md +0 -643
- package/src/tools/subagent/__tests__/SubagentExecutionRegistry.test.ts +0 -637
- package/src/tools/subagent/__tests__/SubagentExecutor.lazy.test.ts +0 -3054
- package/src/tools/subagent/__tests__/childGraphConfig.test.ts +0 -521
- package/src/utils/__tests__/apportion.test.ts +0 -32
- package/src/utils/__tests__/errors.test.ts +0 -270
- package/src/utils/__tests__/fixtures/contextOverflowSignatures.ts +0 -336
- package/src/utils/__tests__/redactSecrets.test.ts +0 -56
- package/src/utils/__tests__/truncation.test.ts +0 -66
- package/src/utils/llm.test.ts +0 -18
- package/src/utils/proxy.test.ts +0 -176
- package/src/utils/toolContent.test.ts +0 -1432
|
@@ -1,1858 +0,0 @@
|
|
|
1
|
-
import { context } from '@opentelemetry/api';
|
|
2
|
-
import { LangfuseOtelSpanAttributes } from '@langfuse/tracing';
|
|
3
|
-
import { AIMessage, ToolMessage, HumanMessage } from '@langchain/core/messages';
|
|
4
|
-
import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
5
|
-
import type { BaseMessage } from '@langchain/core/messages';
|
|
6
|
-
import type { Context } from '@opentelemetry/api';
|
|
7
|
-
import type { TPayload } from '@/types';
|
|
8
|
-
import {
|
|
9
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
10
|
-
classifyLangfuseToolNodeSpan,
|
|
11
|
-
prepareLangfuseSpanForExport,
|
|
12
|
-
redactLangfuseSpanToolOutputs,
|
|
13
|
-
shouldTraceToolNodeForLangfuse,
|
|
14
|
-
} from '@/langfuseToolOutputTracing';
|
|
15
|
-
import {
|
|
16
|
-
resolveLangfuseConfigForSpan,
|
|
17
|
-
resolveLangfuseRuntimeScope,
|
|
18
|
-
resolveToolOutputTracingConfigForSpan,
|
|
19
|
-
withLangfuseRuntimeScope,
|
|
20
|
-
} from '@/langfuseRuntimeScope';
|
|
21
|
-
import {
|
|
22
|
-
runWithLangfuseRuntimeContext,
|
|
23
|
-
type ResolvedLangfuseToolOutputTracingConfig,
|
|
24
|
-
} from '@/langfuseRuntimeContext';
|
|
25
|
-
import {
|
|
26
|
-
resolveLangfuseConfig,
|
|
27
|
-
resolveToolOutputTracingConfig,
|
|
28
|
-
} from '@/langfuseConfig';
|
|
29
|
-
import { ensureOpenTelemetryContextManager } from '@/instrumentation';
|
|
30
|
-
import { projectToolStreamContentForProvider } from '@/messages/core';
|
|
31
|
-
import { formatAgentMessages } from '@/messages/format';
|
|
32
|
-
import { ContentTypes } from '@/common';
|
|
33
|
-
|
|
34
|
-
type SerializedLangfuseChatMessage = {
|
|
35
|
-
content: BaseMessage['content'];
|
|
36
|
-
role?: string;
|
|
37
|
-
additional_kwargs?: BaseMessage['additional_kwargs'];
|
|
38
|
-
tool_calls?:
|
|
39
|
-
| NonNullable<AIMessage['tool_calls']>
|
|
40
|
-
| NonNullable<BaseMessage['additional_kwargs']['tool_calls']>;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type RedactedMessage = {
|
|
44
|
-
role?: string;
|
|
45
|
-
content?: string;
|
|
46
|
-
tool_calls?: Array<{
|
|
47
|
-
id?: string;
|
|
48
|
-
name?: string;
|
|
49
|
-
args?: {
|
|
50
|
-
query?: string;
|
|
51
|
-
};
|
|
52
|
-
}>;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
function createSpan(
|
|
56
|
-
name: string,
|
|
57
|
-
attributes: Record<string, unknown>
|
|
58
|
-
): ReadableSpan {
|
|
59
|
-
return { name, attributes } as unknown as ReadableSpan;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function createConfig(
|
|
63
|
-
overrides: Partial<ResolvedLangfuseToolOutputTracingConfig> = {}
|
|
64
|
-
): ResolvedLangfuseToolOutputTracingConfig {
|
|
65
|
-
return {
|
|
66
|
-
enabled: true,
|
|
67
|
-
redactedToolNames: new Set<string>(),
|
|
68
|
-
redactedToolNameMatchMode: 'exact',
|
|
69
|
-
redactionText: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
70
|
-
...overrides,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function serializeMessageForLangfuse(
|
|
75
|
-
message: BaseMessage
|
|
76
|
-
): SerializedLangfuseChatMessage {
|
|
77
|
-
if (message instanceof HumanMessage) {
|
|
78
|
-
return { content: message.content, role: 'user' };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (message instanceof AIMessage) {
|
|
82
|
-
const response: SerializedLangfuseChatMessage = {
|
|
83
|
-
content: message.content,
|
|
84
|
-
role: 'assistant',
|
|
85
|
-
};
|
|
86
|
-
if (message.tool_calls != null && message.tool_calls.length > 0) {
|
|
87
|
-
response.tool_calls = message.tool_calls;
|
|
88
|
-
}
|
|
89
|
-
if (message.additional_kwargs.tool_calls != null) {
|
|
90
|
-
response.tool_calls = message.additional_kwargs.tool_calls;
|
|
91
|
-
}
|
|
92
|
-
return response;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (message instanceof ToolMessage) {
|
|
96
|
-
return {
|
|
97
|
-
content: message.content,
|
|
98
|
-
additional_kwargs: message.additional_kwargs,
|
|
99
|
-
role: message.name,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return message.name != null
|
|
104
|
-
? { content: message.content, role: message.name }
|
|
105
|
-
: { content: message.content };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function readJsonAttribute<T>(span: ReadableSpan, key: string): T {
|
|
109
|
-
return JSON.parse(span.attributes[key] as string) as T;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
describe('Langfuse tool output tracing redaction', () => {
|
|
113
|
-
const originalEnv = process.env;
|
|
114
|
-
|
|
115
|
-
beforeEach(() => {
|
|
116
|
-
process.env = { ...originalEnv };
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
afterEach(() => {
|
|
120
|
-
process.env = originalEnv;
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('keeps internal ToolNode batch tracing opt-in', () => {
|
|
124
|
-
delete process.env.LANGFUSE_SECRET_KEY;
|
|
125
|
-
delete process.env.LANGFUSE_PUBLIC_KEY;
|
|
126
|
-
delete process.env.LANGFUSE_BASE_URL;
|
|
127
|
-
|
|
128
|
-
expect(shouldTraceToolNodeForLangfuse({})).toBe(false);
|
|
129
|
-
expect(
|
|
130
|
-
shouldTraceToolNodeForLangfuse({
|
|
131
|
-
runLangfuse: {
|
|
132
|
-
enabled: true,
|
|
133
|
-
publicKey: 'pk-run',
|
|
134
|
-
secretKey: 'sk-run',
|
|
135
|
-
},
|
|
136
|
-
})
|
|
137
|
-
).toBe(false);
|
|
138
|
-
expect(
|
|
139
|
-
shouldTraceToolNodeForLangfuse({
|
|
140
|
-
agentLangfuse: {
|
|
141
|
-
enabled: true,
|
|
142
|
-
publicKey: 'pk-agent',
|
|
143
|
-
secretKey: 'sk-agent',
|
|
144
|
-
baseUrl: 'https://langfuse.test',
|
|
145
|
-
toolNodeTracing: { enabled: true },
|
|
146
|
-
},
|
|
147
|
-
})
|
|
148
|
-
).toBe(true);
|
|
149
|
-
|
|
150
|
-
process.env.LANGFUSE_SECRET_KEY = 'sk-test';
|
|
151
|
-
process.env.LANGFUSE_PUBLIC_KEY = 'pk-test';
|
|
152
|
-
process.env.LANGFUSE_BASE_URL = 'https://langfuse.test';
|
|
153
|
-
|
|
154
|
-
expect(shouldTraceToolNodeForLangfuse({})).toBe(false);
|
|
155
|
-
expect(
|
|
156
|
-
shouldTraceToolNodeForLangfuse({
|
|
157
|
-
runLangfuse: { toolNodeTracing: { enabled: true } },
|
|
158
|
-
})
|
|
159
|
-
).toBe(true);
|
|
160
|
-
expect(
|
|
161
|
-
shouldTraceToolNodeForLangfuse({
|
|
162
|
-
runLangfuse: { toolNodeTracing: { enabled: false } },
|
|
163
|
-
})
|
|
164
|
-
).toBe(false);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('lets an agent explicitly opt into ToolNode batch tracing', () => {
|
|
168
|
-
delete process.env.LANGFUSE_SECRET_KEY;
|
|
169
|
-
delete process.env.LANGFUSE_PUBLIC_KEY;
|
|
170
|
-
delete process.env.LANGFUSE_BASE_URL;
|
|
171
|
-
|
|
172
|
-
expect(
|
|
173
|
-
shouldTraceToolNodeForLangfuse({
|
|
174
|
-
runLangfuse: {
|
|
175
|
-
enabled: false,
|
|
176
|
-
},
|
|
177
|
-
agentLangfuse: {
|
|
178
|
-
enabled: true,
|
|
179
|
-
publicKey: 'pk-agent',
|
|
180
|
-
secretKey: 'sk-agent',
|
|
181
|
-
baseUrl: 'https://langfuse.test',
|
|
182
|
-
toolNodeTracing: { enabled: true },
|
|
183
|
-
},
|
|
184
|
-
})
|
|
185
|
-
).toBe(true);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('keeps ToolNode tracing disabled when resolved Langfuse is disabled', () => {
|
|
189
|
-
process.env.LANGFUSE_SECRET_KEY = 'sk-test';
|
|
190
|
-
process.env.LANGFUSE_PUBLIC_KEY = 'pk-test';
|
|
191
|
-
|
|
192
|
-
expect(
|
|
193
|
-
shouldTraceToolNodeForLangfuse({
|
|
194
|
-
runLangfuse: {
|
|
195
|
-
enabled: false,
|
|
196
|
-
toolNodeTracing: { enabled: true },
|
|
197
|
-
},
|
|
198
|
-
})
|
|
199
|
-
).toBe(false);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('classifies LangGraph tool-node spans as Langfuse tool observations', () => {
|
|
203
|
-
const span = createSpan('tool_batch', {
|
|
204
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'span',
|
|
205
|
-
[`${LangfuseOtelSpanAttributes.OBSERVATION_METADATA}.langgraph_node`]:
|
|
206
|
-
'tools=agent_1',
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
redactLangfuseSpanToolOutputs(span, createConfig());
|
|
210
|
-
|
|
211
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]).toBe(
|
|
212
|
-
'tool'
|
|
213
|
-
);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('classifies LangGraph tool-node spans without requiring redaction config', () => {
|
|
217
|
-
const span = createSpan('tool_batch', {
|
|
218
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'span',
|
|
219
|
-
[`${LangfuseOtelSpanAttributes.OBSERVATION_METADATA}.langgraph_node`]:
|
|
220
|
-
'tools=agent_1',
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
classifyLangfuseToolNodeSpan(span);
|
|
224
|
-
|
|
225
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]).toBe(
|
|
226
|
-
'tool'
|
|
227
|
-
);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it('does not reclassify non-tool LangGraph spans', () => {
|
|
231
|
-
const span = createSpan('agent=agent_1', {
|
|
232
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'span',
|
|
233
|
-
[`${LangfuseOtelSpanAttributes.OBSERVATION_METADATA}.langgraph_node`]:
|
|
234
|
-
'agent=agent_1',
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
redactLangfuseSpanToolOutputs(span, createConfig());
|
|
238
|
-
|
|
239
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]).toBe(
|
|
240
|
-
'span'
|
|
241
|
-
);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('redacts raw tool observation output when tool output tracing is disabled', () => {
|
|
245
|
-
const span = createSpan('execute_sql', {
|
|
246
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'tool',
|
|
247
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: '{"query":"select 1"}',
|
|
248
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: 'secret rows',
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
redactLangfuseSpanToolOutputs(span, createConfig({ enabled: false }));
|
|
252
|
-
|
|
253
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]).toBe(
|
|
254
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
255
|
-
);
|
|
256
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]).toBe(
|
|
257
|
-
'{"query":"select 1"}'
|
|
258
|
-
);
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it('redacts ToolMessage content inside serialized generation inputs', () => {
|
|
262
|
-
const messages = [
|
|
263
|
-
{ role: 'user', content: 'show tables' },
|
|
264
|
-
{
|
|
265
|
-
role: 'execute_sql',
|
|
266
|
-
content: 'private query result',
|
|
267
|
-
additional_kwargs: {},
|
|
268
|
-
},
|
|
269
|
-
];
|
|
270
|
-
const span = createSpan('gpt-4o', {
|
|
271
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'generation',
|
|
272
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(messages),
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
redactLangfuseSpanToolOutputs(span, createConfig({ enabled: false }));
|
|
276
|
-
|
|
277
|
-
const redacted = JSON.parse(
|
|
278
|
-
span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_INPUT] as string
|
|
279
|
-
) as Array<{ role: string; content: string }>;
|
|
280
|
-
expect(redacted[0].content).toBe('show tables');
|
|
281
|
-
expect(redacted[1].content).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it('redacts captured Responses server-tool outputs wherever they are serialized', () => {
|
|
285
|
-
const outputs = [
|
|
286
|
-
{
|
|
287
|
-
id: 'local_output',
|
|
288
|
-
type: 'local_shell_call_output',
|
|
289
|
-
status: 'completed',
|
|
290
|
-
output: 'local shell secret',
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
id: 'shell_output',
|
|
294
|
-
call_id: 'shell_call',
|
|
295
|
-
type: 'shell_call_output',
|
|
296
|
-
status: 'completed',
|
|
297
|
-
output: 'shell secret',
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
id: 'patch_output',
|
|
301
|
-
call_id: 'patch_call',
|
|
302
|
-
type: 'apply_patch_call_output',
|
|
303
|
-
status: 'completed',
|
|
304
|
-
output: 'patch secret',
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
id: 'program_output',
|
|
308
|
-
call_id: 'program_call',
|
|
309
|
-
type: 'program_output',
|
|
310
|
-
status: 'completed',
|
|
311
|
-
result: 'program secret',
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
id: 'code_interpreter_call',
|
|
315
|
-
type: 'code_interpreter_call',
|
|
316
|
-
code: 'code input stays visible',
|
|
317
|
-
container_id: 'container_1',
|
|
318
|
-
status: 'completed',
|
|
319
|
-
outputs: [{ type: 'logs', logs: 'code interpreter secret' }],
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
id: 'mcp_call',
|
|
323
|
-
type: 'mcp_call',
|
|
324
|
-
name: 'private_mcp_tool',
|
|
325
|
-
arguments: '{"query":"mcp input stays visible"}',
|
|
326
|
-
server_label: 'mcp_server',
|
|
327
|
-
status: 'failed',
|
|
328
|
-
output: 'mcp output secret',
|
|
329
|
-
error: 'mcp error secret',
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
id: 'mcp_list',
|
|
333
|
-
type: 'mcp_list_tools',
|
|
334
|
-
server_label: 'mcp_server',
|
|
335
|
-
tools: [{ name: 'listed secret tool', input_schema: {} }],
|
|
336
|
-
error: 'mcp list error secret',
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
id: 'image_generation_call',
|
|
340
|
-
type: 'image_generation_call',
|
|
341
|
-
status: 'completed',
|
|
342
|
-
revised_prompt: 'image prompt stays visible',
|
|
343
|
-
result: 'image generation secret',
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
id: 'file_search_call',
|
|
347
|
-
type: 'file_search_call',
|
|
348
|
-
status: 'completed',
|
|
349
|
-
queries: ['file query stays visible'],
|
|
350
|
-
results: [{ text: 'file search secret' }],
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
id: 'web_search_call',
|
|
354
|
-
type: 'web_search_call',
|
|
355
|
-
status: 'completed',
|
|
356
|
-
action: {
|
|
357
|
-
type: 'search',
|
|
358
|
-
queries: ['web query stays visible'],
|
|
359
|
-
sources: [{ type: 'url', url: 'web source secret' }],
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
id: 'tool_search_output',
|
|
364
|
-
call_id: 'tool_search_call',
|
|
365
|
-
type: 'tool_search_output',
|
|
366
|
-
status: 'completed',
|
|
367
|
-
tools: [{ type: 'function', name: 'tool definition secret' }],
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
id: 'function_call',
|
|
371
|
-
call_id: 'function_call_id',
|
|
372
|
-
type: 'function_call',
|
|
373
|
-
name: 'private_function',
|
|
374
|
-
arguments: 'function input stays visible',
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
id: 'function_output',
|
|
378
|
-
call_id: 'function_call_id',
|
|
379
|
-
type: 'function_call_output',
|
|
380
|
-
output: 'function output secret',
|
|
381
|
-
},
|
|
382
|
-
{
|
|
383
|
-
id: 'custom_call',
|
|
384
|
-
call_id: 'custom_call_id',
|
|
385
|
-
type: 'custom_tool_call',
|
|
386
|
-
name: 'private_custom',
|
|
387
|
-
input: 'custom input stays visible',
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
id: 'custom_output',
|
|
391
|
-
call_id: 'custom_call_id',
|
|
392
|
-
type: 'custom_tool_call_output',
|
|
393
|
-
output: 'custom output secret',
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
id: 'computer_output',
|
|
397
|
-
call_id: 'computer_call_id',
|
|
398
|
-
type: 'computer_call_output',
|
|
399
|
-
acknowledged_safety_checks: ['computer input stays visible'],
|
|
400
|
-
output: 'computer output secret',
|
|
401
|
-
},
|
|
402
|
-
];
|
|
403
|
-
const serializedMessage = {
|
|
404
|
-
role: 'assistant',
|
|
405
|
-
content: outputs.map((value) => ({ type: 'non_standard', value })),
|
|
406
|
-
content_blocks: outputs.map((value) => ({
|
|
407
|
-
type: 'non_standard',
|
|
408
|
-
value,
|
|
409
|
-
})),
|
|
410
|
-
additional_kwargs: { tool_outputs: outputs },
|
|
411
|
-
};
|
|
412
|
-
const span = createSpan('gpt-5.6', {
|
|
413
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'generation',
|
|
414
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: JSON.stringify([
|
|
415
|
-
serializedMessage,
|
|
416
|
-
]),
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
redactLangfuseSpanToolOutputs(span, createConfig({ enabled: false }));
|
|
420
|
-
|
|
421
|
-
const redacted = span.attributes[
|
|
422
|
-
LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT
|
|
423
|
-
] as string;
|
|
424
|
-
for (const secret of [
|
|
425
|
-
'local shell secret',
|
|
426
|
-
'shell secret',
|
|
427
|
-
'patch secret',
|
|
428
|
-
'program secret',
|
|
429
|
-
'code interpreter secret',
|
|
430
|
-
'mcp output secret',
|
|
431
|
-
'mcp error secret',
|
|
432
|
-
'listed secret tool',
|
|
433
|
-
'mcp list error secret',
|
|
434
|
-
'image generation secret',
|
|
435
|
-
'file search secret',
|
|
436
|
-
'web source secret',
|
|
437
|
-
'tool definition secret',
|
|
438
|
-
'function output secret',
|
|
439
|
-
'custom output secret',
|
|
440
|
-
'computer output secret',
|
|
441
|
-
]) {
|
|
442
|
-
expect(redacted).not.toContain(secret);
|
|
443
|
-
}
|
|
444
|
-
expect(redacted).toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
445
|
-
for (const input of [
|
|
446
|
-
'local_output',
|
|
447
|
-
'shell_call',
|
|
448
|
-
'patch_call',
|
|
449
|
-
'program_call',
|
|
450
|
-
'code input stays visible',
|
|
451
|
-
'mcp input stays visible',
|
|
452
|
-
'private_mcp_tool',
|
|
453
|
-
'mcp_server',
|
|
454
|
-
'image prompt stays visible',
|
|
455
|
-
'file query stays visible',
|
|
456
|
-
'web query stays visible',
|
|
457
|
-
'tool_search_call',
|
|
458
|
-
'function input stays visible',
|
|
459
|
-
'custom input stays visible',
|
|
460
|
-
'computer input stays visible',
|
|
461
|
-
]) {
|
|
462
|
-
expect(redacted).toContain(input);
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
it('selectively redacts captured Responses outputs by canonical tool name', () => {
|
|
467
|
-
const outputs = [
|
|
468
|
-
{
|
|
469
|
-
type: 'local_shell_call_output',
|
|
470
|
-
output: 'public local output',
|
|
471
|
-
},
|
|
472
|
-
{ type: 'shell_call_output', output: 'private shell output' },
|
|
473
|
-
{ type: 'apply_patch_call_output', output: 'public patch output' },
|
|
474
|
-
{ type: 'program_output', result: 'private program output' },
|
|
475
|
-
{
|
|
476
|
-
type: 'code_interpreter_call',
|
|
477
|
-
code: 'public code input',
|
|
478
|
-
outputs: [{ type: 'logs', logs: 'private code output' }],
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
type: 'mcp_call',
|
|
482
|
-
name: 'private_mcp_tool',
|
|
483
|
-
arguments: 'public mcp input',
|
|
484
|
-
output: 'private named mcp output',
|
|
485
|
-
error: 'private named mcp error',
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
type: 'mcp_call',
|
|
489
|
-
name: 'public_mcp_tool',
|
|
490
|
-
output: 'public named mcp output',
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
type: 'mcp_call',
|
|
494
|
-
output: 'private fallback mcp output',
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
type: 'mcp_list_tools',
|
|
498
|
-
server_label: 'public server label',
|
|
499
|
-
tools: [{ name: 'private listed tool' }],
|
|
500
|
-
error: 'private list error',
|
|
501
|
-
},
|
|
502
|
-
{
|
|
503
|
-
type: 'image_generation_call',
|
|
504
|
-
revised_prompt: 'public image prompt',
|
|
505
|
-
result: 'private generated image',
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
type: 'file_search_call',
|
|
509
|
-
queries: ['public file query'],
|
|
510
|
-
results: [{ text: 'private file result' }],
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
type: 'web_search_call',
|
|
514
|
-
results: [{ title: 'private web result' }],
|
|
515
|
-
action: {
|
|
516
|
-
type: 'search',
|
|
517
|
-
queries: ['public web query'],
|
|
518
|
-
sources: [{ url: 'private web source' }],
|
|
519
|
-
},
|
|
520
|
-
},
|
|
521
|
-
{
|
|
522
|
-
type: 'tool_search_output',
|
|
523
|
-
call_id: 'public tool search call id',
|
|
524
|
-
tools: [{ name: 'private tool definition' }],
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
type: 'computer_call_output',
|
|
528
|
-
acknowledged_safety_checks: ['public computer input'],
|
|
529
|
-
output: 'private computer output',
|
|
530
|
-
},
|
|
531
|
-
];
|
|
532
|
-
const span = createSpan('gpt-5.6', {
|
|
533
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(outputs),
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
redactLangfuseSpanToolOutputs(
|
|
537
|
-
span,
|
|
538
|
-
createConfig({
|
|
539
|
-
redactedToolNames: new Set([
|
|
540
|
-
'shell',
|
|
541
|
-
'program',
|
|
542
|
-
'code_interpreter',
|
|
543
|
-
'private_mcp_tool',
|
|
544
|
-
'mcp',
|
|
545
|
-
'mcp_list_tools',
|
|
546
|
-
'image_generation',
|
|
547
|
-
'file_search',
|
|
548
|
-
'web_search',
|
|
549
|
-
'tool_search',
|
|
550
|
-
'computer_use',
|
|
551
|
-
]),
|
|
552
|
-
})
|
|
553
|
-
);
|
|
554
|
-
|
|
555
|
-
const redacted = readJsonAttribute<Array<Record<string, unknown>>>(
|
|
556
|
-
span,
|
|
557
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
558
|
-
);
|
|
559
|
-
expect(redacted[0].output).toBe('public local output');
|
|
560
|
-
expect(redacted[1].output).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
561
|
-
expect(redacted[2].output).toBe('public patch output');
|
|
562
|
-
expect(redacted[3].result).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
563
|
-
expect(redacted[4]).toMatchObject({
|
|
564
|
-
code: 'public code input',
|
|
565
|
-
outputs: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
566
|
-
});
|
|
567
|
-
expect(redacted[5]).toMatchObject({
|
|
568
|
-
name: 'private_mcp_tool',
|
|
569
|
-
arguments: 'public mcp input',
|
|
570
|
-
output: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
571
|
-
error: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
572
|
-
});
|
|
573
|
-
expect(redacted[6].output).toBe('public named mcp output');
|
|
574
|
-
expect(redacted[7].output).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
575
|
-
expect(redacted[8]).toMatchObject({
|
|
576
|
-
server_label: 'public server label',
|
|
577
|
-
tools: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
578
|
-
error: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
579
|
-
});
|
|
580
|
-
expect(redacted[9]).toMatchObject({
|
|
581
|
-
revised_prompt: 'public image prompt',
|
|
582
|
-
result: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
583
|
-
});
|
|
584
|
-
expect(redacted[10]).toMatchObject({
|
|
585
|
-
queries: ['public file query'],
|
|
586
|
-
results: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
587
|
-
});
|
|
588
|
-
expect(redacted[11]).toMatchObject({
|
|
589
|
-
results: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
590
|
-
action: {
|
|
591
|
-
type: 'search',
|
|
592
|
-
queries: ['public web query'],
|
|
593
|
-
sources: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
594
|
-
},
|
|
595
|
-
});
|
|
596
|
-
expect(redacted[12]).toMatchObject({
|
|
597
|
-
call_id: 'public tool search call id',
|
|
598
|
-
tools: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
599
|
-
});
|
|
600
|
-
expect(redacted[13]).toMatchObject({
|
|
601
|
-
acknowledged_safety_checks: ['public computer input'],
|
|
602
|
-
output: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
603
|
-
});
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
it('maps Responses function and custom outputs to their call names', () => {
|
|
607
|
-
const outputs = [
|
|
608
|
-
{
|
|
609
|
-
type: 'function_call',
|
|
610
|
-
call_id: 'private_function_call',
|
|
611
|
-
name: 'execute_sql',
|
|
612
|
-
arguments: 'private function input stays visible',
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
type: 'function_call_output',
|
|
616
|
-
call_id: 'private_function_call',
|
|
617
|
-
output: 'private function output',
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
type: 'function_call',
|
|
621
|
-
call_id: 'public_function_call',
|
|
622
|
-
name: 'public_function',
|
|
623
|
-
arguments: 'public function input',
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
type: 'function_call_output',
|
|
627
|
-
call_id: 'public_function_call',
|
|
628
|
-
output: 'public function output',
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
type: 'custom_tool_call',
|
|
632
|
-
call_id: 'private_custom_call',
|
|
633
|
-
name: 'private_custom_tool',
|
|
634
|
-
input: 'private custom input stays visible',
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
type: 'custom_tool_call_output',
|
|
638
|
-
call_id: 'private_custom_call',
|
|
639
|
-
output: 'private custom output',
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
type: 'custom_tool_call_output',
|
|
643
|
-
call_id: 'unmatched_custom_call',
|
|
644
|
-
output: 'unmatched custom output stays visible',
|
|
645
|
-
},
|
|
646
|
-
];
|
|
647
|
-
const span = createSpan('gpt-5.6', {
|
|
648
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(outputs),
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
redactLangfuseSpanToolOutputs(
|
|
652
|
-
span,
|
|
653
|
-
createConfig({
|
|
654
|
-
redactedToolNames: new Set(['execute_sql', 'private_custom_tool']),
|
|
655
|
-
})
|
|
656
|
-
);
|
|
657
|
-
|
|
658
|
-
const redacted = readJsonAttribute<Array<Record<string, unknown>>>(
|
|
659
|
-
span,
|
|
660
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
661
|
-
);
|
|
662
|
-
expect(redacted[0].arguments).toBe('private function input stays visible');
|
|
663
|
-
expect(redacted[1].output).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
664
|
-
expect(redacted[3].output).toBe('public function output');
|
|
665
|
-
expect(redacted[4].input).toBe('private custom input stays visible');
|
|
666
|
-
expect(redacted[5].output).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
667
|
-
expect(redacted[6].output).toBe('unmatched custom output stays visible');
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
it('redacts standard server-tool results globally and by paired call name', () => {
|
|
671
|
-
const blocks = [
|
|
672
|
-
{
|
|
673
|
-
type: 'server_tool_call',
|
|
674
|
-
id: 'private_server_call',
|
|
675
|
-
name: 'file_search',
|
|
676
|
-
args: { query: 'private server input stays visible' },
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
type: 'server_tool_call_result',
|
|
680
|
-
toolCallId: 'private_server_call',
|
|
681
|
-
status: 'success',
|
|
682
|
-
output: { results: ['private standard server result'] },
|
|
683
|
-
},
|
|
684
|
-
{
|
|
685
|
-
type: 'server_tool_call',
|
|
686
|
-
id: 'public_server_call',
|
|
687
|
-
name: 'web_search',
|
|
688
|
-
args: { query: 'public server input' },
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
type: 'server_tool_call_result',
|
|
692
|
-
toolCallId: 'public_server_call',
|
|
693
|
-
status: 'success',
|
|
694
|
-
output: 'public standard server result',
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
type: 'server_tool_call_result',
|
|
698
|
-
toolCallId: 'unknown_server_call',
|
|
699
|
-
status: 'success',
|
|
700
|
-
output: 'unmatched standard server result',
|
|
701
|
-
},
|
|
702
|
-
];
|
|
703
|
-
const selectiveSpan = createSpan('gpt-5.6', {
|
|
704
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(blocks),
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
redactLangfuseSpanToolOutputs(
|
|
708
|
-
selectiveSpan,
|
|
709
|
-
createConfig({ redactedToolNames: new Set(['file_search']) })
|
|
710
|
-
);
|
|
711
|
-
|
|
712
|
-
const selectivelyRedacted = readJsonAttribute<
|
|
713
|
-
Array<Record<string, unknown>>
|
|
714
|
-
>(selectiveSpan, LangfuseOtelSpanAttributes.OBSERVATION_INPUT);
|
|
715
|
-
expect(selectivelyRedacted[0]).toMatchObject({
|
|
716
|
-
args: { query: 'private server input stays visible' },
|
|
717
|
-
});
|
|
718
|
-
expect(selectivelyRedacted[1].output).toBe(
|
|
719
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
720
|
-
);
|
|
721
|
-
expect(selectivelyRedacted[3].output).toBe('public standard server result');
|
|
722
|
-
expect(selectivelyRedacted[4].output).toBe(
|
|
723
|
-
'unmatched standard server result'
|
|
724
|
-
);
|
|
725
|
-
|
|
726
|
-
const globalSpan = createSpan('gpt-5.6', {
|
|
727
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(blocks),
|
|
728
|
-
});
|
|
729
|
-
redactLangfuseSpanToolOutputs(globalSpan, createConfig({ enabled: false }));
|
|
730
|
-
const globallyRedacted = readJsonAttribute<Array<Record<string, unknown>>>(
|
|
731
|
-
globalSpan,
|
|
732
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
733
|
-
);
|
|
734
|
-
expect(globallyRedacted[1].output).toBe(
|
|
735
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
736
|
-
);
|
|
737
|
-
expect(globallyRedacted[3].output).toBe(
|
|
738
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
739
|
-
);
|
|
740
|
-
expect(globallyRedacted[4].output).toBe(
|
|
741
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
742
|
-
);
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
it('redacts marked projected server-tool images without touching user images', () => {
|
|
746
|
-
const message = new AIMessage({
|
|
747
|
-
content: [{ type: 'text', text: 'Partial answer stays visible.' }],
|
|
748
|
-
additional_kwargs: {
|
|
749
|
-
tool_outputs: [
|
|
750
|
-
{
|
|
751
|
-
id: 'code_image_call',
|
|
752
|
-
type: 'code_interpreter_call',
|
|
753
|
-
code: 'public image-producing code',
|
|
754
|
-
status: 'completed',
|
|
755
|
-
outputs: [
|
|
756
|
-
{
|
|
757
|
-
type: 'image',
|
|
758
|
-
url: 'data:image/png;base64,private-code-image-data',
|
|
759
|
-
},
|
|
760
|
-
],
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
id: 'generated_image_call',
|
|
764
|
-
type: 'image_generation_call',
|
|
765
|
-
status: 'completed',
|
|
766
|
-
result: 'private-generated-image-data',
|
|
767
|
-
},
|
|
768
|
-
],
|
|
769
|
-
},
|
|
770
|
-
response_metadata: {
|
|
771
|
-
model_provider: 'openai',
|
|
772
|
-
preempted: true,
|
|
773
|
-
},
|
|
774
|
-
});
|
|
775
|
-
const [projected] = projectToolStreamContentForProvider(
|
|
776
|
-
[message],
|
|
777
|
-
'native'
|
|
778
|
-
);
|
|
779
|
-
const projectedJson = projected.toJSON();
|
|
780
|
-
const serializedProjection = JSON.stringify(projectedJson);
|
|
781
|
-
expect(serializedProjection).toContain('private-code-image-data');
|
|
782
|
-
expect(serializedProjection).toContain('private-generated-image-data');
|
|
783
|
-
expect(serializedProjection).toContain('librechatServerToolResult');
|
|
784
|
-
|
|
785
|
-
const userImage = {
|
|
786
|
-
type: 'image',
|
|
787
|
-
mimeType: 'image/png',
|
|
788
|
-
data: 'public-user-image-data',
|
|
789
|
-
};
|
|
790
|
-
const span = createSpan('gpt-5.6', {
|
|
791
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify([
|
|
792
|
-
projectedJson,
|
|
793
|
-
userImage,
|
|
794
|
-
]),
|
|
795
|
-
});
|
|
796
|
-
redactLangfuseSpanToolOutputs(
|
|
797
|
-
span,
|
|
798
|
-
createConfig({
|
|
799
|
-
redactedToolNames: new Set(['code_interpreter', 'image_generation']),
|
|
800
|
-
})
|
|
801
|
-
);
|
|
802
|
-
|
|
803
|
-
const redacted = span.attributes[
|
|
804
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
805
|
-
] as string;
|
|
806
|
-
expect(redacted).toContain('Partial answer stays visible.');
|
|
807
|
-
expect(redacted).toContain('public-user-image-data');
|
|
808
|
-
expect(redacted).not.toContain('private-code-image-data');
|
|
809
|
-
expect(redacted).not.toContain('private-generated-image-data');
|
|
810
|
-
expect(redacted).toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
811
|
-
});
|
|
812
|
-
|
|
813
|
-
it.each([
|
|
814
|
-
['globally', createConfig({ enabled: false })],
|
|
815
|
-
[
|
|
816
|
-
'selectively',
|
|
817
|
-
createConfig({ redactedToolNames: new Set(['image_generation']) }),
|
|
818
|
-
],
|
|
819
|
-
] as const)(
|
|
820
|
-
'redacts serialized normalized generated images %s without touching user images',
|
|
821
|
-
(_scope, config) => {
|
|
822
|
-
const generatedById = {
|
|
823
|
-
id: 'ig_normal_response',
|
|
824
|
-
type: 'image_generation_call',
|
|
825
|
-
status: 'completed',
|
|
826
|
-
result: 'private-generated-image-by-id',
|
|
827
|
-
};
|
|
828
|
-
const generatedSecond = {
|
|
829
|
-
id: 'ig_normal_response_second',
|
|
830
|
-
type: 'image_generation_call',
|
|
831
|
-
status: 'completed',
|
|
832
|
-
result: 'private-generated-image-by-data',
|
|
833
|
-
};
|
|
834
|
-
const message = new AIMessage({
|
|
835
|
-
content: [
|
|
836
|
-
{
|
|
837
|
-
type: 'image',
|
|
838
|
-
mimeType: 'image/png',
|
|
839
|
-
data: generatedById.result,
|
|
840
|
-
id: generatedById.id,
|
|
841
|
-
metadata: { status: generatedById.status },
|
|
842
|
-
},
|
|
843
|
-
{
|
|
844
|
-
type: 'image',
|
|
845
|
-
mimeType: 'image/png',
|
|
846
|
-
data: generatedSecond.result,
|
|
847
|
-
id: generatedSecond.id,
|
|
848
|
-
metadata: { status: generatedSecond.status },
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
type: 'image',
|
|
852
|
-
mimeType: 'image/png',
|
|
853
|
-
id: generatedById.id,
|
|
854
|
-
url: 'private-generated-image-url',
|
|
855
|
-
fileId: 'private-generated-image-file-id',
|
|
856
|
-
metadata: { status: generatedById.status },
|
|
857
|
-
},
|
|
858
|
-
{
|
|
859
|
-
type: 'image',
|
|
860
|
-
mimeType: 'image/png',
|
|
861
|
-
data: 'public-assistant-application-image',
|
|
862
|
-
id: 'application-image',
|
|
863
|
-
metadata: { status: 'completed' },
|
|
864
|
-
},
|
|
865
|
-
],
|
|
866
|
-
additional_kwargs: {
|
|
867
|
-
tool_outputs: [generatedById, generatedSecond],
|
|
868
|
-
},
|
|
869
|
-
response_metadata: {
|
|
870
|
-
model_provider: 'openai',
|
|
871
|
-
output: [generatedById, generatedSecond],
|
|
872
|
-
},
|
|
873
|
-
});
|
|
874
|
-
const serializedMessage = serializeMessageForLangfuse(message);
|
|
875
|
-
const serializedUserMessage = serializeMessageForLangfuse(
|
|
876
|
-
new HumanMessage({
|
|
877
|
-
content: [
|
|
878
|
-
{
|
|
879
|
-
type: 'image',
|
|
880
|
-
mimeType: 'image/png',
|
|
881
|
-
data: 'public-user-image-data',
|
|
882
|
-
},
|
|
883
|
-
],
|
|
884
|
-
})
|
|
885
|
-
);
|
|
886
|
-
expect(JSON.stringify(serializedMessage)).not.toContain(
|
|
887
|
-
'image_generation_call'
|
|
888
|
-
);
|
|
889
|
-
const span = createSpan('gpt-5.6', {
|
|
890
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: JSON.stringify([
|
|
891
|
-
serializedMessage,
|
|
892
|
-
serializedUserMessage,
|
|
893
|
-
]),
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
redactLangfuseSpanToolOutputs(span, config);
|
|
897
|
-
|
|
898
|
-
const redacted = span.attributes[
|
|
899
|
-
LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT
|
|
900
|
-
] as string;
|
|
901
|
-
expect(redacted).not.toContain(generatedById.result);
|
|
902
|
-
expect(redacted).not.toContain(generatedSecond.result);
|
|
903
|
-
expect(redacted).not.toContain('private-generated-image-url');
|
|
904
|
-
expect(redacted).not.toContain('private-generated-image-file-id');
|
|
905
|
-
expect(redacted).toContain('public-assistant-application-image');
|
|
906
|
-
expect(redacted).toContain('public-user-image-data');
|
|
907
|
-
expect(redacted).toContain(generatedById.id);
|
|
908
|
-
expect(redacted).toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
909
|
-
}
|
|
910
|
-
);
|
|
911
|
-
|
|
912
|
-
it('does not reclassify a marked code-interpreter image as image generation', () => {
|
|
913
|
-
const codeImage = 'data:image/png;base64,public-code-image';
|
|
914
|
-
const span = createSpan('gpt-5.6', {
|
|
915
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: JSON.stringify([
|
|
916
|
-
{
|
|
917
|
-
role: 'assistant',
|
|
918
|
-
content: [
|
|
919
|
-
{
|
|
920
|
-
type: 'image',
|
|
921
|
-
url: codeImage,
|
|
922
|
-
extras: {
|
|
923
|
-
librechatServerToolResult: {
|
|
924
|
-
toolName: 'code_interpreter',
|
|
925
|
-
},
|
|
926
|
-
},
|
|
927
|
-
},
|
|
928
|
-
],
|
|
929
|
-
},
|
|
930
|
-
]),
|
|
931
|
-
});
|
|
932
|
-
|
|
933
|
-
redactLangfuseSpanToolOutputs(
|
|
934
|
-
span,
|
|
935
|
-
createConfig({
|
|
936
|
-
redactedToolNames: new Set(['image_generation']),
|
|
937
|
-
})
|
|
938
|
-
);
|
|
939
|
-
|
|
940
|
-
expect(
|
|
941
|
-
span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]
|
|
942
|
-
).toContain(codeImage);
|
|
943
|
-
expect(
|
|
944
|
-
span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]
|
|
945
|
-
).not.toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
946
|
-
});
|
|
947
|
-
|
|
948
|
-
it('fails closed when OpenTelemetry truncates a JSON-shaped attribute', () => {
|
|
949
|
-
const secret = 'private truncated tool output';
|
|
950
|
-
const serialized = JSON.stringify([
|
|
951
|
-
{
|
|
952
|
-
role: 'assistant',
|
|
953
|
-
content: [
|
|
954
|
-
{
|
|
955
|
-
type: 'text',
|
|
956
|
-
text: JSON.stringify({
|
|
957
|
-
serverToolResult: {
|
|
958
|
-
toolName: 'shell',
|
|
959
|
-
status: 'success',
|
|
960
|
-
output: secret,
|
|
961
|
-
},
|
|
962
|
-
}),
|
|
963
|
-
},
|
|
964
|
-
],
|
|
965
|
-
},
|
|
966
|
-
]);
|
|
967
|
-
const span = createSpan('gpt-5.6', {
|
|
968
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: serialized.slice(0, -1),
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
redactLangfuseSpanToolOutputs(
|
|
972
|
-
span,
|
|
973
|
-
createConfig({ redactedToolNames: new Set(['shell']) })
|
|
974
|
-
);
|
|
975
|
-
|
|
976
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]).toBe(
|
|
977
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
978
|
-
);
|
|
979
|
-
expect(JSON.stringify(span.attributes)).not.toContain(secret);
|
|
980
|
-
});
|
|
981
|
-
|
|
982
|
-
it('redacts marked bounded replay text without parsing its payload', () => {
|
|
983
|
-
const truncatedSecret =
|
|
984
|
-
'{"serverToolResult":{"librechatResponsesReplay":true,"status":"success","output":"secret head…secret tail"';
|
|
985
|
-
const span = createSpan('gpt-5.6', {
|
|
986
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify([
|
|
987
|
-
{
|
|
988
|
-
role: 'assistant',
|
|
989
|
-
content: [
|
|
990
|
-
{
|
|
991
|
-
type: 'text',
|
|
992
|
-
text: truncatedSecret,
|
|
993
|
-
},
|
|
994
|
-
],
|
|
995
|
-
},
|
|
996
|
-
]),
|
|
997
|
-
});
|
|
998
|
-
|
|
999
|
-
redactLangfuseSpanToolOutputs(span, createConfig({ enabled: false }));
|
|
1000
|
-
|
|
1001
|
-
const redacted = span.attributes[
|
|
1002
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
1003
|
-
] as string;
|
|
1004
|
-
expect(redacted).not.toContain('secret head');
|
|
1005
|
-
expect(redacted).not.toContain('secret tail');
|
|
1006
|
-
expect(redacted).toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1007
|
-
});
|
|
1008
|
-
|
|
1009
|
-
it('redacts replay output before root-span answer shaping', () => {
|
|
1010
|
-
const rootSecret = 'private root replay result';
|
|
1011
|
-
const span = createSpan('LangGraph', {
|
|
1012
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify([
|
|
1013
|
-
{ role: 'user', content: 'Continue.' },
|
|
1014
|
-
]),
|
|
1015
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: JSON.stringify([
|
|
1016
|
-
{
|
|
1017
|
-
role: 'assistant',
|
|
1018
|
-
content: [
|
|
1019
|
-
{ type: 'text', text: 'Partial answer. ' },
|
|
1020
|
-
{
|
|
1021
|
-
type: 'text',
|
|
1022
|
-
text: JSON.stringify({
|
|
1023
|
-
serverToolResult: {
|
|
1024
|
-
toolName: 'shell',
|
|
1025
|
-
status: 'success',
|
|
1026
|
-
output: rootSecret,
|
|
1027
|
-
},
|
|
1028
|
-
}),
|
|
1029
|
-
extras: {
|
|
1030
|
-
librechatServerToolResult: { toolName: 'shell' },
|
|
1031
|
-
},
|
|
1032
|
-
},
|
|
1033
|
-
],
|
|
1034
|
-
},
|
|
1035
|
-
]),
|
|
1036
|
-
});
|
|
1037
|
-
|
|
1038
|
-
prepareLangfuseSpanForExport(span, createConfig({ enabled: false }));
|
|
1039
|
-
|
|
1040
|
-
for (const key of [
|
|
1041
|
-
LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT,
|
|
1042
|
-
LangfuseOtelSpanAttributes.TRACE_OUTPUT,
|
|
1043
|
-
]) {
|
|
1044
|
-
const output = span.attributes[key] as string;
|
|
1045
|
-
expect(output).toContain('Partial answer.');
|
|
1046
|
-
expect(output).toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1047
|
-
expect(output).not.toContain(rootSecret);
|
|
1048
|
-
}
|
|
1049
|
-
});
|
|
1050
|
-
|
|
1051
|
-
it('redacts a root tool output before deriving trace output', () => {
|
|
1052
|
-
const rootSecret = 'private root tool result';
|
|
1053
|
-
const span = createSpan('shell', {
|
|
1054
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'tool',
|
|
1055
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: rootSecret,
|
|
1056
|
-
});
|
|
1057
|
-
|
|
1058
|
-
prepareLangfuseSpanForExport(span, createConfig({ enabled: false }));
|
|
1059
|
-
|
|
1060
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]).toBe(
|
|
1061
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
1062
|
-
);
|
|
1063
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.TRACE_OUTPUT]).toBe(
|
|
1064
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
1065
|
-
);
|
|
1066
|
-
expect(JSON.stringify(span.attributes)).not.toContain(rootSecret);
|
|
1067
|
-
});
|
|
1068
|
-
|
|
1069
|
-
it('preserves ordinary text that only resembles a server-tool result', () => {
|
|
1070
|
-
const ordinaryText =
|
|
1071
|
-
'{"serverToolResult":{"status":"success","output":"public literal text"}}';
|
|
1072
|
-
const span = createSpan('gpt-5.6', {
|
|
1073
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify([
|
|
1074
|
-
{
|
|
1075
|
-
role: 'assistant',
|
|
1076
|
-
content: [{ type: 'text', text: ordinaryText }],
|
|
1077
|
-
},
|
|
1078
|
-
]),
|
|
1079
|
-
});
|
|
1080
|
-
|
|
1081
|
-
redactLangfuseSpanToolOutputs(span, createConfig({ enabled: false }));
|
|
1082
|
-
|
|
1083
|
-
expect(
|
|
1084
|
-
span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]
|
|
1085
|
-
).toContain('public literal text');
|
|
1086
|
-
expect(
|
|
1087
|
-
span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]
|
|
1088
|
-
).not.toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1089
|
-
});
|
|
1090
|
-
|
|
1091
|
-
it('recognizes serialized fallback results only inside assistant messages', () => {
|
|
1092
|
-
const userLiteral =
|
|
1093
|
-
'{"serverToolResult":{"status":"success","output":"public user literal"}}';
|
|
1094
|
-
const assistantResult =
|
|
1095
|
-
'{"serverToolResult":{"librechatResponsesReplay":true,"status":"success","output":"private replay result"}}';
|
|
1096
|
-
const span = createSpan('gpt-5.6', {
|
|
1097
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify([
|
|
1098
|
-
{
|
|
1099
|
-
role: 'user',
|
|
1100
|
-
content: [{ type: 'text', text: userLiteral }],
|
|
1101
|
-
},
|
|
1102
|
-
{
|
|
1103
|
-
role: 'assistant',
|
|
1104
|
-
content: [{ type: 'text', text: assistantResult }],
|
|
1105
|
-
},
|
|
1106
|
-
]),
|
|
1107
|
-
});
|
|
1108
|
-
|
|
1109
|
-
redactLangfuseSpanToolOutputs(span, createConfig({ enabled: false }));
|
|
1110
|
-
|
|
1111
|
-
const redacted = span.attributes[
|
|
1112
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
1113
|
-
] as string;
|
|
1114
|
-
expect(redacted).toContain('public user literal');
|
|
1115
|
-
expect(redacted).not.toContain('private replay result');
|
|
1116
|
-
expect(redacted).toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1117
|
-
});
|
|
1118
|
-
|
|
1119
|
-
it('redacts neutralized replay results from resumed generation input', () => {
|
|
1120
|
-
const message = new AIMessage({
|
|
1121
|
-
content: [{ type: 'text', text: 'Partial answer.' }],
|
|
1122
|
-
additional_kwargs: {
|
|
1123
|
-
tool_outputs: [
|
|
1124
|
-
{
|
|
1125
|
-
id: 'shell_output_item',
|
|
1126
|
-
call_id: 'shell_call',
|
|
1127
|
-
type: 'shell_call_output',
|
|
1128
|
-
status: 'completed',
|
|
1129
|
-
output: 'resumed generation secret',
|
|
1130
|
-
},
|
|
1131
|
-
],
|
|
1132
|
-
},
|
|
1133
|
-
response_metadata: {
|
|
1134
|
-
model_provider: 'openai',
|
|
1135
|
-
preempted: true,
|
|
1136
|
-
},
|
|
1137
|
-
});
|
|
1138
|
-
const [projected] = projectToolStreamContentForProvider(
|
|
1139
|
-
[message],
|
|
1140
|
-
'fallback'
|
|
1141
|
-
);
|
|
1142
|
-
expect(projected.content).toEqual([
|
|
1143
|
-
{ type: 'text', text: 'Partial answer.' },
|
|
1144
|
-
expect.objectContaining({
|
|
1145
|
-
type: 'text',
|
|
1146
|
-
text: expect.stringContaining('resumed generation secret'),
|
|
1147
|
-
}),
|
|
1148
|
-
]);
|
|
1149
|
-
expect(JSON.stringify(projected.content)).not.toContain('extras');
|
|
1150
|
-
const span = createSpan('gpt-5.6', {
|
|
1151
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify([
|
|
1152
|
-
projected.toJSON(),
|
|
1153
|
-
]),
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
redactLangfuseSpanToolOutputs(
|
|
1157
|
-
span,
|
|
1158
|
-
createConfig({ redactedToolNames: new Set(['shell']) })
|
|
1159
|
-
);
|
|
1160
|
-
|
|
1161
|
-
const redacted = span.attributes[
|
|
1162
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
1163
|
-
] as string;
|
|
1164
|
-
expect(redacted).toContain('Partial answer.');
|
|
1165
|
-
expect(redacted).not.toContain('resumed generation secret');
|
|
1166
|
-
expect(redacted).toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1167
|
-
});
|
|
1168
|
-
|
|
1169
|
-
it('redacts only configured tool names when output tracing stays enabled', () => {
|
|
1170
|
-
const messages = [
|
|
1171
|
-
{ role: 'execute_sql', content: 'private query result' },
|
|
1172
|
-
{ role: 'bash', content: 'public build log' },
|
|
1173
|
-
];
|
|
1174
|
-
const span = createSpan('LangGraph', {
|
|
1175
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: JSON.stringify({
|
|
1176
|
-
messages,
|
|
1177
|
-
}),
|
|
1178
|
-
});
|
|
1179
|
-
|
|
1180
|
-
redactLangfuseSpanToolOutputs(
|
|
1181
|
-
span,
|
|
1182
|
-
createConfig({
|
|
1183
|
-
redactedToolNames: new Set(['execute_sql']),
|
|
1184
|
-
})
|
|
1185
|
-
);
|
|
1186
|
-
|
|
1187
|
-
const redacted = JSON.parse(
|
|
1188
|
-
span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT] as string
|
|
1189
|
-
) as { messages: Array<{ role: string; content: string }> };
|
|
1190
|
-
expect(redacted.messages[0].content).toBe(
|
|
1191
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
1192
|
-
);
|
|
1193
|
-
expect(redacted.messages[1].content).toBe('public build log');
|
|
1194
|
-
});
|
|
1195
|
-
|
|
1196
|
-
it('uses nested ToolMessage names instead of generic tool role', () => {
|
|
1197
|
-
const messages = [
|
|
1198
|
-
{
|
|
1199
|
-
role: 'tool',
|
|
1200
|
-
content: 'private query result',
|
|
1201
|
-
kwargs: {
|
|
1202
|
-
name: 'execute_sql',
|
|
1203
|
-
tool_call_id: 'call_1',
|
|
1204
|
-
},
|
|
1205
|
-
},
|
|
1206
|
-
];
|
|
1207
|
-
const span = createSpan('gpt-4o', {
|
|
1208
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'generation',
|
|
1209
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(messages),
|
|
1210
|
-
});
|
|
1211
|
-
|
|
1212
|
-
redactLangfuseSpanToolOutputs(
|
|
1213
|
-
span,
|
|
1214
|
-
createConfig({
|
|
1215
|
-
redactedToolNames: new Set(['execute_sql']),
|
|
1216
|
-
})
|
|
1217
|
-
);
|
|
1218
|
-
|
|
1219
|
-
const redacted = readJsonAttribute<Array<{ content: string }>>(
|
|
1220
|
-
span,
|
|
1221
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
1222
|
-
);
|
|
1223
|
-
expect(redacted[0].content).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1224
|
-
});
|
|
1225
|
-
|
|
1226
|
-
it('maps tool_call_id to the preceding tool call name for allowlisted redaction', () => {
|
|
1227
|
-
const messages = [
|
|
1228
|
-
{
|
|
1229
|
-
role: 'assistant',
|
|
1230
|
-
content: '',
|
|
1231
|
-
tool_calls: [
|
|
1232
|
-
{
|
|
1233
|
-
id: 'call_sql',
|
|
1234
|
-
name: 'execute_sql',
|
|
1235
|
-
args: { query: 'select * from private_table' },
|
|
1236
|
-
},
|
|
1237
|
-
],
|
|
1238
|
-
},
|
|
1239
|
-
{
|
|
1240
|
-
role: 'tool',
|
|
1241
|
-
tool_call_id: 'call_sql',
|
|
1242
|
-
content: 'sensitive row output',
|
|
1243
|
-
},
|
|
1244
|
-
{
|
|
1245
|
-
role: 'tool',
|
|
1246
|
-
tool_call_id: 'call_bash',
|
|
1247
|
-
content: 'public build log',
|
|
1248
|
-
},
|
|
1249
|
-
];
|
|
1250
|
-
const span = createSpan('gpt-4o', {
|
|
1251
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'generation',
|
|
1252
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(messages),
|
|
1253
|
-
});
|
|
1254
|
-
|
|
1255
|
-
redactLangfuseSpanToolOutputs(
|
|
1256
|
-
span,
|
|
1257
|
-
createConfig({
|
|
1258
|
-
redactedToolNames: new Set(['execute_sql']),
|
|
1259
|
-
})
|
|
1260
|
-
);
|
|
1261
|
-
|
|
1262
|
-
const redacted = readJsonAttribute<RedactedMessage[]>(
|
|
1263
|
-
span,
|
|
1264
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
1265
|
-
);
|
|
1266
|
-
expect(redacted[0].tool_calls?.[0]?.args?.query).toBe(
|
|
1267
|
-
'select * from private_table'
|
|
1268
|
-
);
|
|
1269
|
-
expect(redacted[1].content).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1270
|
-
expect(redacted[2].content).toBe('public build log');
|
|
1271
|
-
});
|
|
1272
|
-
|
|
1273
|
-
it('does not redact partial tool name matches by default', () => {
|
|
1274
|
-
const span = createSpan('clickhouse_execute_sql_prod', {
|
|
1275
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'tool',
|
|
1276
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: 'secret rows',
|
|
1277
|
-
});
|
|
1278
|
-
|
|
1279
|
-
redactLangfuseSpanToolOutputs(
|
|
1280
|
-
span,
|
|
1281
|
-
createConfig({
|
|
1282
|
-
redactedToolNames: new Set(['execute_sql']),
|
|
1283
|
-
})
|
|
1284
|
-
);
|
|
1285
|
-
|
|
1286
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]).toBe(
|
|
1287
|
-
'secret rows'
|
|
1288
|
-
);
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
it('redacts configured partial tool name matches when enabled', () => {
|
|
1292
|
-
const span = createSpan('clickhouse_execute_sql_prod', {
|
|
1293
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'tool',
|
|
1294
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: 'secret rows',
|
|
1295
|
-
});
|
|
1296
|
-
|
|
1297
|
-
redactLangfuseSpanToolOutputs(
|
|
1298
|
-
span,
|
|
1299
|
-
createConfig({
|
|
1300
|
-
redactedToolNames: new Set(['execute_sql']),
|
|
1301
|
-
redactedToolNameMatchMode: 'partial',
|
|
1302
|
-
})
|
|
1303
|
-
);
|
|
1304
|
-
|
|
1305
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]).toBe(
|
|
1306
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
1307
|
-
);
|
|
1308
|
-
});
|
|
1309
|
-
|
|
1310
|
-
it('redacts prior tool outputs from multi-turn generation inputs', () => {
|
|
1311
|
-
const messages = [
|
|
1312
|
-
{ role: 'user', content: 'run the query' },
|
|
1313
|
-
{
|
|
1314
|
-
role: 'assistant',
|
|
1315
|
-
content: '',
|
|
1316
|
-
tool_calls: [
|
|
1317
|
-
{
|
|
1318
|
-
id: 'call_sql',
|
|
1319
|
-
name: 'execute_sql',
|
|
1320
|
-
args: { query: 'select * from private_table' },
|
|
1321
|
-
},
|
|
1322
|
-
],
|
|
1323
|
-
},
|
|
1324
|
-
{
|
|
1325
|
-
role: 'execute_sql',
|
|
1326
|
-
content: 'sensitive row output',
|
|
1327
|
-
additional_kwargs: {},
|
|
1328
|
-
},
|
|
1329
|
-
{ role: 'assistant', content: 'I found the answer.' },
|
|
1330
|
-
{ role: 'user', content: 'explain the first row' },
|
|
1331
|
-
];
|
|
1332
|
-
const span = createSpan('gpt-4o', {
|
|
1333
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'generation',
|
|
1334
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(messages),
|
|
1335
|
-
});
|
|
1336
|
-
|
|
1337
|
-
redactLangfuseSpanToolOutputs(span, createConfig({ enabled: false }));
|
|
1338
|
-
|
|
1339
|
-
const redacted = readJsonAttribute<RedactedMessage[]>(
|
|
1340
|
-
span,
|
|
1341
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
1342
|
-
);
|
|
1343
|
-
expect(redacted[0].content).toBe('run the query');
|
|
1344
|
-
expect(redacted[1].tool_calls?.[0]?.args?.query).toBe(
|
|
1345
|
-
'select * from private_table'
|
|
1346
|
-
);
|
|
1347
|
-
expect(redacted[2].content).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1348
|
-
expect(redacted[3].content).toBe('I found the answer.');
|
|
1349
|
-
expect(redacted[4].content).toBe('explain the first row');
|
|
1350
|
-
});
|
|
1351
|
-
|
|
1352
|
-
it('redacts tool outputs after formatAgentMessages rehydrates content parts', () => {
|
|
1353
|
-
const payload: TPayload = [
|
|
1354
|
-
{ role: 'user', content: 'show me the private numbers' },
|
|
1355
|
-
{
|
|
1356
|
-
role: 'assistant',
|
|
1357
|
-
content: [
|
|
1358
|
-
{
|
|
1359
|
-
type: ContentTypes.TEXT,
|
|
1360
|
-
[ContentTypes.TEXT]: 'I will query ClickHouse.',
|
|
1361
|
-
tool_call_ids: ['call_sql'],
|
|
1362
|
-
},
|
|
1363
|
-
{
|
|
1364
|
-
type: ContentTypes.TOOL_CALL,
|
|
1365
|
-
tool_call: {
|
|
1366
|
-
id: 'call_sql',
|
|
1367
|
-
name: 'execute_sql',
|
|
1368
|
-
args: '{"query":"select secret_value from prod"}',
|
|
1369
|
-
output: 'secret_value: 12345',
|
|
1370
|
-
},
|
|
1371
|
-
},
|
|
1372
|
-
],
|
|
1373
|
-
},
|
|
1374
|
-
{ role: 'user', content: 'can you summarize it?' },
|
|
1375
|
-
];
|
|
1376
|
-
const { messages } = formatAgentMessages(
|
|
1377
|
-
payload,
|
|
1378
|
-
undefined,
|
|
1379
|
-
new Set(['execute_sql'])
|
|
1380
|
-
);
|
|
1381
|
-
const serialized = messages.map(serializeMessageForLangfuse);
|
|
1382
|
-
const span = createSpan('gpt-4o', {
|
|
1383
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'generation',
|
|
1384
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]:
|
|
1385
|
-
JSON.stringify(serialized),
|
|
1386
|
-
});
|
|
1387
|
-
|
|
1388
|
-
redactLangfuseSpanToolOutputs(
|
|
1389
|
-
span,
|
|
1390
|
-
createConfig({
|
|
1391
|
-
redactedToolNames: new Set(['execute_sql']),
|
|
1392
|
-
})
|
|
1393
|
-
);
|
|
1394
|
-
|
|
1395
|
-
const redacted = readJsonAttribute<RedactedMessage[]>(
|
|
1396
|
-
span,
|
|
1397
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
1398
|
-
);
|
|
1399
|
-
expect(redacted[1].tool_calls?.[0]?.args?.query).toBe(
|
|
1400
|
-
'select secret_value from prod'
|
|
1401
|
-
);
|
|
1402
|
-
expect(redacted[2].role).toBe('execute_sql');
|
|
1403
|
-
expect(redacted[2].content).toBe(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1404
|
-
expect(JSON.stringify(redacted)).not.toContain('secret_value: 12345');
|
|
1405
|
-
});
|
|
1406
|
-
|
|
1407
|
-
it('redacts constructor-serialized ToolMessages from rehydrated content parts', () => {
|
|
1408
|
-
const payload: TPayload = [
|
|
1409
|
-
{ role: 'user', content: 'show the stored result' },
|
|
1410
|
-
{
|
|
1411
|
-
role: 'assistant',
|
|
1412
|
-
content: [
|
|
1413
|
-
{
|
|
1414
|
-
type: ContentTypes.TEXT,
|
|
1415
|
-
[ContentTypes.TEXT]: 'I will query ClickHouse.',
|
|
1416
|
-
tool_call_ids: ['call_sql'],
|
|
1417
|
-
},
|
|
1418
|
-
{
|
|
1419
|
-
type: ContentTypes.TOOL_CALL,
|
|
1420
|
-
tool_call: {
|
|
1421
|
-
id: 'call_sql',
|
|
1422
|
-
name: 'execute_sql',
|
|
1423
|
-
args: '{"query":"select constructor_path from prod"}',
|
|
1424
|
-
output: 'constructor path secret',
|
|
1425
|
-
},
|
|
1426
|
-
},
|
|
1427
|
-
],
|
|
1428
|
-
},
|
|
1429
|
-
];
|
|
1430
|
-
const { messages } = formatAgentMessages(
|
|
1431
|
-
payload,
|
|
1432
|
-
undefined,
|
|
1433
|
-
new Set(['execute_sql'])
|
|
1434
|
-
);
|
|
1435
|
-
const span = createSpan('gpt-4o', {
|
|
1436
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'generation',
|
|
1437
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify([
|
|
1438
|
-
messages,
|
|
1439
|
-
]),
|
|
1440
|
-
});
|
|
1441
|
-
|
|
1442
|
-
redactLangfuseSpanToolOutputs(
|
|
1443
|
-
span,
|
|
1444
|
-
createConfig({
|
|
1445
|
-
redactedToolNames: new Set(['execute_sql']),
|
|
1446
|
-
})
|
|
1447
|
-
);
|
|
1448
|
-
|
|
1449
|
-
const redacted = span.attributes[
|
|
1450
|
-
LangfuseOtelSpanAttributes.OBSERVATION_INPUT
|
|
1451
|
-
] as string;
|
|
1452
|
-
expect(redacted).toContain('select constructor_path from prod');
|
|
1453
|
-
expect(redacted).toContain(LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT);
|
|
1454
|
-
expect(redacted).not.toContain('constructor path secret');
|
|
1455
|
-
});
|
|
1456
|
-
|
|
1457
|
-
it('redacts ToolMessage artifacts because they are tool output', () => {
|
|
1458
|
-
const messages = [
|
|
1459
|
-
{
|
|
1460
|
-
id: ['langchain_core', 'messages', 'ToolMessage'],
|
|
1461
|
-
kwargs: {
|
|
1462
|
-
name: 'execute_sql',
|
|
1463
|
-
tool_call_id: 'call_sql',
|
|
1464
|
-
content: 'safe display content',
|
|
1465
|
-
artifact: {
|
|
1466
|
-
rows: ['artifact secret row'],
|
|
1467
|
-
},
|
|
1468
|
-
},
|
|
1469
|
-
},
|
|
1470
|
-
];
|
|
1471
|
-
const span = createSpan('gpt-4o', {
|
|
1472
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'generation',
|
|
1473
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_INPUT]: JSON.stringify(messages),
|
|
1474
|
-
});
|
|
1475
|
-
|
|
1476
|
-
redactLangfuseSpanToolOutputs(
|
|
1477
|
-
span,
|
|
1478
|
-
createConfig({
|
|
1479
|
-
redactedToolNames: new Set(['execute_sql']),
|
|
1480
|
-
})
|
|
1481
|
-
);
|
|
1482
|
-
|
|
1483
|
-
const redacted = readJsonAttribute<
|
|
1484
|
-
Array<{
|
|
1485
|
-
kwargs: {
|
|
1486
|
-
artifact: string;
|
|
1487
|
-
content: string;
|
|
1488
|
-
};
|
|
1489
|
-
}>
|
|
1490
|
-
>(span, LangfuseOtelSpanAttributes.OBSERVATION_INPUT);
|
|
1491
|
-
expect(redacted[0].kwargs.content).toBe(
|
|
1492
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
1493
|
-
);
|
|
1494
|
-
expect(redacted[0].kwargs.artifact).toBe(
|
|
1495
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
1496
|
-
);
|
|
1497
|
-
expect(JSON.stringify(redacted)).not.toContain('artifact secret row');
|
|
1498
|
-
});
|
|
1499
|
-
|
|
1500
|
-
it('merges run Langfuse defaults with agent redaction overrides', () => {
|
|
1501
|
-
const resolved = resolveLangfuseConfig(
|
|
1502
|
-
{
|
|
1503
|
-
enabled: true,
|
|
1504
|
-
publicKey: 'pk-run',
|
|
1505
|
-
secretKey: 'sk-run',
|
|
1506
|
-
baseUrl: 'https://langfuse.test',
|
|
1507
|
-
metadata: { tenantId: 'tenant-run' },
|
|
1508
|
-
librechatTraceAttributes: {
|
|
1509
|
-
'librechat.langfuse.destination': 'eu',
|
|
1510
|
-
'librechat.langfuse.tenant_export.enabled': true,
|
|
1511
|
-
},
|
|
1512
|
-
tags: ['tenant:tenant-run', 'shared'],
|
|
1513
|
-
deterministicTraceId: true,
|
|
1514
|
-
toolNodeTracing: { enabled: true },
|
|
1515
|
-
toolOutputTracing: {
|
|
1516
|
-
enabled: true,
|
|
1517
|
-
redactionText: '[redacted]',
|
|
1518
|
-
},
|
|
1519
|
-
},
|
|
1520
|
-
{
|
|
1521
|
-
publicKey: 'pk-agent',
|
|
1522
|
-
secretKey: 'sk-agent',
|
|
1523
|
-
baseUrl: 'https://langfuse.agent',
|
|
1524
|
-
metadata: { agentId: 'agent-1' },
|
|
1525
|
-
librechatTraceAttributes: {
|
|
1526
|
-
'librechat.langfuse.public_key': 'pk-agent',
|
|
1527
|
-
},
|
|
1528
|
-
tags: ['shared', 'agent:agent-1'],
|
|
1529
|
-
toolOutputTracing: {
|
|
1530
|
-
enabled: false,
|
|
1531
|
-
redactedToolNames: ['execute_sql'],
|
|
1532
|
-
},
|
|
1533
|
-
}
|
|
1534
|
-
);
|
|
1535
|
-
|
|
1536
|
-
expect(resolved).toMatchObject({
|
|
1537
|
-
enabled: true,
|
|
1538
|
-
publicKey: 'pk-agent',
|
|
1539
|
-
secretKey: 'sk-agent',
|
|
1540
|
-
baseUrl: 'https://langfuse.agent',
|
|
1541
|
-
metadata: { tenantId: 'tenant-run', agentId: 'agent-1' },
|
|
1542
|
-
librechatTraceAttributes: {
|
|
1543
|
-
'librechat.langfuse.destination': 'eu',
|
|
1544
|
-
'librechat.langfuse.tenant_export.enabled': true,
|
|
1545
|
-
'librechat.langfuse.public_key': 'pk-agent',
|
|
1546
|
-
},
|
|
1547
|
-
tags: ['tenant:tenant-run', 'shared', 'agent:agent-1'],
|
|
1548
|
-
deterministicTraceId: true,
|
|
1549
|
-
toolNodeTracing: { enabled: true },
|
|
1550
|
-
toolOutputTracing: {
|
|
1551
|
-
enabled: false,
|
|
1552
|
-
redactedToolNames: ['execute_sql'],
|
|
1553
|
-
redactionText: '[redacted]',
|
|
1554
|
-
},
|
|
1555
|
-
});
|
|
1556
|
-
});
|
|
1557
|
-
|
|
1558
|
-
it('inherits deterministic trace ids when tenant config only supplies connection settings', () => {
|
|
1559
|
-
const resolved = resolveLangfuseConfig(
|
|
1560
|
-
{
|
|
1561
|
-
deterministicTraceId: true,
|
|
1562
|
-
},
|
|
1563
|
-
{
|
|
1564
|
-
publicKey: 'pk-tenant',
|
|
1565
|
-
secretKey: 'sk-tenant',
|
|
1566
|
-
baseUrl: 'https://langfuse.tenant',
|
|
1567
|
-
}
|
|
1568
|
-
);
|
|
1569
|
-
|
|
1570
|
-
expect(resolved).toMatchObject({
|
|
1571
|
-
publicKey: 'pk-tenant',
|
|
1572
|
-
secretKey: 'sk-tenant',
|
|
1573
|
-
baseUrl: 'https://langfuse.tenant',
|
|
1574
|
-
deterministicTraceId: true,
|
|
1575
|
-
});
|
|
1576
|
-
});
|
|
1577
|
-
|
|
1578
|
-
it('inherits application-level redaction when tenant config does not explicitly opt out', () => {
|
|
1579
|
-
process.env.LANGFUSE_REDACT_TOOL_OUTPUTS = 'true';
|
|
1580
|
-
process.env.LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT = '[app redacted]';
|
|
1581
|
-
|
|
1582
|
-
const config = resolveToolOutputTracingConfig(
|
|
1583
|
-
{
|
|
1584
|
-
publicKey: 'pk-tenant',
|
|
1585
|
-
secretKey: 'sk-tenant',
|
|
1586
|
-
baseUrl: 'https://langfuse.tenant',
|
|
1587
|
-
toolOutputTracing: {
|
|
1588
|
-
redactionText: '[tenant redacted]',
|
|
1589
|
-
},
|
|
1590
|
-
},
|
|
1591
|
-
undefined
|
|
1592
|
-
);
|
|
1593
|
-
|
|
1594
|
-
expect(config).toMatchObject({
|
|
1595
|
-
enabled: false,
|
|
1596
|
-
redactionText: '[tenant redacted]',
|
|
1597
|
-
});
|
|
1598
|
-
});
|
|
1599
|
-
|
|
1600
|
-
it('keeps application redacted tool names when tenant adds its own names', () => {
|
|
1601
|
-
process.env.LANGFUSE_REDACT_TOOL_OUTPUT_NAMES = 'run_sql';
|
|
1602
|
-
|
|
1603
|
-
const config = resolveToolOutputTracingConfig(
|
|
1604
|
-
{
|
|
1605
|
-
toolOutputTracing: {
|
|
1606
|
-
redactedToolNames: ['execute_sql'],
|
|
1607
|
-
},
|
|
1608
|
-
},
|
|
1609
|
-
{
|
|
1610
|
-
toolOutputTracing: {
|
|
1611
|
-
redactedToolNames: ['web_search'],
|
|
1612
|
-
},
|
|
1613
|
-
}
|
|
1614
|
-
);
|
|
1615
|
-
|
|
1616
|
-
expect([...config.redactedToolNames].sort()).toEqual([
|
|
1617
|
-
'execute_sql',
|
|
1618
|
-
'run_sql',
|
|
1619
|
-
'web_search',
|
|
1620
|
-
]);
|
|
1621
|
-
});
|
|
1622
|
-
|
|
1623
|
-
it('keeps application partial redaction matching when tenant adds exact redaction config', () => {
|
|
1624
|
-
process.env.LANGFUSE_REDACT_TOOL_OUTPUT_NAME_MATCH_MODE = 'partial';
|
|
1625
|
-
|
|
1626
|
-
const config = resolveToolOutputTracingConfig(
|
|
1627
|
-
{
|
|
1628
|
-
toolOutputTracing: {
|
|
1629
|
-
redactedToolNames: ['execute'],
|
|
1630
|
-
},
|
|
1631
|
-
},
|
|
1632
|
-
{
|
|
1633
|
-
toolOutputTracing: {
|
|
1634
|
-
redactedToolNameMatchMode: 'exact',
|
|
1635
|
-
redactedToolNames: ['web_search'],
|
|
1636
|
-
},
|
|
1637
|
-
}
|
|
1638
|
-
);
|
|
1639
|
-
|
|
1640
|
-
expect(config.redactedToolNameMatchMode).toBe('partial');
|
|
1641
|
-
|
|
1642
|
-
const span = createSpan('execute_sql', {
|
|
1643
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'tool',
|
|
1644
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: 'secret rows',
|
|
1645
|
-
});
|
|
1646
|
-
|
|
1647
|
-
redactLangfuseSpanToolOutputs(span, config);
|
|
1648
|
-
|
|
1649
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]).toBe(
|
|
1650
|
-
LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT
|
|
1651
|
-
);
|
|
1652
|
-
});
|
|
1653
|
-
|
|
1654
|
-
it('lets tenant explicitly opt out of application-level redact-all outputs', () => {
|
|
1655
|
-
process.env.LANGFUSE_REDACT_TOOL_OUTPUTS = 'true';
|
|
1656
|
-
|
|
1657
|
-
const config = resolveToolOutputTracingConfig(
|
|
1658
|
-
{
|
|
1659
|
-
publicKey: 'pk-tenant',
|
|
1660
|
-
secretKey: 'sk-tenant',
|
|
1661
|
-
toolOutputTracing: {
|
|
1662
|
-
enabled: true,
|
|
1663
|
-
},
|
|
1664
|
-
},
|
|
1665
|
-
undefined
|
|
1666
|
-
);
|
|
1667
|
-
|
|
1668
|
-
expect(config.enabled).toBe(true);
|
|
1669
|
-
expect(config.redactedToolNames.size).toBe(0);
|
|
1670
|
-
});
|
|
1671
|
-
|
|
1672
|
-
it('applies application-level redaction through tenant runtime scope unless tenant opts out', () => {
|
|
1673
|
-
ensureOpenTelemetryContextManager();
|
|
1674
|
-
process.env.LANGFUSE_REDACT_TOOL_OUTPUTS = 'true';
|
|
1675
|
-
process.env.LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT = '[app redacted]';
|
|
1676
|
-
let capturedContext: Context | undefined;
|
|
1677
|
-
|
|
1678
|
-
withLangfuseRuntimeScope(
|
|
1679
|
-
resolveLangfuseRuntimeScope({
|
|
1680
|
-
runLangfuse: {
|
|
1681
|
-
publicKey: 'pk-tenant',
|
|
1682
|
-
secretKey: 'sk-tenant',
|
|
1683
|
-
baseUrl: 'https://langfuse.tenant',
|
|
1684
|
-
},
|
|
1685
|
-
}),
|
|
1686
|
-
() => {
|
|
1687
|
-
capturedContext = context.active();
|
|
1688
|
-
}
|
|
1689
|
-
);
|
|
1690
|
-
|
|
1691
|
-
expect(capturedContext).toBeDefined();
|
|
1692
|
-
const config = resolveToolOutputTracingConfigForSpan(capturedContext!);
|
|
1693
|
-
expect(config).toMatchObject({
|
|
1694
|
-
enabled: false,
|
|
1695
|
-
redactionText: '[app redacted]',
|
|
1696
|
-
});
|
|
1697
|
-
|
|
1698
|
-
const span = createSpan('execute_sql', {
|
|
1699
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'tool',
|
|
1700
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: 'tenant secret rows',
|
|
1701
|
-
});
|
|
1702
|
-
|
|
1703
|
-
redactLangfuseSpanToolOutputs(span, config!);
|
|
1704
|
-
|
|
1705
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]).toBe(
|
|
1706
|
-
'[app redacted]'
|
|
1707
|
-
);
|
|
1708
|
-
});
|
|
1709
|
-
|
|
1710
|
-
it('keeps OTEL context fallback for spans outside callback runtime scope', () => {
|
|
1711
|
-
ensureOpenTelemetryContextManager();
|
|
1712
|
-
const langfuse = {
|
|
1713
|
-
publicKey: 'pk-context',
|
|
1714
|
-
secretKey: 'sk-context',
|
|
1715
|
-
baseUrl: 'https://langfuse.context',
|
|
1716
|
-
};
|
|
1717
|
-
let capturedContext: Context | undefined;
|
|
1718
|
-
|
|
1719
|
-
withLangfuseRuntimeScope({ langfuse }, () => {
|
|
1720
|
-
capturedContext = context.active();
|
|
1721
|
-
});
|
|
1722
|
-
|
|
1723
|
-
expect(capturedContext).toBeDefined();
|
|
1724
|
-
expect(resolveLangfuseConfigForSpan(capturedContext!)).toBe(langfuse);
|
|
1725
|
-
});
|
|
1726
|
-
|
|
1727
|
-
it('keeps OTEL tool-output fallback for spans outside callback runtime scope', () => {
|
|
1728
|
-
ensureOpenTelemetryContextManager();
|
|
1729
|
-
let capturedContext: Context | undefined;
|
|
1730
|
-
|
|
1731
|
-
withLangfuseRuntimeScope(
|
|
1732
|
-
{ toolOutputTracing: createConfig({ enabled: false }) },
|
|
1733
|
-
() => {
|
|
1734
|
-
capturedContext = context.active();
|
|
1735
|
-
}
|
|
1736
|
-
);
|
|
1737
|
-
|
|
1738
|
-
expect(capturedContext).toBeDefined();
|
|
1739
|
-
expect(
|
|
1740
|
-
resolveToolOutputTracingConfigForSpan(capturedContext!)
|
|
1741
|
-
).toMatchObject({
|
|
1742
|
-
enabled: false,
|
|
1743
|
-
});
|
|
1744
|
-
});
|
|
1745
|
-
|
|
1746
|
-
it('honors env-only tool-output redaction in runtime scope', () => {
|
|
1747
|
-
ensureOpenTelemetryContextManager();
|
|
1748
|
-
process.env.LANGFUSE_REDACT_TOOL_OUTPUTS = 'true';
|
|
1749
|
-
let capturedContext: Context | undefined;
|
|
1750
|
-
|
|
1751
|
-
withLangfuseRuntimeScope(resolveLangfuseRuntimeScope({}), () => {
|
|
1752
|
-
capturedContext = context.active();
|
|
1753
|
-
});
|
|
1754
|
-
|
|
1755
|
-
expect(capturedContext).toBeDefined();
|
|
1756
|
-
const config = resolveToolOutputTracingConfigForSpan(capturedContext!);
|
|
1757
|
-
expect(config).toMatchObject({
|
|
1758
|
-
enabled: false,
|
|
1759
|
-
redactedToolNameMatchMode: 'exact',
|
|
1760
|
-
redactionText: LANGFUSE_TOOL_OUTPUT_REDACTION_TEXT,
|
|
1761
|
-
});
|
|
1762
|
-
expect(config?.redactedToolNames.size).toBe(0);
|
|
1763
|
-
});
|
|
1764
|
-
|
|
1765
|
-
it('applies agent tool-output redaction override through runtime scope', () => {
|
|
1766
|
-
ensureOpenTelemetryContextManager();
|
|
1767
|
-
let capturedContext: Context | undefined;
|
|
1768
|
-
|
|
1769
|
-
withLangfuseRuntimeScope(
|
|
1770
|
-
resolveLangfuseRuntimeScope({
|
|
1771
|
-
runLangfuse: {
|
|
1772
|
-
toolOutputTracing: {
|
|
1773
|
-
enabled: true,
|
|
1774
|
-
redactionText: '[agent redacted]',
|
|
1775
|
-
},
|
|
1776
|
-
},
|
|
1777
|
-
langfuseOverlay: {
|
|
1778
|
-
toolOutputTracing: {
|
|
1779
|
-
enabled: false,
|
|
1780
|
-
},
|
|
1781
|
-
},
|
|
1782
|
-
}),
|
|
1783
|
-
() => {
|
|
1784
|
-
capturedContext = context.active();
|
|
1785
|
-
}
|
|
1786
|
-
);
|
|
1787
|
-
|
|
1788
|
-
expect(capturedContext).toBeDefined();
|
|
1789
|
-
const config = resolveToolOutputTracingConfigForSpan(capturedContext!);
|
|
1790
|
-
expect(config).toMatchObject({
|
|
1791
|
-
enabled: false,
|
|
1792
|
-
redactionText: '[agent redacted]',
|
|
1793
|
-
});
|
|
1794
|
-
|
|
1795
|
-
const span = createSpan('execute_sql', {
|
|
1796
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_TYPE]: 'tool',
|
|
1797
|
-
[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]: 'secret rows',
|
|
1798
|
-
});
|
|
1799
|
-
|
|
1800
|
-
redactLangfuseSpanToolOutputs(span, config!);
|
|
1801
|
-
|
|
1802
|
-
expect(span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_OUTPUT]).toBe(
|
|
1803
|
-
'[agent redacted]'
|
|
1804
|
-
);
|
|
1805
|
-
});
|
|
1806
|
-
|
|
1807
|
-
it('prefers ALS runtime tenant config over OTEL fallback config', () => {
|
|
1808
|
-
ensureOpenTelemetryContextManager();
|
|
1809
|
-
const otelLangfuse = {
|
|
1810
|
-
publicKey: 'pk-otel',
|
|
1811
|
-
secretKey: 'sk-otel',
|
|
1812
|
-
baseUrl: 'https://langfuse.otel',
|
|
1813
|
-
};
|
|
1814
|
-
const runtimeLangfuse = {
|
|
1815
|
-
publicKey: 'pk-runtime',
|
|
1816
|
-
secretKey: 'sk-runtime',
|
|
1817
|
-
baseUrl: 'https://langfuse.runtime',
|
|
1818
|
-
};
|
|
1819
|
-
let capturedContext: Context | undefined;
|
|
1820
|
-
|
|
1821
|
-
withLangfuseRuntimeScope({ langfuse: otelLangfuse }, () => {
|
|
1822
|
-
capturedContext = context.active();
|
|
1823
|
-
});
|
|
1824
|
-
|
|
1825
|
-
runWithLangfuseRuntimeContext({ langfuse: runtimeLangfuse }, () => {
|
|
1826
|
-
expect(resolveLangfuseConfigForSpan(capturedContext!)).toBe(
|
|
1827
|
-
runtimeLangfuse
|
|
1828
|
-
);
|
|
1829
|
-
});
|
|
1830
|
-
});
|
|
1831
|
-
|
|
1832
|
-
it('prefers ALS runtime tool-output config over OTEL fallback config', () => {
|
|
1833
|
-
ensureOpenTelemetryContextManager();
|
|
1834
|
-
const runtimeToolOutputTracing = {
|
|
1835
|
-
enabled: false,
|
|
1836
|
-
redactedToolNames: new Set(['runtime_tool']),
|
|
1837
|
-
redactedToolNameMatchMode: 'exact' as const,
|
|
1838
|
-
redactionText: '[runtime]',
|
|
1839
|
-
};
|
|
1840
|
-
let capturedContext: Context | undefined;
|
|
1841
|
-
|
|
1842
|
-
withLangfuseRuntimeScope(
|
|
1843
|
-
{ toolOutputTracing: createConfig({ enabled: true }) },
|
|
1844
|
-
() => {
|
|
1845
|
-
capturedContext = context.active();
|
|
1846
|
-
}
|
|
1847
|
-
);
|
|
1848
|
-
|
|
1849
|
-
runWithLangfuseRuntimeContext(
|
|
1850
|
-
{ toolOutputTracing: runtimeToolOutputTracing },
|
|
1851
|
-
() => {
|
|
1852
|
-
expect(resolveToolOutputTracingConfigForSpan(capturedContext!)).toBe(
|
|
1853
|
-
runtimeToolOutputTracing
|
|
1854
|
-
);
|
|
1855
|
-
}
|
|
1856
|
-
);
|
|
1857
|
-
});
|
|
1858
|
-
});
|