@librechat/agents 3.4.7 → 3.5.1
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 +0 -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 +0 -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/package.json +35 -32
- package/dist/types/agents/__tests__/promptCacheLiveHelpers.d.ts +0 -52
- package/dist/types/test/mockTools.d.ts +0 -28
- package/dist/types/utils/__tests__/fixtures/contextOverflowSignatures.d.ts +0 -40
- 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 -196
- 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,19 +1,5 @@
|
|
|
1
1
|
import { getStreamedToolCallSeal } from "../tools/streamedToolCallSeals.mjs";
|
|
2
2
|
//#region src/llm/streamLimits.ts
|
|
3
|
-
/**
|
|
4
|
-
* Circuit breakers for pathological model streams.
|
|
5
|
-
*
|
|
6
|
-
* A malformed generation can stream a single tool call's arguments for many
|
|
7
|
-
* minutes at the provider's full token rate while the arguments never become
|
|
8
|
-
* executable (observed live: one 149,923-char SQL argument streamed for 26
|
|
9
|
-
* minutes before the 64k output-token ceiling finally ended the run). These
|
|
10
|
-
* guards fail fast instead: when a limit trips, the stream handler throws
|
|
11
|
-
* `StreamLimitExceededError` out of the run's `streamEvents` loop, which
|
|
12
|
-
* tears down the in-flight provider request where it stands (see the
|
|
13
|
-
* mid-flight halt notes in `Run.processStream`: leaving the loop cancels the
|
|
14
|
-
* reader and langgraph aborts the model call).
|
|
15
|
-
*/
|
|
16
|
-
/** Default cap on a single streamed tool call's cumulative argument bytes (64 KiB). */
|
|
17
3
|
const DEFAULT_MAX_TOOL_CALL_ARG_BYTES = 65536;
|
|
18
4
|
function resolveLimit(value, fallback) {
|
|
19
5
|
if (value == null || Number.isNaN(value)) return fallback;
|
|
@@ -21,23 +7,11 @@ function resolveLimit(value, fallback) {
|
|
|
21
7
|
const whole = Math.floor(value);
|
|
22
8
|
return whole > 0 ? whole : 0;
|
|
23
9
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Normalizes host-supplied limits once at graph construction. `undefined`
|
|
26
|
-
* applies the default for each guard (the tool-argument byte cap is ON by
|
|
27
|
-
* default, the per-turn event cap is opt-in), `0` and negative values
|
|
28
|
-
* disable a guard, `Infinity` means "no limit" and also disables, and `NaN`
|
|
29
|
-
* falls back to the default.
|
|
30
|
-
*/
|
|
31
10
|
function resolveStreamLimits(limits) {
|
|
32
11
|
const maxToolCallArgBytes = resolveLimit(limits?.maxToolCallArgBytes, DEFAULT_MAX_TOOL_CALL_ARG_BYTES);
|
|
33
12
|
let maxToolCallArgBytesByTool;
|
|
34
13
|
if (limits?.maxToolCallArgBytesByTool != null) for (const [name, value] of Object.entries(limits.maxToolCallArgBytesByTool)) {
|
|
35
|
-
/** An unusable entry (NaN) falls back to the global cap by omission,
|
|
36
|
-
* matching how the global field treats NaN. */
|
|
37
14
|
if (name === "" || Number.isNaN(value)) continue;
|
|
38
|
-
/** Prototype-free: bracket-assigning a `__proto__` tool name into a
|
|
39
|
-
* plain object invokes the prototype setter instead of creating an own
|
|
40
|
-
* property, silently dropping that tool's configured override. */
|
|
41
15
|
maxToolCallArgBytesByTool ??= Object.create(null);
|
|
42
16
|
maxToolCallArgBytesByTool[name] = resolveLimit(value, maxToolCallArgBytes);
|
|
43
17
|
}
|
|
@@ -54,11 +28,6 @@ function buildLimitMessage(kind, limit, toolName) {
|
|
|
54
28
|
if (kind === "tool_call_args") return `Streamed tool call arguments exceeded the ${limit}-byte safety limit${toolName != null && toolName !== "" ? ` (tool call: ${toolName})` : ""}. The generation was aborted mid-stream: arguments growing this large without completing usually indicate a runaway or malformed tool call. Raise 'maxToolCallArgBytes' (or the tool's 'maxToolCallArgBytesByTool' entry) if your tools legitimately need larger arguments.`;
|
|
55
29
|
return `Model stream exceeded the ${limit}-event safety limit for a single generation turn. The generation was aborted mid-stream: this usually indicates a looping or duplicated provider stream. Raise 'maxDeltaEventsPerTurn' if legitimate generations need more stream events.`;
|
|
56
30
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Raised when a {@link t.StreamLimits} guard trips. Thrown from inside the
|
|
59
|
-
* run's `streamEvents` loop, so the in-flight provider request is torn down
|
|
60
|
-
* and `processStream` rejects with this error.
|
|
61
|
-
*/
|
|
62
31
|
var StreamLimitExceededError = class extends Error {
|
|
63
32
|
kind;
|
|
64
33
|
limit;
|
|
@@ -73,77 +42,16 @@ var StreamLimitExceededError = class extends Error {
|
|
|
73
42
|
this.toolName = toolName;
|
|
74
43
|
}
|
|
75
44
|
};
|
|
76
|
-
/**
|
|
77
|
-
* Identity of one model generation, derived from langgraph's node-execution
|
|
78
|
-
* metadata. Deliberately NOT `Graph.getStepKey()`: the step key forks within
|
|
79
|
-
* a single generation on reasoning transitions (`'reasoning'` /
|
|
80
|
-
* `post-reasoning-<n>` suffixes in `getKeyList`) and on mid-turn server-tool
|
|
81
|
-
* results (`invokedToolIds` count), which would hand a fresh budget to each
|
|
82
|
-
* segment. One agent-node execution is one superstep, so
|
|
83
|
-
* `checkpoint_ns + node + step` stays stable for the whole generation and
|
|
84
|
-
* distinguishes parallel agents in the same superstep.
|
|
85
|
-
*
|
|
86
|
-
* The attempt stamp scopes attempts within one node execution:
|
|
87
|
-
* `attemptInvoke` is the single funnel for primary, fallback, and
|
|
88
|
-
* summarization model calls and stamps {@link STREAM_LIMIT_ATTEMPT_KEY}
|
|
89
|
-
* with a unique sequence number into each attempt's callback metadata. A
|
|
90
|
-
* fallback's chunks therefore key separately from the failed primary's,
|
|
91
|
-
* even for two fallbacks configured with the same provider and model name,
|
|
92
|
-
* and even when the decoupled `streamEvents` reader drains a failed
|
|
93
|
-
* attempt's buffered chunks late. Those late chunks land in their own
|
|
94
|
-
* attempt's bucket instead of polluting the next one's.
|
|
95
|
-
*/
|
|
96
45
|
function resolveGenerationKey(metadata) {
|
|
97
46
|
if (metadata == null) return "";
|
|
98
47
|
return `${metadata.langgraph_checkpoint_ns ?? ""}|${metadata.langgraph_node ?? ""}|${metadata.langgraph_step ?? ""}|${metadata["lc_stream_limit_attempt"] ?? ""}`;
|
|
99
48
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Metadata key carrying the unique per-model-attempt sequence number that
|
|
102
|
-
* `attemptInvoke` stamps into every attempt's callback metadata. Part of
|
|
103
|
-
* the generation key so budgets never alias across attempts.
|
|
104
|
-
*/
|
|
105
49
|
const STREAM_LIMIT_ATTEMPT_KEY = "lc_stream_limit_attempt";
|
|
106
|
-
/**
|
|
107
|
-
* Event-metadata marker for a chunk the SDK re-dispatches inline after
|
|
108
|
-
* transforming it (`attemptInvoke`'s OpenRouter final-reasoning replay). The
|
|
109
|
-
* original wire chunk still reaches the handler through `streamEvents` and
|
|
110
|
-
* is counted there, so the re-dispatch must not consume a second
|
|
111
|
-
* event-budget slot.
|
|
112
|
-
*/
|
|
113
50
|
const STREAM_LIMIT_REDISPATCH_KEY = "lc_stream_limit_redispatch";
|
|
114
|
-
/**
|
|
115
|
-
* Metadata key carrying the graph's breaker epoch at the time a model
|
|
116
|
-
* attempt started. The stream handler trips the shared breaker only when
|
|
117
|
-
* the event's epoch matches the live controller's — a straggling chunk from
|
|
118
|
-
* a failed run that outlived `resetValues()` must fail its own (dead) run,
|
|
119
|
-
* not abort the controller now serving the next one. A primitive rather
|
|
120
|
-
* than the controller itself so attempt metadata stays serialization-safe
|
|
121
|
-
* for tracing.
|
|
122
|
-
*/
|
|
123
51
|
const STREAM_LIMIT_EPOCH_KEY = "lc_stream_limit_epoch";
|
|
124
|
-
/**
|
|
125
|
-
* Configurable key carrying the tool batch's entry-captured
|
|
126
|
-
* {@link RunBreakerScope} to tools that spawn their own runs (subagents).
|
|
127
|
-
* Captured BEFORE PreToolUse hooks, so a reset during a hook cannot rebind
|
|
128
|
-
* the spawned child to the new run's controller. Stripped from host-facing
|
|
129
|
-
* batch requests and from child-graph configurables.
|
|
130
|
-
*/
|
|
131
52
|
const RUN_BREAKER_SCOPE_CONFIG_KEY = "lc_run_breaker_scope";
|
|
132
|
-
/**
|
|
133
|
-
* True when the event's `single` seal marks this chunk's own call as
|
|
134
|
-
* complete. On the OpenAI Responses adapter the sealing chunk RESTATES the
|
|
135
|
-
* full argument string (`response.function_call_arguments.done`), so summing
|
|
136
|
-
* it would double-count every legitimate call; on Bedrock Converse the
|
|
137
|
-
* sealing chunk carries empty args. Either way the call is finished: its
|
|
138
|
-
* tally is replaced by the sealing chunk's own bytes, checked, and released.
|
|
139
|
-
*/
|
|
140
53
|
function sealsChunk(seal, chunk) {
|
|
141
54
|
if (seal == null || seal.kind !== "single") return false;
|
|
142
|
-
/** Either supplied identifier agreeing is sufficient (matching the
|
|
143
|
-
* eager-call seal handling in stream.ts): a mismatch on one identifier
|
|
144
|
-
* must not veto a match on the other, or an OpenAI-style full-argument
|
|
145
|
-
* restatement gets ADDED to the tally instead of replacing it, and an
|
|
146
|
-
* empty seal leaves the tally unreleased. */
|
|
147
55
|
if (seal.index != null && chunk.index != null && seal.index === chunk.index) return true;
|
|
148
56
|
const sealId = seal.id != null && seal.id !== "" ? seal.id : void 0;
|
|
149
57
|
return sealId != null && sealId === chunkCallId(chunk);
|
|
@@ -151,10 +59,6 @@ function sealsChunk(seal, chunk) {
|
|
|
151
59
|
function chunkToolName(chunk) {
|
|
152
60
|
return chunk.name != null && chunk.name !== "" ? chunk.name : void 0;
|
|
153
61
|
}
|
|
154
|
-
/** The chunk's id with empty-string placeholders treated as absent —
|
|
155
|
-
* OpenAI-compatible adapters emit `id: ''` on continuation deltas, and a
|
|
156
|
-
* shared placeholder must not merge independent calls onto one identity
|
|
157
|
-
* (mirrors `getEagerToolChunkKey`). */
|
|
158
62
|
function chunkCallId(chunk) {
|
|
159
63
|
return chunk.id != null && chunk.id !== "" ? chunk.id : void 0;
|
|
160
64
|
}
|
|
@@ -164,40 +68,15 @@ function isHighSurrogate(code) {
|
|
|
164
68
|
function isLowSurrogate(code) {
|
|
165
69
|
return code >= 56320 && code <= 57343;
|
|
166
70
|
}
|
|
167
|
-
/**
|
|
168
|
-
* Accumulates the UTF-8 byte size of streamed tool-call argument chunks per
|
|
169
|
-
* in-flight tool call and throws once a single call's cumulative bytes
|
|
170
|
-
* exceed `maxToolCallArgBytes`. Runs once per streamed chunk event, before
|
|
171
|
-
* complete tool calls are dispatched or eagerly executed and before chunks
|
|
172
|
-
* are recorded, so a tripped limit stops the run without dispatching the
|
|
173
|
-
* offending call.
|
|
174
|
-
*
|
|
175
|
-
* Calls are keyed by generation and chunk `index`, falling back to the
|
|
176
|
-
* chunk `id` and then to the chunk's position within the event's batch when
|
|
177
|
-
* a provider identifies chunks by neither (Google emits complete parallel
|
|
178
|
-
* calls with optional ids and no index). A `kind: 'all'` arrival seal marks
|
|
179
|
-
* every chunk in the event as its own complete call, so those are checked
|
|
180
|
-
* standalone and never share a budget; a matching `kind: 'single'` seal
|
|
181
|
-
* replaces the call's tally with the sealing chunk's own bytes (the OpenAI
|
|
182
|
-
* Responses done-chunk restates the full argument string) and releases it.
|
|
183
|
-
*/
|
|
184
71
|
function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, responseMetadata, parsedToolCalls }) {
|
|
185
72
|
const resolved = graph.streamLimits ?? DEFAULT_RESOLVED_LIMITS;
|
|
186
73
|
const globalLimit = resolved.maxToolCallArgBytes;
|
|
187
74
|
const byTool = resolved.maxToolCallArgBytesByTool;
|
|
188
75
|
if (!resolved.hasEnforceableToolCallArgLimit) return;
|
|
189
|
-
/** An inline re-dispatch of a transformed chunk (OpenRouter final-reasoning
|
|
190
|
-
* replay) duplicates tool-call chunks the original `streamEvents` event
|
|
191
|
-
* already charged — the original always survives the content-specific
|
|
192
|
-
* skips when it carries tool calls, so counting the marked copy would
|
|
193
|
-
* double every legitimate argument byte. */
|
|
194
76
|
if (metadata?.["lc_stream_limit_redispatch"] === true) return;
|
|
195
77
|
const tallies = graph.streamedToolCallArgTallies ??= /* @__PURE__ */ new Map();
|
|
196
78
|
const generationKey = resolveGenerationKey(metadata);
|
|
197
79
|
const seal = getStreamedToolCallSeal(responseMetadata);
|
|
198
|
-
/** The complete call in this event sharing the chunk's id — the strongest
|
|
199
|
-
* name evidence: adapters may stream raw names in FRAGMENTS, and an
|
|
200
|
-
* id-correlated complete call states the full name outright. */
|
|
201
80
|
const correlateParsedNameById = (id) => {
|
|
202
81
|
if (parsedToolCalls == null) return;
|
|
203
82
|
for (const parsed of parsedToolCalls) if (parsed.id === id && parsed.name != null && parsed.name !== "") return parsed.name;
|
|
@@ -214,11 +93,6 @@ function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, resp
|
|
|
214
93
|
if (correlated != null) return correlated;
|
|
215
94
|
const name = chunkToolName(chunk);
|
|
216
95
|
if (name != null || parsedToolCalls == null || chunkId != null) return name;
|
|
217
|
-
/** No id to correlate on; positional association is unambiguous only
|
|
218
|
-
* when the event carries exactly one raw chunk AND one parsed call —
|
|
219
|
-
* with several id-less raw chunks in flight, handing one parsed call's
|
|
220
|
-
* name (and its override) to all of them would let an unrelated
|
|
221
|
-
* still-partial call bypass the global cap. */
|
|
222
96
|
if (parsedToolCalls.length === 1 && toolCallChunks.length === 1) {
|
|
223
97
|
const only = parsedToolCalls[0];
|
|
224
98
|
if (only.name != null && only.name !== "") return only.name;
|
|
@@ -250,59 +124,25 @@ function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, resp
|
|
|
250
124
|
});
|
|
251
125
|
continue;
|
|
252
126
|
}
|
|
253
|
-
/** Keys are namespaced by identity kind (`i:` index, `c:` id, `#`
|
|
254
|
-
* batch position) so an index and a string id with the same textual
|
|
255
|
-
* value — index 0 and id "0" — cannot alias distinct calls onto one
|
|
256
|
-
* tally. Empty-string ids are placeholders, not identities. */
|
|
257
127
|
const chunkId = chunkCallId(chunk);
|
|
258
128
|
const sealed = sealsChunk(seal, chunk);
|
|
259
|
-
/** Applies this chunk's name contribution and reports whether the
|
|
260
|
-
* effective name changed. Adapters may stream the name in FRAGMENTS
|
|
261
|
-
* ("create_" then "file"), so unsealed fragments append — matching
|
|
262
|
-
* langchain's own tool-call-chunk merge — while a sealing chunk's name
|
|
263
|
-
* is a full restatement and replaces, mirroring how sealed args replace
|
|
264
|
-
* the tally bytes. An id-correlated complete call in the same event
|
|
265
|
-
* outranks both; positional parsed-call correlation fills in only when
|
|
266
|
-
* the chunk carries no fragment. */
|
|
267
129
|
const applyChunkName = (target) => {
|
|
268
130
|
const correlated = chunkId != null ? correlateParsedNameById(chunkId) : void 0;
|
|
269
131
|
const fragment = chunkToolName(chunk);
|
|
270
132
|
let next = target.name;
|
|
271
|
-
if (correlated != null)
|
|
272
|
-
/** An id-correlated complete call wins over fragment accumulation:
|
|
273
|
-
* a raw name like "create_" must not hide the "create_file"
|
|
274
|
-
* override behind the global cap. */
|
|
275
|
-
next = correlated;
|
|
133
|
+
if (correlated != null) next = correlated;
|
|
276
134
|
else if (fragment != null) {
|
|
277
135
|
if (sealed || target.name == null) next = fragment;
|
|
278
|
-
else if (fragment !== target.name)
|
|
279
|
-
/** A fragment identical to the accumulated name is a repeated
|
|
280
|
-
* full-name delta (a common provider shape) and is a no-op; a
|
|
281
|
-
* differing fragment is a continuation and appends. */
|
|
282
|
-
next = target.name + fragment;
|
|
136
|
+
else if (fragment !== target.name) next = target.name + fragment;
|
|
283
137
|
} else if (target.name == null) next = resolveChunkName(chunk);
|
|
284
138
|
if (next === target.name) return false;
|
|
285
139
|
target.name = next;
|
|
286
140
|
return true;
|
|
287
141
|
};
|
|
288
|
-
/** A single identifier-less event while calls are live is a sparse
|
|
289
|
-
* parallel continuation: its position is relative to this event, not to
|
|
290
|
-
* the original batch, so `#0` cannot identify which call it belongs to.
|
|
291
|
-
* With exactly one live call the association is unambiguous — charge
|
|
292
|
-
* that tally, keeping its budget continuous (a fresh `#0` tally here
|
|
293
|
-
* would RESET the sole remaining call's byte budget). With several,
|
|
294
|
-
* charge every live candidate. Each tally is judged under its OWN
|
|
295
|
-
* name-specific limit: comparing only against the global cap would let
|
|
296
|
-
* a call with a lower per-tool override stream past it indefinitely
|
|
297
|
-
* while its chunks stay anonymous. */
|
|
298
142
|
if (chunk.index == null && chunkId == null && toolCallChunks.length === 1) {
|
|
299
143
|
const liveTallies = getLiveGenerationTallies();
|
|
300
144
|
if (liveTallies.length > 0) {
|
|
301
|
-
if (liveTallies.length === 1 && applyChunkName(liveTallies[0]))
|
|
302
|
-
/** A late name can select a lower override than the limit under
|
|
303
|
-
* which prior bytes were accepted, so re-judge before charging
|
|
304
|
-
* this continuation. */
|
|
305
|
-
enforceTallyLimit(liveTallies[0]);
|
|
145
|
+
if (liveTallies.length === 1 && applyChunkName(liveTallies[0])) enforceTallyLimit(liveTallies[0]);
|
|
306
146
|
if (hasArgs) {
|
|
307
147
|
const argBytes = Buffer.byteLength(args, "utf8");
|
|
308
148
|
for (const liveTally of liveTallies) {
|
|
@@ -319,41 +159,19 @@ function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, resp
|
|
|
319
159
|
if (chunk.index != null) key = `${generationKey}:i:${chunk.index}`;
|
|
320
160
|
else if (chunkId != null) key = `${generationKey}:c:${chunkId}`;
|
|
321
161
|
else key = `${generationKey}:#${i}`;
|
|
322
|
-
/** Batch position is a stable identity only when the event carries a
|
|
323
|
-
* single chunk: sparse parallel events reuse position 0 for whichever
|
|
324
|
-
* call happens to continue, and a position alias would hand one call's
|
|
325
|
-
* tally — and its per-tool override — to another live call's deltas. */
|
|
326
162
|
const positionAliasSafe = toolCallChunks.length === 1;
|
|
327
|
-
/** Secondary keys this call is also reachable under, so a later delta
|
|
328
|
-
* that drops one or both identifiers still lands on the same tally:
|
|
329
|
-
* id-bearing chunks register the batch-position fallback (single-chunk
|
|
330
|
-
* events only), and chunks carrying both identifiers additionally
|
|
331
|
-
* register the id. */
|
|
332
163
|
const aliasCandidates = [];
|
|
333
164
|
if (chunkId != null) {
|
|
334
165
|
if (positionAliasSafe) aliasCandidates.push(`${generationKey}:#${i}`);
|
|
335
166
|
if (chunk.index != null) aliasCandidates.push(`${generationKey}:c:${chunkId}`);
|
|
336
167
|
}
|
|
337
168
|
let tally = tallies.get(key);
|
|
338
|
-
/** A later delta can also ADD an identifier, changing the primary key;
|
|
339
|
-
* adopt the call's existing tally through a stronger prior identity
|
|
340
|
-
* before allocating. An index maps to that call's original batch
|
|
341
|
-
* position, never this sparse event's position. A newly arrived id can
|
|
342
|
-
* adopt a position only when one anonymous tally is live; with several,
|
|
343
|
-
* positional association is ambiguous. The old identity is recorded as
|
|
344
|
-
* an alias and released together with the rest. */
|
|
345
169
|
if (tally == null) {
|
|
346
170
|
const adoptionCandidates = [];
|
|
347
171
|
if (chunkId != null) adoptionCandidates.push(`${generationKey}:c:${chunkId}`);
|
|
348
172
|
if (chunk.index != null) {
|
|
349
|
-
/** An index is stable across sparse events; the loop position is
|
|
350
|
-
* merely this event's position and may be 0 for call index 1. */
|
|
351
173
|
const indexedPositionKey = `${generationKey}:#${chunk.index}`;
|
|
352
174
|
adoptionCandidates.push(indexedPositionKey);
|
|
353
|
-
/** A single anonymous call may first appear alone at event position
|
|
354
|
-
* #0 and reveal a nonzero provider index only later. Exact indexed
|
|
355
|
-
* position wins above; when it does not exist, one anonymous tally
|
|
356
|
-
* is still an unambiguous fallback. */
|
|
357
175
|
const liveTallies = getLiveGenerationTallies();
|
|
358
176
|
const soleTally = liveTallies.length === 1 ? liveTallies[0] : void 0;
|
|
359
177
|
if (soleTally?.keys?.[0]?.startsWith(`${generationPrefix}#`) === true) {
|
|
@@ -371,10 +189,6 @@ function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, resp
|
|
|
371
189
|
if (adoptionKey === key) continue;
|
|
372
190
|
const existing = tallies.get(adoptionKey);
|
|
373
191
|
if (existing == null) continue;
|
|
374
|
-
/** A position entry may only be adopted when the tally was CREATED
|
|
375
|
-
* anonymous (its first key is the position): id-bearing calls also
|
|
376
|
-
* alias their position, and adopting a live parallel call's alias
|
|
377
|
-
* would merge distinct budgets. */
|
|
378
192
|
if (adoptionKey.includes(":#") && existing.keys?.[0] !== adoptionKey) continue;
|
|
379
193
|
tally = existing;
|
|
380
194
|
tallies.set(key, existing);
|
|
@@ -387,9 +201,6 @@ function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, resp
|
|
|
387
201
|
for (const aliasKey of candidates) {
|
|
388
202
|
const currentOwner = tallies.get(aliasKey);
|
|
389
203
|
if (currentOwner === target) continue;
|
|
390
|
-
/** Parallel calls can contend for one batch position, so the newest
|
|
391
|
-
* live call takes the alias over and the previous owner is disowned
|
|
392
|
-
* — its seal must not delete a key it no longer holds. */
|
|
393
204
|
if (currentOwner?.keys != null) {
|
|
394
205
|
const remaining = currentOwner.keys.filter((ownedKey) => ownedKey !== aliasKey);
|
|
395
206
|
currentOwner.keys = remaining.length > 0 ? remaining : void 0;
|
|
@@ -401,10 +212,6 @@ function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, resp
|
|
|
401
212
|
const registerAliases = (target) => {
|
|
402
213
|
registerAliasKeys(target, aliasCandidates);
|
|
403
214
|
};
|
|
404
|
-
/** Index-only calls register their batch position ONCE, at creation:
|
|
405
|
-
* later deltas that drop the index then land on the same tally, while
|
|
406
|
-
* the per-delta hot path (indexed id-less deltas) stays free of alias
|
|
407
|
-
* work. */
|
|
408
215
|
const registerCreationPositionAlias = (target) => {
|
|
409
216
|
if (chunkId != null || chunk.index == null || sealed) return;
|
|
410
217
|
if (!positionAliasSafe) return;
|
|
@@ -430,15 +237,8 @@ function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, resp
|
|
|
430
237
|
}
|
|
431
238
|
continue;
|
|
432
239
|
}
|
|
433
|
-
/** A sealing chunk is about to release this tally; taking the position
|
|
434
|
-
* alias here would steal it from a still-live parallel call. */
|
|
435
240
|
if (!sealed) registerAliases(tally);
|
|
436
|
-
if (applyChunkName(tally))
|
|
437
|
-
/** Bytes tallied under the previous (or absent) name were held
|
|
438
|
-
* against that name's limit; a changed name — late arrival or a
|
|
439
|
-
* completed fragment — must re-judge them, including on a sealing
|
|
440
|
-
* chunk about to release the tally. */
|
|
441
|
-
enforceTallyLimit(tally);
|
|
241
|
+
if (applyChunkName(tally)) enforceTallyLimit(tally);
|
|
442
242
|
if (sealed) releaseTally(tally);
|
|
443
243
|
continue;
|
|
444
244
|
}
|
|
@@ -471,14 +271,6 @@ function enforceStreamedToolCallArgLimit({ graph, metadata, toolCallChunks, resp
|
|
|
471
271
|
if (sealed) releaseTally(tally);
|
|
472
272
|
}
|
|
473
273
|
}
|
|
474
|
-
/**
|
|
475
|
-
* Standalone byte check for complete parsed tool calls that arrive without a
|
|
476
|
-
* raw chunk representation: a streaming custom or OpenAI-compatible
|
|
477
|
-
* `ChatModel` can yield fully parsed `tool_calls` with empty
|
|
478
|
-
* `tool_call_chunks`, which would otherwise dispatch without consuming any
|
|
479
|
-
* byte budget. Complete calls are self-contained, so each is judged
|
|
480
|
-
* standalone without tallying.
|
|
481
|
-
*/
|
|
482
274
|
function enforceCompleteToolCallArgLimit({ graph, metadata, toolCalls }) {
|
|
483
275
|
const resolved = graph.streamLimits ?? DEFAULT_RESOLVED_LIMITS;
|
|
484
276
|
const globalLimit = resolved.maxToolCallArgBytes;
|
|
@@ -503,40 +295,19 @@ function enforceCompleteToolCallArgLimit({ graph, metadata, toolCalls }) {
|
|
|
503
295
|
});
|
|
504
296
|
}
|
|
505
297
|
}
|
|
506
|
-
/**
|
|
507
|
-
* Whether a chunk needs charge accounting at all. With the event cap off
|
|
508
|
-
* (the default) and no tool payload on the chunk, there is nothing a claim
|
|
509
|
-
* could ever gate — skipping restores the documented zero-cost-disabled
|
|
510
|
-
* behavior by avoiding a WeakMap entry and nested Map per ordinary text
|
|
511
|
-
* delta. Both the producer and consumer paths use this same predicate on
|
|
512
|
-
* the same chunk, so claim pairing is unaffected.
|
|
513
|
-
*/
|
|
514
298
|
function requiresStreamLimitAccounting(graph, chunk) {
|
|
515
299
|
const resolved = graph.streamLimits ?? DEFAULT_RESOLVED_LIMITS;
|
|
516
300
|
if (resolved.maxDeltaEventsPerTurn > 0) return true;
|
|
517
|
-
/** With no argument limit able to fire (byte cap disabled and every
|
|
518
|
-
* per-tool entry a zero-valued disable), neither enforcement function can
|
|
519
|
-
* trip — hosts that explicitly disable the guards for legitimate large
|
|
520
|
-
* arguments must not pay per-chunk claim allocations (generation keys,
|
|
521
|
-
* WeakMap entries, nested Maps) for bookkeeping that judges nothing. */
|
|
522
301
|
if (!resolved.hasEnforceableToolCallArgLimit) return false;
|
|
523
302
|
return (chunk.tool_call_chunks?.length ?? 0) > 0 || (chunk.tool_calls?.length ?? 0) > 0 || (chunk.invalid_tool_calls?.length ?? 0) > 0;
|
|
524
303
|
}
|
|
525
|
-
/** True when any stream-limit guard can fire for this graph. The attempt
|
|
526
|
-
* lease and per-chunk claims are both gated on it — fully disabled guards
|
|
527
|
-
* must allocate no bookkeeping at all, per-attempt included. */
|
|
528
304
|
function streamLimitAccountingEnabled(graph) {
|
|
529
305
|
const resolved = graph.streamLimits ?? DEFAULT_RESOLVED_LIMITS;
|
|
530
306
|
return resolved.hasEnforceableToolCallArgLimit || resolved.maxDeltaEventsPerTurn > 0;
|
|
531
307
|
}
|
|
532
|
-
/** Leases a model attempt's generation: entries under it are exempt from
|
|
533
|
-
* the reset sweep until {@link releaseStreamLimitGeneration} runs from the
|
|
534
|
-
* attempt's `finally`. */
|
|
535
308
|
function registerActiveStreamLimitGeneration(graph, generationKey) {
|
|
536
309
|
(graph.activeStreamLimitGenerations ??= /* @__PURE__ */ new Set()).add(generationKey);
|
|
537
310
|
}
|
|
538
|
-
/** Ends an attempt's lease and deletes its accounting entries — the
|
|
539
|
-
* authoritative retirement point for attempt-scoped state. */
|
|
540
311
|
function releaseStreamLimitGeneration(graph, generationKey) {
|
|
541
312
|
graph.activeStreamLimitGenerations?.delete(generationKey);
|
|
542
313
|
deleteGenerationEntries(graph.streamedToolCallArgTallies, generationKey);
|
|
@@ -551,16 +322,6 @@ function isOwnedByActiveGeneration(key, activeGenerations) {
|
|
|
551
322
|
for (const generationKey of activeGenerations) if (key === generationKey || key.startsWith(`${generationKey}:`)) return true;
|
|
552
323
|
return false;
|
|
553
324
|
}
|
|
554
|
-
/**
|
|
555
|
-
* Deletes accounting entries older than the epoch that is ending, EXCEPT
|
|
556
|
-
* entries leased by a still-active attempt. Called by `resetValues` instead
|
|
557
|
-
* of clearing: producer loops of straggling attempts use the graph's maps
|
|
558
|
-
* directly and are not behind the consumer-only epoch gate, so a clear
|
|
559
|
-
* would hand a cancellation-ignoring provider a fresh allowance at every
|
|
560
|
-
* run start. Leased entries live until their attempt's `finally` releases
|
|
561
|
-
* them; unleased entries (direct callers with no attempt stamp) get one
|
|
562
|
-
* grace reset via their epoch tag.
|
|
563
|
-
*/
|
|
564
325
|
function sweepStaleStreamLimitEntries(entries, endingEpoch, activeGenerations) {
|
|
565
326
|
const hasActive = activeGenerations != null && activeGenerations.size > 0;
|
|
566
327
|
for (const [key, value] of entries) {
|
|
@@ -569,11 +330,6 @@ function sweepStaleStreamLimitEntries(entries, endingEpoch, activeGenerations) {
|
|
|
569
330
|
entries.delete(key);
|
|
570
331
|
}
|
|
571
332
|
}
|
|
572
|
-
/** Links a secondary representation of a wire chunk (e.g. a provider
|
|
573
|
-
* adapter's callback copy) to its canonical emission object, so claim
|
|
574
|
-
* accounting treats both as one emission even though their identities
|
|
575
|
-
* differ. Non-enumerable, so the link stays out of serialization and chunk
|
|
576
|
-
* merges. */
|
|
577
333
|
const STREAM_LIMIT_CANONICAL = Symbol("streamLimitCanonical");
|
|
578
334
|
function linkStreamLimitCanonical(copy, canonical) {
|
|
579
335
|
Object.defineProperty(copy, STREAM_LIMIT_CANONICAL, {
|
|
@@ -586,22 +342,6 @@ function canonicalChunk(chunk) {
|
|
|
586
342
|
const linked = chunk[STREAM_LIMIT_CANONICAL];
|
|
587
343
|
return typeof linked === "object" && linked != null ? linked : chunk;
|
|
588
344
|
}
|
|
589
|
-
/**
|
|
590
|
-
* Claims accounting ownership of one EMISSION of a wire chunk. LangChain can
|
|
591
|
-
* hand the same chunk object to the decoupled `streamEvents` handler
|
|
592
|
-
* (`consumer`) and to the dispatch loop (`producer`) in either order, and a
|
|
593
|
-
* streaming model may mutate and re-yield the same object across emissions —
|
|
594
|
-
* so dedup is a signed credit balance per object rather than a lifetime set.
|
|
595
|
-
* Each producer visit adds a credit, each consumer visit removes one, and a
|
|
596
|
-
* visit charges only when the other side has not already charged that
|
|
597
|
-
* emission (positive balance = producer ahead, negative = consumer ahead).
|
|
598
|
-
* Paths where only one side ever observes the chunk (summarization, local
|
|
599
|
-
* replay-skip) charge every visit, since their balance never crosses zero
|
|
600
|
-
* the other way. Balances are scoped by generation identity so parallel
|
|
601
|
-
* generations sharing one reused chunk object cannot cancel each other's
|
|
602
|
-
* charges. Non-object chunks cannot be identity-tracked and are always
|
|
603
|
-
* claimable.
|
|
604
|
-
*/
|
|
605
345
|
function claimStreamLimitCharge(graph, chunk, side, metadata) {
|
|
606
346
|
if (typeof chunk !== "object" || chunk == null) return true;
|
|
607
347
|
const emission = canonicalChunk(chunk);
|
|
@@ -620,16 +360,6 @@ function claimStreamLimitCharge(graph, chunk, side, metadata) {
|
|
|
620
360
|
byGeneration.set(generationKey, balance - 1);
|
|
621
361
|
return balance <= 0;
|
|
622
362
|
}
|
|
623
|
-
/**
|
|
624
|
-
* Synchronous producer-side accounting for wire chunks that would otherwise
|
|
625
|
-
* be judged only when the decoupled `streamEvents` reader catches up — or,
|
|
626
|
-
* on replay-skipped and summarization chunks, not at all. A lagging reader
|
|
627
|
-
* would let an oversized complete call return to LangGraph and reach
|
|
628
|
-
* `ToolNode` before the queued handler throws; charging in the producer
|
|
629
|
-
* loop keeps the breaker ahead of graph progression. Claim-based, so
|
|
630
|
-
* whichever of this path and the handler echo sees the chunk object first
|
|
631
|
-
* charges it and the other skips.
|
|
632
|
-
*/
|
|
633
363
|
function enforceStreamLimitsForWireChunk({ graph, metadata, chunk, side = "producer" }) {
|
|
634
364
|
if (!requiresStreamLimitAccounting(graph, chunk)) return;
|
|
635
365
|
if (!claimStreamLimitCharge(graph, chunk, side, metadata)) return;
|
|
@@ -637,10 +367,6 @@ function enforceStreamLimitsForWireChunk({ graph, metadata, chunk, side = "produ
|
|
|
637
367
|
graph,
|
|
638
368
|
metadata
|
|
639
369
|
});
|
|
640
|
-
/** Combined view computed first so the raw-chunk guard can correlate
|
|
641
|
-
* names from BOTH parsed and invalid calls in the same event; an unnamed
|
|
642
|
-
* raw chunk twinned with a named invalid call must select that tool's
|
|
643
|
-
* override, not the global cap. */
|
|
644
370
|
const completeCalls = combineCompleteToolCalls(chunk);
|
|
645
371
|
if (chunk.tool_call_chunks != null && chunk.tool_call_chunks.length > 0) enforceStreamedToolCallArgLimit({
|
|
646
372
|
graph,
|
|
@@ -649,21 +375,12 @@ function enforceStreamLimitsForWireChunk({ graph, metadata, chunk, side = "produ
|
|
|
649
375
|
responseMetadata: chunk.response_metadata,
|
|
650
376
|
parsedToolCalls: completeCalls
|
|
651
377
|
});
|
|
652
|
-
/** Judged whenever parsed calls are present, not only when raw chunks are
|
|
653
|
-
* absent: an adapter can pair an empty or partial raw chunk with a
|
|
654
|
-
* complete parsed call, and the standalone check is stateless so the
|
|
655
|
-
* common both-present case is not double-tallied. `invalid_tool_calls`
|
|
656
|
-
* are included — ToolNode processes and promotes them, and a malformed
|
|
657
|
-
* call streaming oversized arguments is the exact pathology this breaker
|
|
658
|
-
* exists to stop. */
|
|
659
378
|
if (completeCalls != null) enforceCompleteToolCallArgLimit({
|
|
660
379
|
graph,
|
|
661
380
|
metadata,
|
|
662
381
|
toolCalls: completeCalls
|
|
663
382
|
});
|
|
664
383
|
}
|
|
665
|
-
/** Combined view of a chunk's parsed and invalid complete calls, avoiding
|
|
666
|
-
* allocation on the common paths where one or both are absent. */
|
|
667
384
|
function combineCompleteToolCalls(chunk) {
|
|
668
385
|
const parsed = chunk.tool_calls;
|
|
669
386
|
const invalid = chunk.invalid_tool_calls;
|
|
@@ -673,12 +390,6 @@ function combineCompleteToolCalls(chunk) {
|
|
|
673
390
|
if (hasParsed) return parsed;
|
|
674
391
|
return hasInvalid ? invalid : void 0;
|
|
675
392
|
}
|
|
676
|
-
/**
|
|
677
|
-
* Counts streamed chunk events per model generation and throws once a single
|
|
678
|
-
* generation exceeds `maxDeltaEventsPerTurn`. Opt-in defense in depth for
|
|
679
|
-
* pathologies a byte cap cannot see, such as a provider stream looping on
|
|
680
|
-
* empty chunks. Zero cost while disabled.
|
|
681
|
-
*/
|
|
682
393
|
function enforceStreamDeltaEventLimit({ graph, metadata }) {
|
|
683
394
|
const limit = (graph.streamLimits ?? DEFAULT_RESOLVED_LIMITS).maxDeltaEventsPerTurn;
|
|
684
395
|
if (limit <= 0) return;
|