@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.
Files changed (1027) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +0 -356
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/agents/projection.cjs +0 -9
  4. package/dist/cjs/agents/projection.cjs.map +1 -1
  5. package/dist/cjs/common/constants.cjs +0 -26
  6. package/dist/cjs/common/constants.cjs.map +1 -1
  7. package/dist/cjs/common/enum.cjs +0 -85
  8. package/dist/cjs/common/enum.cjs.map +1 -1
  9. package/dist/cjs/events.cjs +0 -14
  10. package/dist/cjs/events.cjs.map +1 -1
  11. package/dist/cjs/graphs/Graph.cjs +1 -909
  12. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  13. package/dist/cjs/graphs/MultiAgentGraph.cjs +7 -272
  14. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  15. package/dist/cjs/graphs/applyGraphRuntimeConfig.cjs.map +1 -1
  16. package/dist/cjs/graphs/createGraph.cjs.map +1 -1
  17. package/dist/cjs/hitl/askUserQuestion.cjs +0 -53
  18. package/dist/cjs/hitl/askUserQuestion.cjs.map +1 -1
  19. package/dist/cjs/hitl/askUserQuestions.cjs +0 -20
  20. package/dist/cjs/hitl/askUserQuestions.cjs.map +1 -1
  21. package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs +0 -6
  22. package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs.map +1 -1
  23. package/dist/cjs/hooks/HookRegistry.cjs +0 -127
  24. package/dist/cjs/hooks/HookRegistry.cjs.map +1 -1
  25. package/dist/cjs/hooks/createToolPolicyHook.cjs +0 -38
  26. package/dist/cjs/hooks/createToolPolicyHook.cjs.map +1 -1
  27. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +0 -77
  28. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs.map +1 -1
  29. package/dist/cjs/hooks/executeHooks.cjs +0 -79
  30. package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
  31. package/dist/cjs/hooks/index.cjs +0 -16
  32. package/dist/cjs/hooks/index.cjs.map +1 -1
  33. package/dist/cjs/hooks/matchers.cjs +0 -104
  34. package/dist/cjs/hooks/matchers.cjs.map +1 -1
  35. package/dist/cjs/hooks/types.cjs +0 -8
  36. package/dist/cjs/hooks/types.cjs.map +1 -1
  37. package/dist/cjs/instrumentation.cjs +0 -14
  38. package/dist/cjs/instrumentation.cjs.map +1 -1
  39. package/dist/cjs/langfuse.cjs +0 -75
  40. package/dist/cjs/langfuse.cjs.map +1 -1
  41. package/dist/cjs/langfuseConfig.cjs.map +1 -1
  42. package/dist/cjs/langfuseRuntimeContext.cjs +0 -13
  43. package/dist/cjs/langfuseRuntimeContext.cjs.map +1 -1
  44. package/dist/cjs/langfuseRuntimeScope.cjs +0 -4
  45. package/dist/cjs/langfuseRuntimeScope.cjs.map +1 -1
  46. package/dist/cjs/langfuseSpanRegistry.cjs +0 -28
  47. package/dist/cjs/langfuseSpanRegistry.cjs.map +1 -1
  48. package/dist/cjs/langfuseToolOutputTracing.cjs +0 -3
  49. package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
  50. package/dist/cjs/langfuseTraceShaping.cjs +0 -74
  51. package/dist/cjs/langfuseTraceShaping.cjs.map +1 -1
  52. package/dist/cjs/llm/anthropic/index.cjs +0 -3
  53. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  54. package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
  55. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +1 -111
  56. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  57. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +0 -1
  58. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
  59. package/dist/cjs/llm/anthropic/utils/stream_events.cjs +0 -8
  60. package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -1
  61. package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -1
  62. package/dist/cjs/llm/bedrock/cachePoints.cjs.map +1 -1
  63. package/dist/cjs/llm/bedrock/index.cjs +1 -95
  64. package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
  65. package/dist/cjs/llm/bedrock/toolCache.cjs.map +1 -1
  66. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +0 -78
  67. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
  68. package/dist/cjs/llm/bedrock/utils/message_outputs.cjs +0 -24
  69. package/dist/cjs/llm/bedrock/utils/message_outputs.cjs.map +1 -1
  70. package/dist/cjs/llm/contextOverflowRecovery.cjs +0 -62
  71. package/dist/cjs/llm/contextOverflowRecovery.cjs.map +1 -1
  72. package/dist/cjs/llm/fake.cjs.map +1 -1
  73. package/dist/cjs/llm/google/index.cjs +2 -21
  74. package/dist/cjs/llm/google/index.cjs.map +1 -1
  75. package/dist/cjs/llm/google/utils/common.cjs +5 -35
  76. package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
  77. package/dist/cjs/llm/init.cjs +0 -9
  78. package/dist/cjs/llm/init.cjs.map +1 -1
  79. package/dist/cjs/llm/invoke.cjs +1 -270
  80. package/dist/cjs/llm/invoke.cjs.map +1 -1
  81. package/dist/cjs/llm/mistral/index.cjs.map +1 -1
  82. package/dist/cjs/llm/openai/index.cjs +0 -99
  83. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  84. package/dist/cjs/llm/openai/streamMetadata.cjs +0 -21
  85. package/dist/cjs/llm/openai/streamMetadata.cjs.map +1 -1
  86. package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
  87. package/dist/cjs/llm/openrouter/index.cjs +0 -1
  88. package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
  89. package/dist/cjs/llm/openrouter/toolCache.cjs +0 -6
  90. package/dist/cjs/llm/openrouter/toolCache.cjs.map +1 -1
  91. package/dist/cjs/llm/preempt.cjs +0 -75
  92. package/dist/cjs/llm/preempt.cjs.map +1 -1
  93. package/dist/cjs/llm/providers.cjs.map +1 -1
  94. package/dist/cjs/llm/request.cjs +0 -10
  95. package/dist/cjs/llm/request.cjs.map +1 -1
  96. package/dist/cjs/llm/stream/chunkAdapters.cjs +0 -62
  97. package/dist/cjs/llm/stream/chunkAdapters.cjs.map +1 -1
  98. package/dist/cjs/llm/stream/smoother.cjs +0 -58
  99. package/dist/cjs/llm/stream/smoother.cjs.map +1 -1
  100. package/dist/cjs/llm/streamLimits.cjs +4 -293
  101. package/dist/cjs/llm/streamLimits.cjs.map +1 -1
  102. package/dist/cjs/llm/truncation.cjs +0 -36
  103. package/dist/cjs/llm/truncation.cjs.map +1 -1
  104. package/dist/cjs/llm/vertexai/index.cjs +0 -330
  105. package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
  106. package/dist/cjs/messages/alternation.cjs +0 -43
  107. package/dist/cjs/messages/alternation.cjs.map +1 -1
  108. package/dist/cjs/messages/anthropicToolCache.cjs +0 -45
  109. package/dist/cjs/messages/anthropicToolCache.cjs.map +1 -1
  110. package/dist/cjs/messages/assistantPhase.cjs +0 -12
  111. package/dist/cjs/messages/assistantPhase.cjs.map +1 -1
  112. package/dist/cjs/messages/budget.cjs +0 -9
  113. package/dist/cjs/messages/budget.cjs.map +1 -1
  114. package/dist/cjs/messages/cache.cjs +0 -172
  115. package/dist/cjs/messages/cache.cjs.map +1 -1
  116. package/dist/cjs/messages/content.cjs +0 -9
  117. package/dist/cjs/messages/content.cjs.map +1 -1
  118. package/dist/cjs/messages/contextPruning.cjs +0 -15
  119. package/dist/cjs/messages/contextPruning.cjs.map +1 -1
  120. package/dist/cjs/messages/contextPruningSettings.cjs +0 -3
  121. package/dist/cjs/messages/contextPruningSettings.cjs.map +1 -1
  122. package/dist/cjs/messages/core.cjs +0 -48
  123. package/dist/cjs/messages/core.cjs.map +1 -1
  124. package/dist/cjs/messages/format.cjs +1 -345
  125. package/dist/cjs/messages/format.cjs.map +1 -1
  126. package/dist/cjs/messages/handoffCue.cjs +0 -36
  127. package/dist/cjs/messages/handoffCue.cjs.map +1 -1
  128. package/dist/cjs/messages/ids.cjs.map +1 -1
  129. package/dist/cjs/messages/injected.cjs +0 -33
  130. package/dist/cjs/messages/injected.cjs.map +1 -1
  131. package/dist/cjs/messages/langchain.cjs +0 -14
  132. package/dist/cjs/messages/langchain.cjs.map +1 -1
  133. package/dist/cjs/messages/prune.cjs +1 -184
  134. package/dist/cjs/messages/prune.cjs.map +1 -1
  135. package/dist/cjs/messages/recency.cjs +0 -32
  136. package/dist/cjs/messages/recency.cjs.map +1 -1
  137. package/dist/cjs/messages/reducer.cjs +0 -30
  138. package/dist/cjs/messages/reducer.cjs.map +1 -1
  139. package/dist/cjs/messages/tools.cjs +0 -14
  140. package/dist/cjs/messages/tools.cjs.map +1 -1
  141. package/dist/cjs/openai/index.cjs.map +1 -1
  142. package/dist/cjs/prompts/activityLabel.cjs +9 -79
  143. package/dist/cjs/prompts/activityLabel.cjs.map +1 -1
  144. package/dist/cjs/responses/index.cjs.map +1 -1
  145. package/dist/cjs/run.cjs +2 -538
  146. package/dist/cjs/run.cjs.map +1 -1
  147. package/dist/cjs/session/AgentSession.cjs +1 -17
  148. package/dist/cjs/session/AgentSession.cjs.map +1 -1
  149. package/dist/cjs/session/JsonlSessionStore.cjs.map +1 -1
  150. package/dist/cjs/session/handlers.cjs +0 -7
  151. package/dist/cjs/session/handlers.cjs.map +1 -1
  152. package/dist/cjs/session/ids.cjs.map +1 -1
  153. package/dist/cjs/session/messageSerialization.cjs +0 -4
  154. package/dist/cjs/session/messageSerialization.cjs.map +1 -1
  155. package/dist/cjs/stream.cjs +1 -93
  156. package/dist/cjs/stream.cjs.map +1 -1
  157. package/dist/cjs/summarization/index.cjs +0 -27
  158. package/dist/cjs/summarization/index.cjs.map +1 -1
  159. package/dist/cjs/summarization/node.cjs +0 -273
  160. package/dist/cjs/summarization/node.cjs.map +1 -1
  161. package/dist/cjs/tools/BashExecutor.cjs +0 -35
  162. package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
  163. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +0 -24
  164. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
  165. package/dist/cjs/tools/Calculator.cjs.map +1 -1
  166. package/dist/cjs/tools/CodeExecutor.cjs +0 -13
  167. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
  168. package/dist/cjs/tools/CodeSessionFileSummary.cjs.map +1 -1
  169. package/dist/cjs/tools/ProgrammaticToolCalling.cjs +0 -101
  170. package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
  171. package/dist/cjs/tools/ReadFile.cjs.map +1 -1
  172. package/dist/cjs/tools/SkillTool.cjs +0 -5
  173. package/dist/cjs/tools/SkillTool.cjs.map +1 -1
  174. package/dist/cjs/tools/SubagentTool.cjs +0 -10
  175. package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
  176. package/dist/cjs/tools/ToolNode.cjs +6 -1038
  177. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  178. package/dist/cjs/tools/ToolSearch.cjs +0 -179
  179. package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
  180. package/dist/cjs/tools/cloudflare/CloudflareBridgeRuntime.cjs.map +1 -1
  181. package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs.map +1 -1
  182. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs +0 -39
  183. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs.map +1 -1
  184. package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs.map +1 -1
  185. package/dist/cjs/tools/eagerEventExecution.cjs +0 -6
  186. package/dist/cjs/tools/eagerEventExecution.cjs.map +1 -1
  187. package/dist/cjs/tools/handlers.cjs +1 -41
  188. package/dist/cjs/tools/handlers.cjs.map +1 -1
  189. package/dist/cjs/tools/intentArg.cjs +1 -132
  190. package/dist/cjs/tools/intentArg.cjs.map +1 -1
  191. package/dist/cjs/tools/local/CompileCheckTool.cjs +0 -25
  192. package/dist/cjs/tools/local/CompileCheckTool.cjs.map +1 -1
  193. package/dist/cjs/tools/local/FileCheckpointer.cjs +0 -23
  194. package/dist/cjs/tools/local/FileCheckpointer.cjs.map +1 -1
  195. package/dist/cjs/tools/local/LocalCodingTools.cjs +0 -80
  196. package/dist/cjs/tools/local/LocalCodingTools.cjs.map +1 -1
  197. package/dist/cjs/tools/local/LocalExecutionEngine.cjs +0 -126
  198. package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -1
  199. package/dist/cjs/tools/local/LocalExecutionTools.cjs.map +1 -1
  200. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +0 -12
  201. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
  202. package/dist/cjs/tools/local/attachments.cjs +0 -44
  203. package/dist/cjs/tools/local/attachments.cjs.map +1 -1
  204. package/dist/cjs/tools/local/bashAst.cjs +0 -16
  205. package/dist/cjs/tools/local/bashAst.cjs.map +1 -1
  206. package/dist/cjs/tools/local/editStrategies.cjs +0 -14
  207. package/dist/cjs/tools/local/editStrategies.cjs.map +1 -1
  208. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
  209. package/dist/cjs/tools/local/syntaxCheck.cjs +0 -31
  210. package/dist/cjs/tools/local/syntaxCheck.cjs.map +1 -1
  211. package/dist/cjs/tools/local/textEncoding.cjs +0 -11
  212. package/dist/cjs/tools/local/textEncoding.cjs.map +1 -1
  213. package/dist/cjs/tools/local/workspaceFS.cjs +0 -33
  214. package/dist/cjs/tools/local/workspaceFS.cjs.map +1 -1
  215. package/dist/cjs/tools/ptcTimeout.cjs.map +1 -1
  216. package/dist/cjs/tools/schema.cjs +0 -8
  217. package/dist/cjs/tools/schema.cjs.map +1 -1
  218. package/dist/cjs/tools/search/anthropic.cjs +0 -9
  219. package/dist/cjs/tools/search/anthropic.cjs.map +1 -1
  220. package/dist/cjs/tools/search/content.cjs.map +1 -1
  221. package/dist/cjs/tools/search/crw-scraper.cjs +0 -33
  222. package/dist/cjs/tools/search/crw-scraper.cjs.map +1 -1
  223. package/dist/cjs/tools/search/crw-search.cjs +0 -2
  224. package/dist/cjs/tools/search/crw-search.cjs.map +1 -1
  225. package/dist/cjs/tools/search/firecrawl.cjs +0 -25
  226. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
  227. package/dist/cjs/tools/search/format.cjs +0 -30
  228. package/dist/cjs/tools/search/format.cjs.map +1 -1
  229. package/dist/cjs/tools/search/highlights.cjs +0 -16
  230. package/dist/cjs/tools/search/highlights.cjs.map +1 -1
  231. package/dist/cjs/tools/search/keenable-scraper.cjs +0 -8
  232. package/dist/cjs/tools/search/keenable-scraper.cjs.map +1 -1
  233. package/dist/cjs/tools/search/keenable-search.cjs +0 -7
  234. package/dist/cjs/tools/search/keenable-search.cjs.map +1 -1
  235. package/dist/cjs/tools/search/rerankers.cjs +0 -35
  236. package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
  237. package/dist/cjs/tools/search/schema.cjs +0 -1
  238. package/dist/cjs/tools/search/schema.cjs.map +1 -1
  239. package/dist/cjs/tools/search/search.cjs +1 -14
  240. package/dist/cjs/tools/search/search.cjs.map +1 -1
  241. package/dist/cjs/tools/search/serper-scraper.cjs +0 -46
  242. package/dist/cjs/tools/search/serper-scraper.cjs.map +1 -1
  243. package/dist/cjs/tools/search/tavily-scraper.cjs.map +1 -1
  244. package/dist/cjs/tools/search/tavily-search.cjs.map +1 -1
  245. package/dist/cjs/tools/search/tool.cjs +0 -25
  246. package/dist/cjs/tools/search/tool.cjs.map +1 -1
  247. package/dist/cjs/tools/search/utils.cjs +0 -8
  248. package/dist/cjs/tools/search/utils.cjs.map +1 -1
  249. package/dist/cjs/tools/skillCatalog.cjs +0 -6
  250. package/dist/cjs/tools/skillCatalog.cjs.map +1 -1
  251. package/dist/cjs/tools/streamedToolCallSeals.cjs +0 -6
  252. package/dist/cjs/tools/streamedToolCallSeals.cjs.map +1 -1
  253. package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs +0 -2
  254. package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -1
  255. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +3 -213
  256. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
  257. package/dist/cjs/tools/subagent/SubagentReplay.cjs.map +1 -1
  258. package/dist/cjs/tools/subagent/childGraphConfig.cjs +0 -4
  259. package/dist/cjs/tools/subagent/childGraphConfig.cjs.map +1 -1
  260. package/dist/cjs/tools/subagent/runtimeLimits.cjs.map +1 -1
  261. package/dist/cjs/tools/toolOutputReferences.cjs +1 -322
  262. package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -1
  263. package/dist/cjs/types/hitl.cjs +0 -5
  264. package/dist/cjs/types/hitl.cjs.map +1 -1
  265. package/dist/cjs/utils/callbacks.cjs.map +1 -1
  266. package/dist/cjs/utils/errors.cjs +14 -165
  267. package/dist/cjs/utils/errors.cjs.map +1 -1
  268. package/dist/cjs/utils/events.cjs +0 -10
  269. package/dist/cjs/utils/events.cjs.map +1 -1
  270. package/dist/cjs/utils/graph.cjs.map +1 -1
  271. package/dist/cjs/utils/handlers.cjs +0 -3
  272. package/dist/cjs/utils/handlers.cjs.map +1 -1
  273. package/dist/cjs/utils/llm.cjs +0 -1
  274. package/dist/cjs/utils/llm.cjs.map +1 -1
  275. package/dist/cjs/utils/misc.cjs +0 -16
  276. package/dist/cjs/utils/misc.cjs.map +1 -1
  277. package/dist/cjs/utils/proxy.cjs +0 -26
  278. package/dist/cjs/utils/proxy.cjs.map +1 -1
  279. package/dist/cjs/utils/run.cjs +0 -6
  280. package/dist/cjs/utils/run.cjs.map +1 -1
  281. package/dist/cjs/utils/schema.cjs +0 -5
  282. package/dist/cjs/utils/schema.cjs.map +1 -1
  283. package/dist/cjs/utils/title.cjs +0 -6
  284. package/dist/cjs/utils/title.cjs.map +1 -1
  285. package/dist/cjs/utils/tokens.cjs +0 -113
  286. package/dist/cjs/utils/tokens.cjs.map +1 -1
  287. package/dist/cjs/utils/toolContent.cjs +0 -41
  288. package/dist/cjs/utils/toolContent.cjs.map +1 -1
  289. package/dist/cjs/utils/truncation.cjs +0 -61
  290. package/dist/cjs/utils/truncation.cjs.map +1 -1
  291. package/dist/esm/agents/AgentContext.mjs +0 -356
  292. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  293. package/dist/esm/agents/projection.mjs +0 -9
  294. package/dist/esm/agents/projection.mjs.map +1 -1
  295. package/dist/esm/common/constants.mjs +0 -26
  296. package/dist/esm/common/constants.mjs.map +1 -1
  297. package/dist/esm/common/enum.mjs +0 -85
  298. package/dist/esm/common/enum.mjs.map +1 -1
  299. package/dist/esm/events.mjs +0 -14
  300. package/dist/esm/events.mjs.map +1 -1
  301. package/dist/esm/graphs/Graph.mjs +1 -909
  302. package/dist/esm/graphs/Graph.mjs.map +1 -1
  303. package/dist/esm/graphs/MultiAgentGraph.mjs +7 -272
  304. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  305. package/dist/esm/graphs/applyGraphRuntimeConfig.mjs.map +1 -1
  306. package/dist/esm/graphs/createGraph.mjs.map +1 -1
  307. package/dist/esm/hitl/askUserQuestion.mjs +0 -53
  308. package/dist/esm/hitl/askUserQuestion.mjs.map +1 -1
  309. package/dist/esm/hitl/askUserQuestions.mjs +0 -20
  310. package/dist/esm/hitl/askUserQuestions.mjs.map +1 -1
  311. package/dist/esm/hitl/askUserQuestionsInterrupt.mjs +0 -6
  312. package/dist/esm/hitl/askUserQuestionsInterrupt.mjs.map +1 -1
  313. package/dist/esm/hooks/HookRegistry.mjs +0 -127
  314. package/dist/esm/hooks/HookRegistry.mjs.map +1 -1
  315. package/dist/esm/hooks/createToolPolicyHook.mjs +0 -38
  316. package/dist/esm/hooks/createToolPolicyHook.mjs.map +1 -1
  317. package/dist/esm/hooks/createWorkspacePolicyHook.mjs +0 -77
  318. package/dist/esm/hooks/createWorkspacePolicyHook.mjs.map +1 -1
  319. package/dist/esm/hooks/executeHooks.mjs +0 -79
  320. package/dist/esm/hooks/executeHooks.mjs.map +1 -1
  321. package/dist/esm/hooks/index.mjs +0 -16
  322. package/dist/esm/hooks/index.mjs.map +1 -1
  323. package/dist/esm/hooks/matchers.mjs +0 -104
  324. package/dist/esm/hooks/matchers.mjs.map +1 -1
  325. package/dist/esm/hooks/types.mjs +0 -8
  326. package/dist/esm/hooks/types.mjs.map +1 -1
  327. package/dist/esm/instrumentation.mjs +0 -14
  328. package/dist/esm/instrumentation.mjs.map +1 -1
  329. package/dist/esm/langfuse.mjs +0 -75
  330. package/dist/esm/langfuse.mjs.map +1 -1
  331. package/dist/esm/langfuseConfig.mjs.map +1 -1
  332. package/dist/esm/langfuseRuntimeContext.mjs +0 -13
  333. package/dist/esm/langfuseRuntimeContext.mjs.map +1 -1
  334. package/dist/esm/langfuseRuntimeScope.mjs +0 -4
  335. package/dist/esm/langfuseRuntimeScope.mjs.map +1 -1
  336. package/dist/esm/langfuseSpanRegistry.mjs +0 -28
  337. package/dist/esm/langfuseSpanRegistry.mjs.map +1 -1
  338. package/dist/esm/langfuseToolOutputTracing.mjs +0 -3
  339. package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
  340. package/dist/esm/langfuseTraceShaping.mjs +0 -74
  341. package/dist/esm/langfuseTraceShaping.mjs.map +1 -1
  342. package/dist/esm/llm/anthropic/index.mjs +0 -3
  343. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  344. package/dist/esm/llm/anthropic/types.mjs.map +1 -1
  345. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +1 -111
  346. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  347. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +0 -1
  348. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
  349. package/dist/esm/llm/anthropic/utils/stream_events.mjs +0 -8
  350. package/dist/esm/llm/anthropic/utils/stream_events.mjs.map +1 -1
  351. package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -1
  352. package/dist/esm/llm/bedrock/cachePoints.mjs.map +1 -1
  353. package/dist/esm/llm/bedrock/index.mjs +1 -95
  354. package/dist/esm/llm/bedrock/index.mjs.map +1 -1
  355. package/dist/esm/llm/bedrock/toolCache.mjs.map +1 -1
  356. package/dist/esm/llm/bedrock/utils/message_inputs.mjs +0 -78
  357. package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
  358. package/dist/esm/llm/bedrock/utils/message_outputs.mjs +0 -24
  359. package/dist/esm/llm/bedrock/utils/message_outputs.mjs.map +1 -1
  360. package/dist/esm/llm/contextOverflowRecovery.mjs +0 -62
  361. package/dist/esm/llm/contextOverflowRecovery.mjs.map +1 -1
  362. package/dist/esm/llm/fake.mjs.map +1 -1
  363. package/dist/esm/llm/google/index.mjs +2 -21
  364. package/dist/esm/llm/google/index.mjs.map +1 -1
  365. package/dist/esm/llm/google/utils/common.mjs +5 -35
  366. package/dist/esm/llm/google/utils/common.mjs.map +1 -1
  367. package/dist/esm/llm/init.mjs +0 -9
  368. package/dist/esm/llm/init.mjs.map +1 -1
  369. package/dist/esm/llm/invoke.mjs +1 -270
  370. package/dist/esm/llm/invoke.mjs.map +1 -1
  371. package/dist/esm/llm/mistral/index.mjs.map +1 -1
  372. package/dist/esm/llm/openai/index.mjs +0 -99
  373. package/dist/esm/llm/openai/index.mjs.map +1 -1
  374. package/dist/esm/llm/openai/streamMetadata.mjs +0 -21
  375. package/dist/esm/llm/openai/streamMetadata.mjs.map +1 -1
  376. package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
  377. package/dist/esm/llm/openrouter/index.mjs +0 -1
  378. package/dist/esm/llm/openrouter/index.mjs.map +1 -1
  379. package/dist/esm/llm/openrouter/toolCache.mjs +0 -6
  380. package/dist/esm/llm/openrouter/toolCache.mjs.map +1 -1
  381. package/dist/esm/llm/preempt.mjs +0 -75
  382. package/dist/esm/llm/preempt.mjs.map +1 -1
  383. package/dist/esm/llm/providers.mjs.map +1 -1
  384. package/dist/esm/llm/request.mjs +0 -10
  385. package/dist/esm/llm/request.mjs.map +1 -1
  386. package/dist/esm/llm/stream/chunkAdapters.mjs +0 -62
  387. package/dist/esm/llm/stream/chunkAdapters.mjs.map +1 -1
  388. package/dist/esm/llm/stream/smoother.mjs +0 -58
  389. package/dist/esm/llm/stream/smoother.mjs.map +1 -1
  390. package/dist/esm/llm/streamLimits.mjs +4 -293
  391. package/dist/esm/llm/streamLimits.mjs.map +1 -1
  392. package/dist/esm/llm/truncation.mjs +0 -36
  393. package/dist/esm/llm/truncation.mjs.map +1 -1
  394. package/dist/esm/llm/vertexai/index.mjs +0 -330
  395. package/dist/esm/llm/vertexai/index.mjs.map +1 -1
  396. package/dist/esm/messages/alternation.mjs +0 -43
  397. package/dist/esm/messages/alternation.mjs.map +1 -1
  398. package/dist/esm/messages/anthropicToolCache.mjs +0 -45
  399. package/dist/esm/messages/anthropicToolCache.mjs.map +1 -1
  400. package/dist/esm/messages/assistantPhase.mjs +0 -12
  401. package/dist/esm/messages/assistantPhase.mjs.map +1 -1
  402. package/dist/esm/messages/budget.mjs +0 -9
  403. package/dist/esm/messages/budget.mjs.map +1 -1
  404. package/dist/esm/messages/cache.mjs +0 -172
  405. package/dist/esm/messages/cache.mjs.map +1 -1
  406. package/dist/esm/messages/content.mjs +0 -9
  407. package/dist/esm/messages/content.mjs.map +1 -1
  408. package/dist/esm/messages/contextPruning.mjs +0 -15
  409. package/dist/esm/messages/contextPruning.mjs.map +1 -1
  410. package/dist/esm/messages/contextPruningSettings.mjs +0 -3
  411. package/dist/esm/messages/contextPruningSettings.mjs.map +1 -1
  412. package/dist/esm/messages/core.mjs +0 -48
  413. package/dist/esm/messages/core.mjs.map +1 -1
  414. package/dist/esm/messages/format.mjs +1 -345
  415. package/dist/esm/messages/format.mjs.map +1 -1
  416. package/dist/esm/messages/handoffCue.mjs +0 -36
  417. package/dist/esm/messages/handoffCue.mjs.map +1 -1
  418. package/dist/esm/messages/ids.mjs.map +1 -1
  419. package/dist/esm/messages/injected.mjs +0 -33
  420. package/dist/esm/messages/injected.mjs.map +1 -1
  421. package/dist/esm/messages/langchain.mjs +0 -14
  422. package/dist/esm/messages/langchain.mjs.map +1 -1
  423. package/dist/esm/messages/prune.mjs +1 -184
  424. package/dist/esm/messages/prune.mjs.map +1 -1
  425. package/dist/esm/messages/recency.mjs +0 -32
  426. package/dist/esm/messages/recency.mjs.map +1 -1
  427. package/dist/esm/messages/reducer.mjs +0 -30
  428. package/dist/esm/messages/reducer.mjs.map +1 -1
  429. package/dist/esm/messages/tools.mjs +0 -14
  430. package/dist/esm/messages/tools.mjs.map +1 -1
  431. package/dist/esm/openai/index.mjs.map +1 -1
  432. package/dist/esm/prompts/activityLabel.mjs +9 -79
  433. package/dist/esm/prompts/activityLabel.mjs.map +1 -1
  434. package/dist/esm/responses/index.mjs.map +1 -1
  435. package/dist/esm/run.mjs +2 -538
  436. package/dist/esm/run.mjs.map +1 -1
  437. package/dist/esm/session/AgentSession.mjs +1 -17
  438. package/dist/esm/session/AgentSession.mjs.map +1 -1
  439. package/dist/esm/session/JsonlSessionStore.mjs.map +1 -1
  440. package/dist/esm/session/handlers.mjs +0 -7
  441. package/dist/esm/session/handlers.mjs.map +1 -1
  442. package/dist/esm/session/ids.mjs.map +1 -1
  443. package/dist/esm/session/messageSerialization.mjs +0 -4
  444. package/dist/esm/session/messageSerialization.mjs.map +1 -1
  445. package/dist/esm/stream.mjs +1 -93
  446. package/dist/esm/stream.mjs.map +1 -1
  447. package/dist/esm/summarization/index.mjs +0 -27
  448. package/dist/esm/summarization/index.mjs.map +1 -1
  449. package/dist/esm/summarization/node.mjs +0 -273
  450. package/dist/esm/summarization/node.mjs.map +1 -1
  451. package/dist/esm/tools/BashExecutor.mjs +0 -35
  452. package/dist/esm/tools/BashExecutor.mjs.map +1 -1
  453. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +0 -24
  454. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
  455. package/dist/esm/tools/Calculator.mjs.map +1 -1
  456. package/dist/esm/tools/CodeExecutor.mjs +0 -13
  457. package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
  458. package/dist/esm/tools/CodeSessionFileSummary.mjs.map +1 -1
  459. package/dist/esm/tools/ProgrammaticToolCalling.mjs +0 -101
  460. package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
  461. package/dist/esm/tools/ReadFile.mjs.map +1 -1
  462. package/dist/esm/tools/SkillTool.mjs +0 -5
  463. package/dist/esm/tools/SkillTool.mjs.map +1 -1
  464. package/dist/esm/tools/SubagentTool.mjs +0 -10
  465. package/dist/esm/tools/SubagentTool.mjs.map +1 -1
  466. package/dist/esm/tools/ToolNode.mjs +6 -1038
  467. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  468. package/dist/esm/tools/ToolSearch.mjs +0 -179
  469. package/dist/esm/tools/ToolSearch.mjs.map +1 -1
  470. package/dist/esm/tools/cloudflare/CloudflareBridgeRuntime.mjs.map +1 -1
  471. package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs.map +1 -1
  472. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs +0 -39
  473. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs.map +1 -1
  474. package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs.map +1 -1
  475. package/dist/esm/tools/eagerEventExecution.mjs +0 -6
  476. package/dist/esm/tools/eagerEventExecution.mjs.map +1 -1
  477. package/dist/esm/tools/handlers.mjs +1 -41
  478. package/dist/esm/tools/handlers.mjs.map +1 -1
  479. package/dist/esm/tools/intentArg.mjs +1 -132
  480. package/dist/esm/tools/intentArg.mjs.map +1 -1
  481. package/dist/esm/tools/local/CompileCheckTool.mjs +0 -25
  482. package/dist/esm/tools/local/CompileCheckTool.mjs.map +1 -1
  483. package/dist/esm/tools/local/FileCheckpointer.mjs +0 -23
  484. package/dist/esm/tools/local/FileCheckpointer.mjs.map +1 -1
  485. package/dist/esm/tools/local/LocalCodingTools.mjs +0 -80
  486. package/dist/esm/tools/local/LocalCodingTools.mjs.map +1 -1
  487. package/dist/esm/tools/local/LocalExecutionEngine.mjs +0 -126
  488. package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -1
  489. package/dist/esm/tools/local/LocalExecutionTools.mjs.map +1 -1
  490. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +0 -12
  491. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
  492. package/dist/esm/tools/local/attachments.mjs +0 -44
  493. package/dist/esm/tools/local/attachments.mjs.map +1 -1
  494. package/dist/esm/tools/local/bashAst.mjs +0 -16
  495. package/dist/esm/tools/local/bashAst.mjs.map +1 -1
  496. package/dist/esm/tools/local/editStrategies.mjs +0 -14
  497. package/dist/esm/tools/local/editStrategies.mjs.map +1 -1
  498. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
  499. package/dist/esm/tools/local/syntaxCheck.mjs +0 -31
  500. package/dist/esm/tools/local/syntaxCheck.mjs.map +1 -1
  501. package/dist/esm/tools/local/textEncoding.mjs +0 -11
  502. package/dist/esm/tools/local/textEncoding.mjs.map +1 -1
  503. package/dist/esm/tools/local/workspaceFS.mjs +0 -33
  504. package/dist/esm/tools/local/workspaceFS.mjs.map +1 -1
  505. package/dist/esm/tools/ptcTimeout.mjs.map +1 -1
  506. package/dist/esm/tools/schema.mjs +0 -8
  507. package/dist/esm/tools/schema.mjs.map +1 -1
  508. package/dist/esm/tools/search/anthropic.mjs +0 -9
  509. package/dist/esm/tools/search/anthropic.mjs.map +1 -1
  510. package/dist/esm/tools/search/content.mjs.map +1 -1
  511. package/dist/esm/tools/search/crw-scraper.mjs +0 -33
  512. package/dist/esm/tools/search/crw-scraper.mjs.map +1 -1
  513. package/dist/esm/tools/search/crw-search.mjs +0 -2
  514. package/dist/esm/tools/search/crw-search.mjs.map +1 -1
  515. package/dist/esm/tools/search/firecrawl.mjs +0 -25
  516. package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
  517. package/dist/esm/tools/search/format.mjs +0 -30
  518. package/dist/esm/tools/search/format.mjs.map +1 -1
  519. package/dist/esm/tools/search/highlights.mjs +0 -16
  520. package/dist/esm/tools/search/highlights.mjs.map +1 -1
  521. package/dist/esm/tools/search/keenable-scraper.mjs +0 -8
  522. package/dist/esm/tools/search/keenable-scraper.mjs.map +1 -1
  523. package/dist/esm/tools/search/keenable-search.mjs +0 -7
  524. package/dist/esm/tools/search/keenable-search.mjs.map +1 -1
  525. package/dist/esm/tools/search/rerankers.mjs +0 -35
  526. package/dist/esm/tools/search/rerankers.mjs.map +1 -1
  527. package/dist/esm/tools/search/schema.mjs +0 -1
  528. package/dist/esm/tools/search/schema.mjs.map +1 -1
  529. package/dist/esm/tools/search/search.mjs +1 -14
  530. package/dist/esm/tools/search/search.mjs.map +1 -1
  531. package/dist/esm/tools/search/serper-scraper.mjs +0 -46
  532. package/dist/esm/tools/search/serper-scraper.mjs.map +1 -1
  533. package/dist/esm/tools/search/tavily-scraper.mjs.map +1 -1
  534. package/dist/esm/tools/search/tavily-search.mjs.map +1 -1
  535. package/dist/esm/tools/search/tool.mjs +0 -25
  536. package/dist/esm/tools/search/tool.mjs.map +1 -1
  537. package/dist/esm/tools/search/utils.mjs +0 -8
  538. package/dist/esm/tools/search/utils.mjs.map +1 -1
  539. package/dist/esm/tools/skillCatalog.mjs +0 -6
  540. package/dist/esm/tools/skillCatalog.mjs.map +1 -1
  541. package/dist/esm/tools/streamedToolCallSeals.mjs +0 -6
  542. package/dist/esm/tools/streamedToolCallSeals.mjs.map +1 -1
  543. package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs +0 -2
  544. package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -1
  545. package/dist/esm/tools/subagent/SubagentExecutor.mjs +3 -213
  546. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
  547. package/dist/esm/tools/subagent/SubagentReplay.mjs.map +1 -1
  548. package/dist/esm/tools/subagent/childGraphConfig.mjs +0 -4
  549. package/dist/esm/tools/subagent/childGraphConfig.mjs.map +1 -1
  550. package/dist/esm/tools/subagent/runtimeLimits.mjs.map +1 -1
  551. package/dist/esm/tools/toolOutputReferences.mjs +1 -322
  552. package/dist/esm/tools/toolOutputReferences.mjs.map +1 -1
  553. package/dist/esm/types/hitl.mjs +0 -5
  554. package/dist/esm/types/hitl.mjs.map +1 -1
  555. package/dist/esm/utils/callbacks.mjs.map +1 -1
  556. package/dist/esm/utils/errors.mjs +14 -165
  557. package/dist/esm/utils/errors.mjs.map +1 -1
  558. package/dist/esm/utils/events.mjs +0 -10
  559. package/dist/esm/utils/events.mjs.map +1 -1
  560. package/dist/esm/utils/graph.mjs.map +1 -1
  561. package/dist/esm/utils/handlers.mjs +0 -3
  562. package/dist/esm/utils/handlers.mjs.map +1 -1
  563. package/dist/esm/utils/llm.mjs +0 -1
  564. package/dist/esm/utils/llm.mjs.map +1 -1
  565. package/dist/esm/utils/misc.mjs +0 -16
  566. package/dist/esm/utils/misc.mjs.map +1 -1
  567. package/dist/esm/utils/proxy.mjs +0 -26
  568. package/dist/esm/utils/proxy.mjs.map +1 -1
  569. package/dist/esm/utils/run.mjs +0 -6
  570. package/dist/esm/utils/run.mjs.map +1 -1
  571. package/dist/esm/utils/schema.mjs +0 -5
  572. package/dist/esm/utils/schema.mjs.map +1 -1
  573. package/dist/esm/utils/title.mjs +0 -6
  574. package/dist/esm/utils/title.mjs.map +1 -1
  575. package/dist/esm/utils/tokens.mjs +0 -113
  576. package/dist/esm/utils/tokens.mjs.map +1 -1
  577. package/dist/esm/utils/toolContent.mjs +0 -41
  578. package/dist/esm/utils/toolContent.mjs.map +1 -1
  579. package/dist/esm/utils/truncation.mjs +0 -61
  580. package/dist/esm/utils/truncation.mjs.map +1 -1
  581. package/dist/types/agents/AgentContext.d.ts +3 -3
  582. package/dist/types/agents/__tests__/promptCacheLiveHelpers.d.ts +3 -3
  583. package/dist/types/agents/projection.d.ts +1 -1
  584. package/dist/types/events.d.ts +2 -2
  585. package/dist/types/graphs/Graph.d.ts +11 -11
  586. package/dist/types/graphs/MultiAgentGraph.d.ts +2 -2
  587. package/dist/types/graphs/createGraph.d.ts +4 -4
  588. package/dist/types/graphs/graphFactory.d.ts +1 -1
  589. package/dist/types/hitl/askUserQuestion.d.ts +1 -1
  590. package/dist/types/hitl/askUserQuestions.d.ts +1 -1
  591. package/dist/types/hitl/askUserQuestionsInterrupt.d.ts +1 -1
  592. package/dist/types/hooks/types.d.ts +1 -1
  593. package/dist/types/instrumentation.d.ts +1 -1
  594. package/dist/types/langfuse.d.ts +3 -3
  595. package/dist/types/langfuseConfig.d.ts +2 -2
  596. package/dist/types/langfuseRuntimeContext.d.ts +1 -1
  597. package/dist/types/langfuseRuntimeScope.d.ts +2 -2
  598. package/dist/types/langfuseSpanRegistry.d.ts +1 -1
  599. package/dist/types/langfuseToolOutputTracing.d.ts +3 -3
  600. package/dist/types/llm/anthropic/index.d.ts +1 -1
  601. package/dist/types/llm/bedrock/index.d.ts +1 -1
  602. package/dist/types/llm/bedrock/toolCache.d.ts +2 -2
  603. package/dist/types/llm/contextOverflowRecovery.d.ts +2 -2
  604. package/dist/types/llm/google/index.d.ts +1 -1
  605. package/dist/types/llm/init.d.ts +2 -2
  606. package/dist/types/llm/invoke.d.ts +6 -6
  607. package/dist/types/llm/mistral/index.d.ts +1 -1
  608. package/dist/types/llm/openai/index.d.ts +2 -2
  609. package/dist/types/llm/openrouter/index.d.ts +2 -2
  610. package/dist/types/llm/openrouter/toolCache.d.ts +2 -2
  611. package/dist/types/llm/providers.d.ts +2 -2
  612. package/dist/types/llm/request.d.ts +2 -2
  613. package/dist/types/llm/stream/chunkAdapters.d.ts +1 -1
  614. package/dist/types/llm/streamLimits.d.ts +1 -1
  615. package/dist/types/llm/truncation.d.ts +1 -1
  616. package/dist/types/llm/vertexai/index.d.ts +1 -1
  617. package/dist/types/messages/alternation.d.ts +1 -1
  618. package/dist/types/messages/anthropicToolCache.d.ts +2 -2
  619. package/dist/types/messages/assistantPhase.d.ts +3 -3
  620. package/dist/types/messages/budget.d.ts +1 -1
  621. package/dist/types/messages/cache.d.ts +1 -1
  622. package/dist/types/messages/contextPruning.d.ts +2 -2
  623. package/dist/types/messages/core.d.ts +2 -2
  624. package/dist/types/messages/format.d.ts +2 -2
  625. package/dist/types/messages/ids.d.ts +2 -2
  626. package/dist/types/messages/injected.d.ts +1 -1
  627. package/dist/types/messages/langchain.d.ts +1 -1
  628. package/dist/types/messages/prune.d.ts +3 -3
  629. package/dist/types/openai/index.d.ts +1 -1
  630. package/dist/types/prompts/activityLabel.d.ts +2 -2
  631. package/dist/types/responses/index.d.ts +1 -1
  632. package/dist/types/run.d.ts +3 -3
  633. package/dist/types/session/handlers.d.ts +1 -1
  634. package/dist/types/session/types.d.ts +1 -1
  635. package/dist/types/stream.d.ts +4 -4
  636. package/dist/types/summarization/index.d.ts +1 -1
  637. package/dist/types/summarization/node.d.ts +6 -6
  638. package/dist/types/test/mockTools.d.ts +1 -1
  639. package/dist/types/tools/BashExecutor.d.ts +2 -2
  640. package/dist/types/tools/BashProgrammaticToolCalling.d.ts +2 -2
  641. package/dist/types/tools/CodeExecutor.d.ts +3 -3
  642. package/dist/types/tools/CodeSessionFileSummary.d.ts +1 -1
  643. package/dist/types/tools/ProgrammaticToolCalling.d.ts +2 -2
  644. package/dist/types/tools/ReadFile.d.ts +1 -1
  645. package/dist/types/tools/SkillTool.d.ts +1 -1
  646. package/dist/types/tools/SubagentTool.d.ts +3 -3
  647. package/dist/types/tools/ToolNode.d.ts +5 -5
  648. package/dist/types/tools/ToolSearch.d.ts +2 -2
  649. package/dist/types/tools/cloudflare/CloudflareBridgeRuntime.d.ts +1 -1
  650. package/dist/types/tools/cloudflare/CloudflareProgrammaticToolCalling.d.ts +1 -1
  651. package/dist/types/tools/cloudflare/CloudflareSandboxExecutionEngine.d.ts +2 -2
  652. package/dist/types/tools/cloudflare/CloudflareSandboxTools.d.ts +1 -1
  653. package/dist/types/tools/eagerEventExecution.d.ts +1 -1
  654. package/dist/types/tools/handlers.d.ts +3 -3
  655. package/dist/types/tools/intentArg.d.ts +1 -1
  656. package/dist/types/tools/local/CompileCheckTool.d.ts +2 -2
  657. package/dist/types/tools/local/FileCheckpointer.d.ts +1 -1
  658. package/dist/types/tools/local/LocalCodingTools.d.ts +2 -2
  659. package/dist/types/tools/local/LocalExecutionEngine.d.ts +1 -1
  660. package/dist/types/tools/local/LocalExecutionTools.d.ts +1 -1
  661. package/dist/types/tools/local/LocalProgrammaticToolCalling.d.ts +1 -1
  662. package/dist/types/tools/local/bashAst.d.ts +1 -1
  663. package/dist/types/tools/local/resolveLocalExecutionTools.d.ts +1 -1
  664. package/dist/types/tools/local/syntaxCheck.d.ts +1 -1
  665. package/dist/types/tools/ptcTimeout.d.ts +1 -1
  666. package/dist/types/tools/schema.d.ts +1 -1
  667. package/dist/types/tools/search/anthropic.d.ts +1 -1
  668. package/dist/types/tools/skillCatalog.d.ts +1 -1
  669. package/dist/types/tools/subagent/SubagentExecutor.d.ts +5 -5
  670. package/dist/types/tools/subagent/SubagentReplay.d.ts +3 -3
  671. package/dist/types/tools/subagent/childGraphConfig.d.ts +2 -2
  672. package/dist/types/types/activityLabel.d.ts +3 -3
  673. package/dist/types/types/graph.d.ts +7 -7
  674. package/dist/types/types/llm.d.ts +9 -9
  675. package/dist/types/types/run.d.ts +7 -7
  676. package/dist/types/types/stream.d.ts +5 -5
  677. package/dist/types/types/summarize.d.ts +2 -2
  678. package/dist/types/types/tools.d.ts +5 -5
  679. package/dist/types/utils/__tests__/fixtures/contextOverflowSignatures.d.ts +1 -1
  680. package/dist/types/utils/errors.d.ts +1 -1
  681. package/dist/types/utils/events.d.ts +1 -1
  682. package/dist/types/utils/handlers.d.ts +3 -3
  683. package/dist/types/utils/llm.d.ts +1 -1
  684. package/dist/types/utils/llmConfig.d.ts +1 -1
  685. package/dist/types/utils/title.d.ts +1 -1
  686. package/package.json +10 -3
  687. package/src/llm/google/utils/common.ts +6 -4
  688. package/src/__tests__/stream.eagerArgsDivergence.test.ts +0 -911
  689. package/src/__tests__/stream.eagerEventExecution.test.ts +0 -5046
  690. package/src/__tests__/stream.streamLimits.test.ts +0 -1982
  691. package/src/agents/__tests__/AgentContext.anthropic.live.test.ts +0 -448
  692. package/src/agents/__tests__/AgentContext.bedrock.live.test.ts +0 -655
  693. package/src/agents/__tests__/AgentContext.openrouter.live.test.ts +0 -128
  694. package/src/agents/__tests__/AgentContext.overflow.test.ts +0 -205
  695. package/src/agents/__tests__/AgentContext.test.ts +0 -2425
  696. package/src/agents/__tests__/projection.test.ts +0 -73
  697. package/src/agents/__tests__/promptCacheLiveHelpers.ts +0 -175
  698. package/src/aggregator.test.ts +0 -1214
  699. package/src/graphs/__tests__/Graph.breakerLifecycle.test.ts +0 -273
  700. package/src/graphs/__tests__/Graph.closeRunStep.test.ts +0 -385
  701. package/src/graphs/__tests__/Graph.contextOverflow.test.ts +0 -1766
  702. package/src/graphs/__tests__/Graph.preemptSignal.test.ts +0 -126
  703. package/src/graphs/__tests__/Graph.reasoning.test.ts +0 -1717
  704. package/src/graphs/__tests__/Graph.subagentResumeState.test.ts +0 -80
  705. package/src/graphs/__tests__/MultiAgentGraph.test.ts +0 -177
  706. package/src/graphs/__tests__/composition.smoke.test.ts +0 -509
  707. package/src/graphs/__tests__/createGraph.test.ts +0 -206
  708. package/src/hooks/__tests__/HookRegistry.test.ts +0 -334
  709. package/src/hooks/__tests__/compactHooks.test.ts +0 -250
  710. package/src/hooks/__tests__/createToolPolicyHook.test.ts +0 -268
  711. package/src/hooks/__tests__/createWorkspacePolicyHook.test.ts +0 -405
  712. package/src/hooks/__tests__/executeHooks.test.ts +0 -1294
  713. package/src/hooks/__tests__/integration.test.ts +0 -337
  714. package/src/hooks/__tests__/matchers.test.ts +0 -238
  715. package/src/hooks/__tests__/preemptBoundary.test.ts +0 -152
  716. package/src/hooks/__tests__/toolHooks.test.ts +0 -669
  717. package/src/llm/__tests__/contextOverflowRecovery.test.ts +0 -401
  718. package/src/llm/__tests__/fallbackOverflow.test.ts +0 -287
  719. package/src/llm/anthropic/Jacob_Lee_Resume_2023.pdf +0 -0
  720. package/src/llm/anthropic/inherited-content-utils.spec.ts +0 -249
  721. package/src/llm/anthropic/inherited-stream-events.spec.ts +0 -1259
  722. package/src/llm/anthropic/inherited-strict.spec.ts +0 -302
  723. package/src/llm/anthropic/llm.spec.ts +0 -3394
  724. package/src/llm/anthropic/utils/cross-provider-reasoning.test.ts +0 -383
  725. package/src/llm/anthropic/utils/cross-provider-server-tools.test.ts +0 -110
  726. package/src/llm/anthropic/utils/server-tool-inputs.test.ts +0 -508
  727. package/src/llm/anthropic/utils/streaming-tool-input.test.ts +0 -361
  728. package/src/llm/anthropic/utils/stripPrefillCache.test.ts +0 -111
  729. package/src/llm/anthropic/utils/tool-id-normalization.test.ts +0 -287
  730. package/src/llm/bedrock/inherited-cache.spec.ts +0 -144
  731. package/src/llm/bedrock/inherited.spec.ts +0 -724
  732. package/src/llm/bedrock/llm.spec.ts +0 -1533
  733. package/src/llm/bedrock/streamSealDispatch.test.ts +0 -331
  734. package/src/llm/bedrock/toolCache.test.ts +0 -194
  735. package/src/llm/bedrock/utils/cross-provider-reasoning.test.ts +0 -131
  736. package/src/llm/bedrock/utils/cross-provider-server-tools.test.ts +0 -122
  737. package/src/llm/bedrock/utils/message_inputs.test.ts +0 -650
  738. package/src/llm/bedrock/utils/message_outputs.test.ts +0 -85
  739. package/src/llm/bedrock/utils/toolResultCachePoint.test.ts +0 -118
  740. package/src/llm/custom-chat-models.smoke.test.ts +0 -1966
  741. package/src/llm/google/data/gettysburg10.wav +0 -0
  742. package/src/llm/google/data/hotdog.jpg +0 -0
  743. package/src/llm/google/inherited-stream-events.spec.ts +0 -350
  744. package/src/llm/google/llm.spec.ts +0 -1388
  745. package/src/llm/google/streamSmoothing.test.ts +0 -121
  746. package/src/llm/google/utils/common.test.ts +0 -185
  747. package/src/llm/invoke.alternation.test.ts +0 -87
  748. package/src/llm/invoke.handoffCue.test.ts +0 -112
  749. package/src/llm/invoke.streamLimits.test.ts +0 -142
  750. package/src/llm/invoke.test.ts +0 -1198
  751. package/src/llm/mistral/streamSmoothing.test.ts +0 -97
  752. package/src/llm/openai/cacheWriteTokens.test.ts +0 -112
  753. package/src/llm/openai/contentBlocks.test.ts +0 -381
  754. package/src/llm/openai/deepseek.test.ts +0 -747
  755. package/src/llm/openai/inherited-deepseek.spec.ts +0 -347
  756. package/src/llm/openai/inherited-xai.spec.ts +0 -416
  757. package/src/llm/openai/llm.spec.ts +0 -1774
  758. package/src/llm/openai/managedRequests.test.ts +0 -182
  759. package/src/llm/openai/sequentialToolCallSeals.test.ts +0 -199
  760. package/src/llm/openai/streamMetadata.spec.ts +0 -86
  761. package/src/llm/openai/streamMetadataDedup.spec.ts +0 -166
  762. package/src/llm/openai/utils/isReasoningModel.test.ts +0 -90
  763. package/src/llm/openai/utils/messages.test.ts +0 -488
  764. package/src/llm/openrouter/reasoning.test.ts +0 -561
  765. package/src/llm/openrouter/toolCache.test.ts +0 -134
  766. package/src/llm/preempt.test.ts +0 -323
  767. package/src/llm/stream/chunkAdapters.test.ts +0 -202
  768. package/src/llm/stream/reassembly.test.ts +0 -241
  769. package/src/llm/stream/smoother.bench.test.ts +0 -155
  770. package/src/llm/stream/smoother.test.ts +0 -519
  771. package/src/llm/streamLimits.test.ts +0 -450
  772. package/src/llm/truncation.test.ts +0 -242
  773. package/src/llm/vertexai/fixThoughtSignatures.test.ts +0 -154
  774. package/src/llm/vertexai/inherited-stream-events.spec.ts +0 -271
  775. package/src/llm/vertexai/llm.spec.ts +0 -159
  776. package/src/llm/vertexai/repairUsageMetadata.test.ts +0 -54
  777. package/src/llm/vertexai/sealStreamedToolCalls.test.ts +0 -88
  778. package/src/llm/vertexai/streamSealDispatch.test.ts +0 -148
  779. package/src/llm/vertexai/streamSmoothing.test.ts +0 -109
  780. package/src/messages/__tests__/anthropicToolCache.test.ts +0 -339
  781. package/src/messages/__tests__/observationMasking.test.ts +0 -312
  782. package/src/messages/__tests__/recency.test.ts +0 -267
  783. package/src/messages/__tests__/tools.test.ts +0 -473
  784. package/src/messages/alternation.test.ts +0 -212
  785. package/src/messages/assistantPhase.test.ts +0 -75
  786. package/src/messages/cache.tail.test.ts +0 -533
  787. package/src/messages/cache.test.ts +0 -2166
  788. package/src/messages/content.test.ts +0 -362
  789. package/src/messages/contextPruning.test.ts +0 -184
  790. package/src/messages/ensureThinkingBlock.test.ts +0 -1427
  791. package/src/messages/foldToollessToolBlocks.test.ts +0 -596
  792. package/src/messages/formatAgentMessages.reducer.test.ts +0 -162
  793. package/src/messages/formatAgentMessages.skills.test.ts +0 -513
  794. package/src/messages/formatAgentMessages.steer.test.ts +0 -598
  795. package/src/messages/formatAgentMessages.test.ts +0 -8111
  796. package/src/messages/formatAgentMessages.tools.test.ts +0 -522
  797. package/src/messages/formatMessage.test.ts +0 -693
  798. package/src/messages/handoffCue.test.ts +0 -96
  799. package/src/messages/injected.test.ts +0 -107
  800. package/src/messages/labelContentByAgent.test.ts +0 -962
  801. package/src/messages/reducer.spec.ts +0 -32
  802. package/src/messages/shiftIndexTokenCountMap.test.ts +0 -81
  803. package/src/messages/tailCacheConversion.test.ts +0 -161
  804. package/src/openai/__tests__/openai.test.ts +0 -337
  805. package/src/responses/__tests__/responses.test.ts +0 -652
  806. package/src/scripts/abort.ts +0 -157
  807. package/src/scripts/activity-labels/captured.json +0 -56
  808. package/src/scripts/activity-labels/checks.cjs +0 -205
  809. package/src/scripts/activity-labels/corpus.cjs +0 -473
  810. package/src/scripts/activity-labels/report.cjs +0 -203
  811. package/src/scripts/activity-labels/rescore.cjs +0 -102
  812. package/src/scripts/activity-labels/run.ts +0 -705
  813. package/src/scripts/activity-labels/variants.ts +0 -71
  814. package/src/scripts/ant_web_search.ts +0 -159
  815. package/src/scripts/ant_web_search_edge_case.ts +0 -163
  816. package/src/scripts/ant_web_search_error_edge_case.ts +0 -149
  817. package/src/scripts/args.ts +0 -48
  818. package/src/scripts/bedrock-cache-debug.ts +0 -250
  819. package/src/scripts/bedrock-content-aggregation-test.ts +0 -266
  820. package/src/scripts/bedrock-merge-test.ts +0 -107
  821. package/src/scripts/bedrock-parallel-tools-test.ts +0 -204
  822. package/src/scripts/bench-prompt-cache.ts +0 -479
  823. package/src/scripts/caching.ts +0 -132
  824. package/src/scripts/cli.ts +0 -172
  825. package/src/scripts/cli2.ts +0 -133
  826. package/src/scripts/cli3.ts +0 -184
  827. package/src/scripts/cli4.ts +0 -191
  828. package/src/scripts/cli5.ts +0 -191
  829. package/src/scripts/code_exec.ts +0 -214
  830. package/src/scripts/code_exec_files.ts +0 -237
  831. package/src/scripts/code_exec_multi_session.ts +0 -237
  832. package/src/scripts/code_exec_ptc.ts +0 -335
  833. package/src/scripts/code_exec_session.ts +0 -283
  834. package/src/scripts/code_exec_simple.ts +0 -148
  835. package/src/scripts/compare_pi_vs_ours.ts +0 -1259
  836. package/src/scripts/content.ts +0 -139
  837. package/src/scripts/context-overflow-probe.ts +0 -997
  838. package/src/scripts/empty_input.ts +0 -137
  839. package/src/scripts/handoff-test.ts +0 -134
  840. package/src/scripts/local_engine.ts +0 -166
  841. package/src/scripts/local_engine_checkpointer.ts +0 -205
  842. package/src/scripts/local_engine_compile.ts +0 -263
  843. package/src/scripts/local_engine_hooks.ts +0 -226
  844. package/src/scripts/local_engine_image.ts +0 -201
  845. package/src/scripts/local_engine_ptc.ts +0 -151
  846. package/src/scripts/local_engine_workspace.ts +0 -258
  847. package/src/scripts/memory.ts +0 -107
  848. package/src/scripts/multi-agent-chain.ts +0 -332
  849. package/src/scripts/multi-agent-conditional.ts +0 -222
  850. package/src/scripts/multi-agent-document-review-chain.ts +0 -198
  851. package/src/scripts/multi-agent-hybrid-flow.ts +0 -311
  852. package/src/scripts/multi-agent-parallel-start.ts +0 -265
  853. package/src/scripts/multi-agent-parallel.ts +0 -395
  854. package/src/scripts/multi-agent-sequence.ts +0 -217
  855. package/src/scripts/multi-agent-subagent.ts +0 -246
  856. package/src/scripts/multi-agent-supervisor.ts +0 -366
  857. package/src/scripts/multi-agent-test.ts +0 -187
  858. package/src/scripts/openrouter_prompt_cache_live.ts +0 -310
  859. package/src/scripts/parallel-asymmetric-tools-test.ts +0 -275
  860. package/src/scripts/parallel-full-metadata-test.ts +0 -241
  861. package/src/scripts/parallel-tools-test.ts +0 -341
  862. package/src/scripts/preempt-probe.ts +0 -330
  863. package/src/scripts/preempt-scenarios.ts +0 -388
  864. package/src/scripts/programmatic_exec.ts +0 -387
  865. package/src/scripts/programmatic_exec_agent.ts +0 -232
  866. package/src/scripts/search.ts +0 -147
  867. package/src/scripts/sequential-full-metadata-test.ts +0 -198
  868. package/src/scripts/session_live.ts +0 -548
  869. package/src/scripts/simple.ts +0 -226
  870. package/src/scripts/single-agent-metadata-test.ts +0 -196
  871. package/src/scripts/stream.ts +0 -141
  872. package/src/scripts/subagent-configurable-inheritance.ts +0 -252
  873. package/src/scripts/subagent-event-driven-debug.ts +0 -190
  874. package/src/scripts/subagent-tools-debug.ts +0 -160
  875. package/src/scripts/subagent-usage-sink.ts +0 -176
  876. package/src/scripts/summarization-recency.ts +0 -462
  877. package/src/scripts/test-custom-prompt-key.ts +0 -145
  878. package/src/scripts/test-handoff-input.ts +0 -170
  879. package/src/scripts/test-handoff-preamble.ts +0 -278
  880. package/src/scripts/test-handoff-steering.ts +0 -430
  881. package/src/scripts/test-multi-agent-list-handoff.ts +0 -418
  882. package/src/scripts/test-parallel-agent-labeling.ts +0 -327
  883. package/src/scripts/test-parallel-handoffs.ts +0 -292
  884. package/src/scripts/test-thinking-handoff-bedrock.ts +0 -154
  885. package/src/scripts/test-thinking-handoff.ts +0 -156
  886. package/src/scripts/test-thinking-to-thinking-handoff-bedrock.ts +0 -166
  887. package/src/scripts/test-tool-before-handoff-role-order.ts +0 -276
  888. package/src/scripts/test-tools-before-handoff.ts +0 -222
  889. package/src/scripts/test_code_api.ts +0 -354
  890. package/src/scripts/thinking-bedrock.ts +0 -160
  891. package/src/scripts/thinking-vertexai.ts +0 -168
  892. package/src/scripts/thinking.ts +0 -172
  893. package/src/scripts/tool_search.ts +0 -153
  894. package/src/scripts/tools.ts +0 -163
  895. package/src/session/__tests__/JsonlSessionStore.test.ts +0 -1463
  896. package/src/session/__tests__/handlers.test.ts +0 -161
  897. package/src/specs/activity-label-observability.live.test.ts +0 -262
  898. package/src/specs/activity-label-observability.test.ts +0 -167
  899. package/src/specs/activity-label-prompt.test.ts +0 -359
  900. package/src/specs/activity-label-trace-seed.test.ts +0 -47
  901. package/src/specs/activity-phase-label.test.ts +0 -306
  902. package/src/specs/agent-handoffs.live.test.ts +0 -140
  903. package/src/specs/agent-handoffs.test.ts +0 -2465
  904. package/src/specs/anthropic.simple.test.ts +0 -453
  905. package/src/specs/ask-user-question-batch.test.ts +0 -289
  906. package/src/specs/ask-user-questions.live.test.ts +0 -185
  907. package/src/specs/ask-user-questions.test.ts +0 -293
  908. package/src/specs/azure.simple.test.ts +0 -502
  909. package/src/specs/bedrock-toolless.live.test.ts +0 -123
  910. package/src/specs/bedrock-truncation.live.test.ts +0 -191
  911. package/src/specs/cache.simple.test.ts +0 -416
  912. package/src/specs/context-accuracy.live.test.ts +0 -409
  913. package/src/specs/context-overflow-recovery.live.test.ts +0 -213
  914. package/src/specs/context-usage-event.test.ts +0 -117
  915. package/src/specs/context-usage.live.test.ts +0 -297
  916. package/src/specs/custom-event-await.test.ts +0 -304
  917. package/src/specs/deepseek.simple.test.ts +0 -290
  918. package/src/specs/deterministic-trace-id.test.ts +0 -43
  919. package/src/specs/discovered-tools.test.ts +0 -217
  920. package/src/specs/durability-checkpoint.integration.test.ts +0 -243
  921. package/src/specs/graph-subagent.live.test.ts +0 -242
  922. package/src/specs/graph-subagent.test.ts +0 -322
  923. package/src/specs/handoffCue.test.ts +0 -165
  924. package/src/specs/langfuse-callbacks.test.ts +0 -1578
  925. package/src/specs/langfuse-config.test.ts +0 -247
  926. package/src/specs/langfuse-instrumentation.test.ts +0 -393
  927. package/src/specs/langfuse-metadata.test.ts +0 -245
  928. package/src/specs/langfuse-routing.integration.test.ts +0 -844
  929. package/src/specs/langfuse-runtime-context.test.ts +0 -92
  930. package/src/specs/langfuse-span-registry.test.ts +0 -87
  931. package/src/specs/langfuse-tool-output-tracing.test.ts +0 -1858
  932. package/src/specs/langfuse-trace-shaping.test.ts +0 -591
  933. package/src/specs/moonshot.simple.test.ts +0 -367
  934. package/src/specs/multi-agent-summarization.test.ts +0 -396
  935. package/src/specs/openai.simple.test.ts +0 -315
  936. package/src/specs/openrouter.simple.test.ts +0 -275
  937. package/src/specs/preemptSeal.test.ts +0 -678
  938. package/src/specs/prune.test.ts +0 -3741
  939. package/src/specs/reasoning.test.ts +0 -201
  940. package/src/specs/run-step-timestamps.test.ts +0 -414
  941. package/src/specs/spec.utils.ts +0 -15
  942. package/src/specs/subagent.test.ts +0 -864
  943. package/src/specs/summarization-unit.test.ts +0 -973
  944. package/src/specs/summarization.test.ts +0 -3823
  945. package/src/specs/summarize-prune.test.ts +0 -376
  946. package/src/specs/thinking-handoff.test.ts +0 -621
  947. package/src/specs/thinking-prune.test.ts +0 -827
  948. package/src/specs/token-accounting-e2e.test.ts +0 -1034
  949. package/src/specs/token-accounting-pipeline.test.ts +0 -1008
  950. package/src/specs/token-distribution-edge-case.test.ts +0 -315
  951. package/src/specs/token-memoization.test.ts +0 -40
  952. package/src/specs/tokens.test.ts +0 -1000
  953. package/src/specs/tool-error-resume.test.ts +0 -194
  954. package/src/specs/tool-error.test.ts +0 -198
  955. package/src/specs/vllm-reasoning-toolcalls.test.ts +0 -340
  956. package/src/stream.dispatch.test.ts +0 -63
  957. package/src/stream.test.ts +0 -144
  958. package/src/summarization/__tests__/aggregator.test.ts +0 -236
  959. package/src/summarization/__tests__/node.test.ts +0 -1996
  960. package/src/summarization/__tests__/trigger.test.ts +0 -149
  961. package/src/summarization/chunkHandler.test.ts +0 -196
  962. package/src/test/mockTools.ts +0 -386
  963. package/src/tools/Calculator.test.ts +0 -278
  964. package/src/tools/__tests__/BashExecutor.test.ts +0 -108
  965. package/src/tools/__tests__/CloudflareSandboxExecution.test.ts +0 -939
  966. package/src/tools/__tests__/CodeApiAuthHeaders.test.ts +0 -858
  967. package/src/tools/__tests__/CodeExecutor.stateful.test.ts +0 -124
  968. package/src/tools/__tests__/LocalExecutionRoots.test.ts +0 -8
  969. package/src/tools/__tests__/LocalExecutionTools.test.ts +0 -2733
  970. package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +0 -318
  971. package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +0 -1557
  972. package/src/tools/__tests__/ReadFile.test.ts +0 -44
  973. package/src/tools/__tests__/SkillTool.test.ts +0 -442
  974. package/src/tools/__tests__/SubagentExecutor.test.ts +0 -3728
  975. package/src/tools/__tests__/SubagentReplay.test.ts +0 -329
  976. package/src/tools/__tests__/SubagentTool.test.ts +0 -149
  977. package/src/tools/__tests__/ToolNode.breakerSignal.test.ts +0 -595
  978. package/src/tools/__tests__/ToolNode.eagerEventExecution.test.ts +0 -1191
  979. package/src/tools/__tests__/ToolNode.invalidToolCalls.test.ts +0 -757
  980. package/src/tools/__tests__/ToolNode.langfuse.test.ts +0 -57
  981. package/src/tools/__tests__/ToolNode.onResultCompletion.test.ts +0 -736
  982. package/src/tools/__tests__/ToolNode.outputReferences.test.ts +0 -1710
  983. package/src/tools/__tests__/ToolNode.runtimeState.test.ts +0 -120
  984. package/src/tools/__tests__/ToolNode.session.test.ts +0 -1352
  985. package/src/tools/__tests__/ToolNode.streamLimits.test.ts +0 -69
  986. package/src/tools/__tests__/ToolSearch.integration.test.ts +0 -161
  987. package/src/tools/__tests__/ToolSearch.test.ts +0 -1227
  988. package/src/tools/__tests__/annotateMessagesForLLM.test.ts +0 -561
  989. package/src/tools/__tests__/directToolHITLResumeScope.test.ts +0 -980
  990. package/src/tools/__tests__/directToolHooks.test.ts +0 -700
  991. package/src/tools/__tests__/eagerEventExecution.session.test.ts +0 -92
  992. package/src/tools/__tests__/handlers.test.ts +0 -997
  993. package/src/tools/__tests__/hitl.test.ts +0 -4663
  994. package/src/tools/__tests__/intentArg.test.ts +0 -357
  995. package/src/tools/__tests__/intentCoverage.test.ts +0 -139
  996. package/src/tools/__tests__/localToolNames.test.ts +0 -75
  997. package/src/tools/__tests__/skillCatalog.test.ts +0 -161
  998. package/src/tools/__tests__/subagentHooks.test.ts +0 -1651
  999. package/src/tools/__tests__/toolOutputReferences.test.ts +0 -515
  1000. package/src/tools/__tests__/workspaceSeam.test.ts +0 -147
  1001. package/src/tools/local/__tests__/FileCheckpointer.test.ts +0 -162
  1002. package/src/tools/local/__tests__/editStrategies.test.ts +0 -134
  1003. package/src/tools/search/content.test.ts +0 -173
  1004. package/src/tools/search/crw.test.ts +0 -836
  1005. package/src/tools/search/format.test.ts +0 -242
  1006. package/src/tools/search/http-agent.test.ts +0 -133
  1007. package/src/tools/search/jina-reranker.test.ts +0 -306
  1008. package/src/tools/search/keenable-scraper.test.ts +0 -153
  1009. package/src/tools/search/keenable.test.ts +0 -183
  1010. package/src/tools/search/outcome.test.ts +0 -90
  1011. package/src/tools/search/output.md +0 -2775
  1012. package/src/tools/search/rag-api-reranker.test.ts +0 -891
  1013. package/src/tools/search/source-processing.test.ts +0 -516
  1014. package/src/tools/search/tavily.test.ts +0 -965
  1015. package/src/tools/search/test.html +0 -884
  1016. package/src/tools/search/test.md +0 -643
  1017. package/src/tools/subagent/__tests__/SubagentExecutionRegistry.test.ts +0 -637
  1018. package/src/tools/subagent/__tests__/SubagentExecutor.lazy.test.ts +0 -3054
  1019. package/src/tools/subagent/__tests__/childGraphConfig.test.ts +0 -521
  1020. package/src/utils/__tests__/apportion.test.ts +0 -32
  1021. package/src/utils/__tests__/errors.test.ts +0 -270
  1022. package/src/utils/__tests__/fixtures/contextOverflowSignatures.ts +0 -336
  1023. package/src/utils/__tests__/redactSecrets.test.ts +0 -56
  1024. package/src/utils/__tests__/truncation.test.ts +0 -66
  1025. package/src/utils/llm.test.ts +0 -18
  1026. package/src/utils/proxy.test.ts +0 -176
  1027. package/src/utils/toolContent.test.ts +0 -1432
@@ -24,8 +24,6 @@ import { Command, END, GraphInterrupt, Send, interrupt, isCommand, isGraphInterr
24
24
  import { AIMessage, HumanMessage, ToolMessage, isAIMessage, isBaseMessage } from "@langchain/core/messages";
25
25
  import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons";
26
26
  //#region src/tools/ToolNode.ts
27
- /** Host-facing batch requests must not carry the batch's breaker scope —
28
- * hosts spread `configurable` into their own run configs. */
29
27
  function stripRunBreakerScope(configurable) {
30
28
  if (configurable == null || !("lc_run_breaker_scope" in configurable)) return configurable;
31
29
  const { [RUN_BREAKER_SCOPE_CONFIG_KEY]: _scope, ...rest } = configurable;
@@ -63,12 +61,6 @@ function createToolErrorOwnership() {
63
61
  undispatched: /* @__PURE__ */ new Set()
64
62
  };
65
63
  }
66
- /**
67
- * Produces the provider preview and, when requested, the exact registry prefix
68
- * in one bounded traversal. String outputs already exist in memory when a tool
69
- * returns them; structured outputs must never be fully JSON-materialized before
70
- * either limit applies.
71
- */
72
64
  function serializeToolOutputWithinLimits(output, maxToolResultChars, registryPrefixChars = 0) {
73
65
  if (typeof output === "string") return {
74
66
  content: truncateToolResultContent(output, maxToolResultChars),
@@ -83,19 +75,12 @@ function serializeToolOutputWithinLimits(output, maxToolResultChars, registryPre
83
75
  const TOOL_NODE_RUN_NAME = "tool_batch";
84
76
  const NANOID_URL_ALPHABET = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
85
77
  const RUNTIME_HANDOFF_GROUP_OFFSET = 2 ** 48;
86
- /**
87
- * Helper to check if a value is a Send object
88
- */
89
78
  function isSend(value) {
90
79
  return value instanceof Send;
91
80
  }
92
81
  function isHandoffToolName(name) {
93
82
  return name.startsWith("lc_transfer_to_");
94
83
  }
95
- /**
96
- * Encodes 48 random bits from the persisted batch key into a safe integer.
97
- * The high offset keeps runtime groups disjoint from low, structural group IDs.
98
- */
99
84
  function getRuntimeHandoffGroupId(batch) {
100
85
  let value = 0;
101
86
  for (const char of batch.slice(0, 8)) {
@@ -114,13 +99,6 @@ function findHandoffMessage(messages, destination) {
114
99
  if (isStandardHandoff || isConditionalHandoff) return toolMessage;
115
100
  }
116
101
  }
117
- /**
118
- * Format a fail-closed diagnostic for malformed approval-decision
119
- * fields. Hosts deserialize resume payloads from untyped JSON, so
120
- * `responseText` and `updatedInput` can land here as anything; the
121
- * blocking ToolMessage carries this string so the host can debug the
122
- * exact wire shape that was rejected.
123
- */
124
102
  function describeOfferedShape(value) {
125
103
  if (value === void 0) return "<missing>";
126
104
  if (value === null) return "null";
@@ -146,13 +124,6 @@ function getAssistantBatchReplayKey(batch, runId, threadId) {
146
124
  batch.messageCount
147
125
  ]);
148
126
  }
149
- /**
150
- * Build the `tool_approval` interrupt payload from the set of pending
151
- * `ask`-decision entries collected during PreToolUse hook handling.
152
- * Pure function — doesn't touch ToolNode state — so it lives at module
153
- * scope. The interrupt itself is raised by the caller (which still
154
- * needs `interrupt()` plus the AsyncLocalStorage anchoring shim).
155
- */
156
127
  function buildToolApprovalInterruptPayload(askEntries, hookSessionId) {
157
128
  return {
158
129
  type: "tool_approval",
@@ -178,14 +149,6 @@ function buildToolApprovalInterruptPayload(askEntries, hookSessionId) {
178
149
  }))
179
150
  };
180
151
  }
181
- /**
182
- * Build a `tool_call_id → ToolApprovalDecision` map from the host's
183
- * resume value. Hosts may return decisions either as an array (one per
184
- * action_request, in order) or as a record keyed by `tool_call_id`. Any
185
- * unrecognized shape (or a decision missing for a given call id) is
186
- * treated as "no decision" by callers — typically rejected so the run
187
- * doesn't silently invoke a tool the human never approved.
188
- */
189
152
  function normalizeApprovalDecisions(callIds, resumeValue) {
190
153
  const map = /* @__PURE__ */ new Map();
191
154
  if (resumeValue == null) return map;
@@ -200,48 +163,6 @@ function normalizeApprovalDecisions(callIds, resumeValue) {
200
163
  }
201
164
  return map;
202
165
  }
203
- /**
204
- * Merges code execution session context into the sessions map.
205
- *
206
- * The codeapi worker reports two distinct ids on a code-execution result:
207
- * - `artifact.session_id` (the `sessionId` arg here) is the EXEC session
208
- * — the sandbox VM that ran the code. It's transient and torn down
209
- * post-execution; subsequent calls cannot reuse it as a sandbox.
210
- * - `file.storage_session_id` on each `artifact.files[i]` is the STORAGE
211
- * session — the file-server bucket prefix where the artifact actually
212
- * lives and is served from.
213
- *
214
- * Per-file `storage_session_id` is preserved (not overwritten with the
215
- * exec id) because `_injected_files` are looked up against the
216
- * file-server's storage path on subsequent tool calls. Stomping the
217
- * storage id with the exec id silently 404s every follow-up tool call
218
- * within the same run — `cat /mnt/data/foo.txt` reports "No such file
219
- * or directory" because the worker can't mount a file at a path the
220
- * storage doesn't know about. Fall back to the exec id only when the
221
- * per-file id is absent (e.g. inline `content` files have no persistent
222
- * storage location).
223
- */
224
- /**
225
- * Builds a `CodeEnvFile` ref from an arbitrary `FileRef`-like input,
226
- * narrowing onto the discriminated union: `kind: 'skill'` requires
227
- * `version`, other kinds forbid it.
228
- *
229
- * Defaults `kind` to `'user'` when unset — most ad-hoc files are
230
- * user-private; shared resources (skills/agents) populate their kind
231
- * upstream. A skill ref missing `version` falls back to `'user'` so
232
- * the upstream contract bug surfaces as a degraded sessionKey rather
233
- * than a runtime crash; primeSkillFiles is the only writer, and it
234
- * always sets `version` — see LC packages/api/src/agents/skillFiles.ts.
235
- *
236
- * `resource_id` carries the entity-that-owns-this-file's-session
237
- * identity (skill `_id` etc.); falls back to `id` (the storage
238
- * file_id) for inputs that haven't been updated to send the field
239
- * explicitly. The fallback degrades sessionKey resolution on the
240
- * codeapi side for shared kinds (it'll match the storage nanoid
241
- * against a skill _id and 403) — but won't crash, so an unmigrated
242
- * client still produces a diagnosable error instead of a stack
243
- * trace.
244
- */
245
166
  function toInjectedFileRef(file, execSessionId) {
246
167
  const base = {
247
168
  id: file.id,
@@ -314,121 +235,32 @@ var ToolNode = class extends RunnableCallable {
314
235
  agentLangfuse;
315
236
  toolCallStepIds;
316
237
  errorHandler;
317
- /**
318
- * Fallback error-completion ownership for calls that reach `runTool`
319
- * outside a batch context (direct `runTool` use in tests / embedders).
320
- * Batch-scoped ownership is threaded via `RunToolBatchContext` instead —
321
- * see {@link ToolErrorOwnership} for why per-invocation scoping matters.
322
- */
323
238
  looseErrorOwnership = createToolErrorOwnership();
324
239
  toolUsageCount;
325
- /** Maps toolCallId → turn captured in runTool, used by handleRunToolCompletions */
326
240
  toolCallTurns = /* @__PURE__ */ new Map();
327
- /**
328
- * `call.id → turn` map dedicated to the direct-path lifecycle so the
329
- * turn assigned on first entry is REUSED on LangGraph resume.
330
- * Distinct from `toolCallTurns` (which is cleared at the start of
331
- * every `run()` to keep per-batch event-dispatch metadata fresh) —
332
- * the direct path needs stability across re-entries triggered by
333
- * `interrupt()` resumes (Codex P2 #30). Cleared with the rest of
334
- * the per-Run state in `clearHeavyState`-equivalent flushes when
335
- * the Run ends.
336
- */
337
241
  directPathTurns = /* @__PURE__ */ new Map();
338
- /** Terminal results from interrupting siblings that must survive a
339
- * LangGraph replay of the containing ToolNode. Includes the sidecar data
340
- * the fresh batch needs for hook-context injection and completion events. */
341
242
  settledInterruptingResults = /* @__PURE__ */ new Map();
342
- /** Tool registry for filtering (lazy computation of programmatic maps) */
343
243
  toolRegistry;
344
- /** Cached programmatic tools (computed once on first PTC call) */
345
244
  programmaticCache;
346
- /** Reference to Graph's sessions map for automatic session injection */
347
245
  sessions;
348
- /** When true, dispatches ON_TOOL_EXECUTE events instead of invoking tools directly */
349
246
  eventDrivenMode = false;
350
- /** Opt-in stream-layer prestart config for event-driven tools. */
351
247
  eagerEventToolExecution;
352
- /** Host tools that write to the code sandbox and share its exec session. */
353
248
  codeSessionToolNames;
354
- /** Shared per-run prestarted tool registry populated by ChatModelStreamHandler. */
355
249
  eagerEventToolExecutions;
356
- /** Shared per-run per-tool turn counter used by eager and normal event dispatch. */
357
250
  eagerEventToolUsageCount;
358
- /**
359
- * Shared per-run eager prestart circuit breaker. Tool names added here
360
- * (when a prestarted execution's args mismatch the final request) are no
361
- * longer prestarted by the stream handler for the rest of the run.
362
- */
363
251
  eagerEventToolSuppressions;
364
- /** Agent ID for event-driven mode */
365
252
  agentId;
366
- /**
367
- * ID of the agent that owns this tool node, whenever the graph knows it
368
- * (including top-level agents in a multi-agent graph). Surfaced to hooks as
369
- * `executingAgentId` so they can attribute a tool batch to a specific agent
370
- * even where `agentId` (the subagent-scope marker) is undefined.
371
- */
372
253
  executingAgentId;
373
- /** Tool names that bypass event dispatch and execute directly (e.g., graph-managed handoff tools) */
374
254
  directToolNames;
375
- /**
376
- * Tool names whose in-process body may raise a LangGraph `interrupt()`
377
- * mid-execution (e.g. `ask_user_question`). Used only to REORDER within
378
- * the direct group: a tool named here that is *already* direct (a real
379
- * in-process graphTool — the only kind whose body can reach
380
- * `interrupt()`) is scheduled ahead of its non-interrupting direct
381
- * siblings, so a mid-body interrupt unwinds the ToolNode before a
382
- * non-idempotent sibling executes and LangGraph's resume-time batch
383
- * re-execution can't double it. This set is deliberately NOT folded
384
- * into direct classification: a name that resolves to a schema-only
385
- * event stub (an inherited `toolDefinition` with no executable
386
- * instance) stays event-dispatched — forcing it direct would invoke
387
- * the stub, which throws. See {@link t.ToolNodeOptions.interruptingToolNames}.
388
- */
389
255
  interruptingToolNames;
390
- /**
391
- * File checkpointer extracted from the local coding tool bundle when
392
- * `toolExecution.local.fileCheckpointing === true`. Exposed via
393
- * {@link getFileCheckpointer}. Undefined when checkpointing is off
394
- * or the local coding suite isn't bound to this node.
395
- */
396
256
  fileCheckpointer;
397
- /** Maximum characters allowed in a single tool result before truncation. */
398
257
  maxToolResultChars;
399
- /** Hook registry for PreToolUse/PostToolUse lifecycle hooks */
400
258
  hookRegistry;
401
- /**
402
- * Run-scoped HITL config. When `enabled`, `ask` decisions from
403
- * PreToolUse hooks raise a LangGraph `interrupt()` instead of being
404
- * treated as fail-closed denies.
405
- */
406
259
  humanInTheLoop;
407
- /**
408
- * Registry of tool outputs keyed by `tool<idx>turn<turn>`.
409
- *
410
- * Populated only when `toolOutputReferences.enabled` is true. The
411
- * registry owns the run-scoped state (turn counter, last-seen runId,
412
- * warn-once memo, stored outputs), so sharing a single instance
413
- * across multiple ToolNodes in a run lets cross-agent `{{…}}`
414
- * references resolve — which is why multi-agent graphs pass the
415
- * *same* instance to every ToolNode they compile rather than each
416
- * ToolNode building its own.
417
- */
418
260
  toolOutputRegistry;
419
- /** Run-scoped selection for swapping remote code tools to local executors. */
420
261
  toolExecution;
421
- /** Owning graph's run-scoped breaker signal, composed into each batch's config. */
422
262
  getBreakerSignal;
423
- /** Owning graph's immutable run scope; captured once per batch. */
424
263
  getRunScope;
425
- /**
426
- * Monotonic counter used to mint a unique scope id for anonymous
427
- * batches (ones invoked without a `run_id` in
428
- * `config.configurable`). Each such batch gets its own registry
429
- * partition so concurrent anonymous invocations can't delete each
430
- * other's in-flight state.
431
- */
432
264
  anonBatchCounter = 0;
433
265
  constructor({ tools, toolMap, name, tags, trace, runLangfuse, agentLangfuse, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, sessions, eventDrivenMode, eagerEventToolExecution, eagerEventToolExecutions, eagerEventToolUsageCount, eagerEventToolSuppressions, agentId, executingAgentId, directToolNames, interruptingToolNames, codeSessionToolNames, maxContextTokens, maxToolResultChars, hookRegistry, humanInTheLoop, toolOutputReferences, toolOutputRegistry, toolExecution, fileCheckpointer, getBreakerSignal, getRunScope }) {
434
266
  super({
@@ -468,17 +300,6 @@ var ToolNode = class extends RunnableCallable {
468
300
  this.getRunScope = getRunScope;
469
301
  this.fileCheckpointer = fileCheckpointer;
470
302
  this.applyToolExecutionOverrides();
471
- /**
472
- * Precedence: an explicitly passed `toolOutputRegistry` instance
473
- * wins over a config object so a host (`Graph`) can share one
474
- * registry across many ToolNodes. When only the config is
475
- * provided (direct ToolNode usage), build a local registry so
476
- * the feature still works without graph-level plumbing. Registry
477
- * caps are intentionally decoupled from `maxToolResultChars`:
478
- * the registry stores the raw untruncated output so a later
479
- * `{{…}}` substitution pipes the full payload into the next
480
- * tool, even when the LLM saw a truncated preview.
481
- */
482
303
  if (toolOutputRegistry != null) this.toolOutputRegistry = toolOutputRegistry;
483
304
  else if (toolOutputReferences?.enabled === true) this.toolOutputRegistry = new ToolOutputReferenceRegistry({
484
305
  maxOutputSize: toolOutputReferences.maxOutputSize,
@@ -499,24 +320,9 @@ var ToolNode = class extends RunnableCallable {
499
320
  agentId: this.executingAgentId
500
321
  }), () => super.invoke(input, scopedOptions));
501
322
  }
502
- /**
503
- * Returns the run-scoped tool output registry, or `undefined` when
504
- * the feature is disabled.
505
- *
506
- * @internal Exposed for test observation only. Host code should rely
507
- * on `{{tool<i>turn<n>}}` substitution at tool-invocation time and
508
- * not mutate the registry directly.
509
- */
510
323
  _unsafeGetToolOutputRegistry() {
511
324
  return this.toolOutputRegistry;
512
325
  }
513
- /**
514
- * Replaces known remote Code API tools with local-process tools when
515
- * `RunConfig.toolExecution.engine === 'local'`. In event-driven mode those
516
- * names are also marked direct so the SDK executes them locally instead of
517
- * dispatching the batch to a host-side remote sandbox handler. When the
518
- * local coding suite is enabled, this also injects file/search/edit tools.
519
- */
520
326
  applyToolExecutionOverrides() {
521
327
  const resolved = resolveLocalExecutionTools({
522
328
  toolMap: this.toolMap,
@@ -529,16 +335,6 @@ var ToolNode = class extends RunnableCallable {
529
335
  this.directToolNames = new Set([...this.directToolNames ?? /* @__PURE__ */ new Set(), ...resolved.directToolNames]);
530
336
  this.programmaticCache = void 0;
531
337
  }
532
- /**
533
- * Returns the per-Run file checkpointer when
534
- * `toolExecution.local.fileCheckpointing === true`. Hosts call
535
- * `rewind()` on the returned object to restore captured pre-write
536
- * file contents — the standard "undo a tool batch" pattern. Returns
537
- * undefined when checkpointing is disabled or the local coding suite
538
- * isn't bound. Manual review (finding E): without this getter, the
539
- * config flag was a silent no-op outside of direct
540
- * `createLocalCodingToolBundle()` use.
541
- */
542
338
  getFileCheckpointer() {
543
339
  return this.fileCheckpointer;
544
340
  }
@@ -571,22 +367,10 @@ var ToolNode = class extends RunnableCallable {
571
367
  if (suggestion == null) return `Tool "${callName}" not found.`;
572
368
  return `Tool "${callName}" not found. Did you mean "${suggestion}"? Handoff tool names must match exactly.`;
573
369
  }
574
- /**
575
- * Flush per-Run direct replay state. Called by the Graph at end-of-Run via
576
- * `clearHeavyState`. The state intentionally survives `run()` re-entry so
577
- * interrupt + resume keeps both original turn slots and terminal sibling
578
- * outputs, but it would otherwise grow linearly and could collide across
579
- * Runs if a provider reused call IDs. Hosts can also call this directly if
580
- * they reuse a ToolNode across batches outside of a Graph.
581
- */
582
370
  clearDirectPathTurns() {
583
371
  this.directPathTurns.clear();
584
372
  this.settledInterruptingResults.clear();
585
373
  }
586
- /**
587
- * Returns cached programmatic tools, computing once on first access.
588
- * Single iteration builds both toolMap and toolDefs simultaneously.
589
- */
590
374
  getProgrammaticTools() {
591
375
  if (this.programmaticCache) return this.programmaticCache;
592
376
  const toolMap = /* @__PURE__ */ new Map();
@@ -604,10 +388,6 @@ var ToolNode = class extends RunnableCallable {
604
388
  };
605
389
  return this.programmaticCache;
606
390
  }
607
- /**
608
- * Returns a snapshot of the current tool usage counts.
609
- * @returns A ReadonlyMap where keys are tool names and values are their usage counts.
610
- */
611
391
  getToolUsageCounts() {
612
392
  return new Map(this.toolUsageCount);
613
393
  }
@@ -642,14 +422,6 @@ var ToolNode = class extends RunnableCallable {
642
422
  this.recordToolUsageTurn(toolName, turn, callId);
643
423
  if (this.canConsumeEagerEventExecution(runId)) this.eagerEventToolUsageCount?.set(toolName, Math.max(this.eagerEventToolUsageCount.get(toolName) ?? 0, turn + 1));
644
424
  }
645
- /**
646
- * Runs a single tool call with error handling.
647
- *
648
- * `batchIndex` is the tool's position within the current ToolNode
649
- * batch and, together with `this.currentTurn`, forms the key used to
650
- * register the output for future `{{tool<idx>turn<turn>}}`
651
- * substitutions. Omit when no registration should occur.
652
- */
653
425
  async runTool(call, config, batchContext = {}) {
654
426
  const { batchIndex, turn, batchScopeId, resolvedArgsByCallId, preBatchSnapshot, runInput } = batchContext;
655
427
  const tool = this.toolMap.get(call.name);
@@ -658,42 +430,11 @@ var ToolNode = class extends RunnableCallable {
658
430
  const resolveOptions = { substituteIntentKey: this.toolDeclaresBusinessIntent(call.name) };
659
431
  if (preBatchSnapshot != null) resolveFn = (_runId, args) => preBatchSnapshot.resolve(args, resolveOptions);
660
432
  else if (registry != null) resolveFn = (runIdArg, args) => registry.resolve(runIdArg, args, resolveOptions);
661
- /**
662
- * Precompute the reference key once per call — captured locally
663
- * so concurrent `invoke()` calls on the same ToolNode cannot race
664
- * on a shared turn field.
665
- */
666
433
  const refKey = registry != null && batchIndex != null && turn != null ? buildReferenceKey(batchIndex, turn) : void 0;
667
- /**
668
- * Hoisted outside the try so the catch branch can append
669
- * `[unresolved refs: …]` to error messages — otherwise the LLM
670
- * only sees a generic error when it references a bad key, losing
671
- * the self-correction signal this feature is meant to provide.
672
- */
673
434
  let unresolvedRefs = [];
674
- /**
675
- * Use the caller-provided `batchScopeId` when threaded from
676
- * `run()` (so anonymous batches get their own unique scope).
677
- * Fall back to the config's `run_id` when runTool is invoked
678
- * from a context that doesn't thread it — that still preserves
679
- * the runId-based partitioning for named runs.
680
- */
681
435
  const runId = batchScopeId ?? config.configurable?.run_id;
682
436
  try {
683
437
  if (tool === void 0) throw new Error(this.getUnknownToolErrorMessage(call.name));
684
- /**
685
- * `usageCount` is the per-tool-name invocation index that
686
- * web-search and other tools observe via `invokeParams.turn`.
687
- * It is intentionally distinct from the outer `turn` parameter
688
- * (the batch turn used for ref keys); the latter is captured
689
- * before the try block when constructing `refKey`.
690
- *
691
- * Prefer the value `runDirectToolWithLifecycleHooks` already
692
- * incremented (Codex P2 #27) — its hook wants the SAME turn
693
- * the tool will execute under. When called from a path that
694
- * doesn't pre-increment (event dispatch, the no-hooks
695
- * shortcut), do the read+increment here.
696
- */
697
438
  const usageCount = batchContext.usageCount ?? (() => {
698
439
  const next = this.toolUsageCount.get(call.name) ?? 0;
699
440
  this.toolUsageCount.set(call.name, next + 1);
@@ -705,12 +446,6 @@ var ToolNode = class extends RunnableCallable {
705
446
  const { resolved, unresolved } = resolveFn(runId, args);
706
447
  args = resolved;
707
448
  unresolvedRefs = unresolved;
708
- /**
709
- * Expose the post-substitution args to downstream completion
710
- * events so audit logs / host-side `ON_RUN_STEP_COMPLETED`
711
- * handlers observe what actually ran, not the `{{…}}`
712
- * template. Only string/object args are worth recording.
713
- */
714
449
  if (resolvedArgsByCallId != null && call.id != null && call.id !== "" && resolved !== call.args && typeof resolved === "object") resolvedArgsByCallId.set(call.id, resolved);
715
450
  }
716
451
  const stepId = this.toolCallStepIds?.get(call.id);
@@ -739,16 +474,6 @@ var ToolNode = class extends RunnableCallable {
739
474
  ...invokeParams,
740
475
  toolRegistry: this.toolRegistry
741
476
  };
742
- /**
743
- * Inject session context for code execution tools when available.
744
- * Each file uses its own session_id (supporting multi-session file tracking).
745
- * Both session_id and _injected_files are injected directly to invokeParams
746
- * (not inside args) so they bypass Zod schema validation and reach config.toolCall.
747
- *
748
- * session_id is always injected when available, but concrete file refs
749
- * still need to travel through `_injected_files`; the legacy
750
- * `/files/<session_id>` fallback was removed from the executors.
751
- */
752
477
  if (this.participatesInCodeSession(call.name)) {
753
478
  const codeSession = this.sessions?.get("execute_code");
754
479
  const execSessionId = codeSession?.session_id;
@@ -759,25 +484,12 @@ var ToolNode = class extends RunnableCallable {
759
484
  };
760
485
  if (codeSession?.files != null && codeSession.files.length > 0) invokeParams._injected_files = codeSession.files.map((file) => toInjectedFileRef(file, execSessionId));
761
486
  }
762
- /**
763
- * Stateful runtime session hint — orthogonal to the transient
764
- * exec-session above, and injected independently (a first call has a
765
- * hint but no exec session yet). Explicit host hint wins; otherwise
766
- * fall back to the conversation's thread_id.
767
- */
768
487
  const runtimeSessionHint = this.resolveRuntimeSessionHint(config);
769
488
  if (runtimeSessionHint != null) invokeParams = {
770
489
  ...invokeParams,
771
490
  _runtime_session_hint: runtimeSessionHint
772
491
  };
773
492
  }
774
- /**
775
- * Forward the graph state as langgraph 1.4's `runtime.state` so
776
- * tools can read it off their second argument instead of the
777
- * deprecated `getCurrentTaskInput()` (which relies on
778
- * `node:async_hooks` and is browser-incompatible). Shape mirrors
779
- * langgraph's prebuilt ToolNode runtime exactly.
780
- */
781
493
  const lgConfig = config;
782
494
  const runtime = {
783
495
  ...config,
@@ -788,9 +500,6 @@ var ToolNode = class extends RunnableCallable {
788
500
  store: lgConfig.store ?? null,
789
501
  writer: lgConfig.writer ?? config.configurable?.writer ?? null
790
502
  };
791
- /** A sibling can trip the breaker while the PreToolUse hooks above
792
- * are awaited; a tool that never inspects its runtime signal would
793
- * still run. Recheck at the last moment before execution. */
794
503
  this.throwIfBreakerTripped(config);
795
504
  const output = await tool.invoke(invokeParams, runtime);
796
505
  if (isCommand(output)) return output;
@@ -801,13 +510,6 @@ var ToolNode = class extends RunnableCallable {
801
510
  const compacted = compactToolContent(originalContent, this.maxToolResultChars);
802
511
  if (compacted.changed) toolMsg.content = compacted.content;
803
512
  if (toolMsg.status === "error") {
804
- /**
805
- * Error ToolMessages bypass registration but still stamp the
806
- * unresolved-refs hint into `additional_kwargs` so the lazy
807
- * annotation transform surfaces it to the LLM, letting the
808
- * model self-correct when its reference key caused the
809
- * failure. Persisted `content` stays clean.
810
- */
811
513
  if (unresolvedRefs.length > 0) toolMsg.additional_kwargs = {
812
514
  ...toolMsg.additional_kwargs,
813
515
  _unresolvedRefs: unresolvedRefs
@@ -822,16 +524,6 @@ var ToolNode = class extends RunnableCallable {
822
524
  ...refMeta
823
525
  };
824
526
  } else {
825
- /**
826
- * Non-string content (multi-part content blocks — text +
827
- * image). It is now bounded for the LLM, but cannot register under a
828
- * reference key because there's no canonical serialized
829
- * form. Warn once per tool per run when the caller
830
- * intended to register. The unresolved-refs hint is still
831
- * stamped as metadata; the lazy transform prepends a text
832
- * block at request time so the LLM gets the self-correction
833
- * signal.
834
- */
835
527
  if (unresolvedRefs.length > 0) toolMsg.additional_kwargs = {
836
528
  ...toolMsg.additional_kwargs,
837
529
  _unresolvedRefs: unresolvedRefs
@@ -853,11 +545,6 @@ var ToolNode = class extends RunnableCallable {
853
545
  const e = _e;
854
546
  if (!this.handleToolErrors) throw e;
855
547
  if (isGraphInterrupt(e)) throw e;
856
- /**
857
- * A stream circuit breaker tripped by a child run (subagent) is a
858
- * safety abort, not a tool failure to report back to the model. It
859
- * passes through like an interrupt so the whole run rejects.
860
- */
861
548
  if (e instanceof StreamLimitExceededError) throw e;
862
549
  if (this.errorHandler) try {
863
550
  const dispatched = await this.errorHandler({
@@ -867,15 +554,7 @@ var ToolNode = class extends RunnableCallable {
867
554
  input: call.args
868
555
  }, config.metadata);
869
556
  const ownership = batchContext.errorOwnership ?? this.looseErrorOwnership;
870
- if (call.id != null && call.id !== "") if (dispatched === false)
871
- /**
872
- * The handler could not dispatch the error completion (typically
873
- * a resume pass, where a fast-failing tool errors before the
874
- * step replay registers its run step). Remember the call so the
875
- * output loop dispatches the completion itself instead of
876
- * assuming the handler covered it.
877
- */
878
- ownership.undispatched.add(call.id);
557
+ if (call.id != null && call.id !== "") if (dispatched === false) ownership.undispatched.add(call.id);
879
558
  else ownership.handlerOwned.add(call.id);
880
559
  } catch (handlerError) {
881
560
  if (call.id != null && call.id !== "") (batchContext.errorOwnership ?? this.looseErrorOwnership).handlerOwned.add(call.id);
@@ -909,53 +588,6 @@ var ToolNode = class extends RunnableCallable {
909
588
  });
910
589
  }
911
590
  }
912
- /**
913
- * Runs a single in-process tool call with the same lifecycle hooks
914
- * the event-dispatch path fires (`PreToolUse`, `PermissionDenied`,
915
- * `PostToolUse`, `PostToolUseFailure`). Used for any tool whose
916
- * implementation lives in the SDK process — i.e. every entry in
917
- * `directToolNames` — so host-supplied policy hooks gate
918
- * direct-invoked tools the same way they gate dispatched ones.
919
- *
920
- * Fast path: when the registry has none of the relevant events
921
- * registered for this run, falls through to `runTool` with zero
922
- * extra work. The hook list is also checked via
923
- * `hasHookFor(event, runId)`, which performs the registry's own
924
- * O(1) shortcut.
925
- *
926
- * Hook semantics intentionally mirror `dispatchToolEvents` for the
927
- * single-call case:
928
- * - `PreToolUse` returning `decision: 'deny'` synthesizes an error
929
- * `ToolMessage` and fires `PermissionDenied` (observational).
930
- * - `PreToolUse` returning `decision: 'ask'`:
931
- * • When `humanInTheLoop.enabled === true`: raises a real
932
- * `tool_approval` interrupt for this single tool call (the
933
- * same payload shape the event path produces). On resume:
934
- * `approve` runs the tool, `reject` blocks via
935
- * `blockDirectCall`, `respond` returns the host-supplied
936
- * `responseText` as a synthetic success ToolMessage,
937
- * `edit` re-runs with edited args. LangGraph re-enters
938
- * ToolNode.run from the start on resume. Reusable hooks fire
939
- * again; a consumed one-shot hook replays its pending approval
940
- * result. In both cases `interrupt()` consumes the resume value.
941
- * • When HITL is off: collapses to a fail-closed deny (matches
942
- * the rest of the SDK's HITL-disabled default). One-time
943
- * warning logged so hosts notice the gap.
944
- * - `PreToolUse.updatedInput` is applied to the call before
945
- * `runTool` runs; placeholder resolution inside `runTool` is
946
- * idempotent on already-resolved args.
947
- * - `PostToolUse.updatedOutput` replaces the returned
948
- * `ToolMessage` content (preserving id/name/status).
949
- * - `PostToolUseFailure` fires when `runTool` returns a
950
- * `ToolMessage` whose `status === 'error'`. Observational only;
951
- * the error message stays the source of truth.
952
- *
953
- * `PostToolBatch` aggregation across direct + dispatched outcomes is
954
- * a separate concern: `dispatchToolEvents` accumulates batch entries
955
- * locally and fires `PostToolBatch` at the end of its scope. Wiring
956
- * direct-call entries into that aggregation crosses the two paths'
957
- * scopes and is left to a follow-up.
958
- */
959
591
  async runDirectToolWithLifecycleHooks(call, config, batchContext = {}) {
960
592
  const replayController = this.toolMap.get(call.name)?.[SUBAGENT_REPLAY_CONTROLLER];
961
593
  const replayConfig = replayController == null ? config : withSubagentReplayBatch(config, batchContext.replayBatchKey);
@@ -1152,15 +784,6 @@ var ToolNode = class extends RunnableCallable {
1152
784
  }
1153
785
  }
1154
786
  }
1155
- /**
1156
- * A hook (`PreToolUse.updatedInput`) or HITL `edit` decision rewrote the
1157
- * args: expose the EFFECTIVE args to downstream completion handling
1158
- * (`handleRunToolCompletions` reads this sink), so the emitted
1159
- * `tool_call.args` — and any intent/outcome label resolved from them —
1160
- * reflect what the tool actually ran with. `runTool`'s own placeholder
1161
- * substitution may overwrite this entry with the post-substitution args,
1162
- * which is strictly more accurate.
1163
- */
1164
787
  if (effectiveCall !== call && batchContext.resolvedArgsByCallId != null && call.id != null && call.id !== "") batchContext.resolvedArgsByCallId.set(call.id, effectiveCall.args);
1165
788
  const output = await this.runTool(effectiveCall, replayConfig, {
1166
789
  ...batchContext,
@@ -1230,13 +853,6 @@ var ToolNode = class extends RunnableCallable {
1230
853
  }
1231
854
  return persistOutput(output);
1232
855
  }
1233
- /**
1234
- * `ask` decisions on direct-path tools collapse to fail-closed deny
1235
- * only when `humanInTheLoop.enabled !== true` (i.e. there's no host
1236
- * UI configured to actually prompt the user). Logged once per process
1237
- * so the gap is visible. When HITL IS enabled, `ask` raises a real
1238
- * LangGraph `interrupt()` instead — see `runDirectToolWithLifecycleHooks`.
1239
- */
1240
856
  askDirectWarningEmitted = false;
1241
857
  resolveAskDecisionForDirectTool(reason, toolName) {
1242
858
  if (!this.askDirectWarningEmitted) {
@@ -1245,12 +861,6 @@ var ToolNode = class extends RunnableCallable {
1245
861
  }
1246
862
  return reason ?? "Blocked by hook";
1247
863
  }
1248
- /**
1249
- * Synthesize a Blocked ToolMessage AND fire `PermissionDenied`
1250
- * (observational) for a direct-path tool call. Centralised so the
1251
- * deny path looks identical whether the block came from `'deny'` or
1252
- * from a fail-closed/`'reject'`/policy-violation path.
1253
- */
1254
864
  blockDirectCall(args) {
1255
865
  const { call, resolvedArgs, reason, hookRegistry, runId, threadId } = args;
1256
866
  if (hookRegistry.hasHookFor("PermissionDenied", runId) === true) executeHooks({
@@ -1276,49 +886,17 @@ var ToolNode = class extends RunnableCallable {
1276
886
  tool_call_id: call.id ?? ""
1277
887
  });
1278
888
  }
1279
- /**
1280
- * Registers the full, raw output under `refKey` (when provided) and
1281
- * builds the per-message ref metadata stamped onto the resulting
1282
- * `ToolMessage.additional_kwargs`. The metadata is read at LLM-
1283
- * request time by `annotateMessagesForLLM` to produce a transient
1284
- * annotated copy of the message — the persisted `content` itself
1285
- * stays clean.
1286
- *
1287
- * @param registryContent The full, untruncated output to store in
1288
- * the registry so `{{tool<i>turn<n>}}` substitutions deliver the
1289
- * complete payload. Ignored when `refKey` is undefined.
1290
- * @param refKey Precomputed `tool<i>turn<n>` key, or undefined when
1291
- * the output is not to be registered (errors, disabled feature,
1292
- * unavailable batch/turn).
1293
- * @param unresolved Placeholder keys that did not resolve; surfaced
1294
- * to the LLM lazily so it can self-correct.
1295
- * @returns A `ToolMessageRefMetadata` object when there is anything
1296
- * to stamp, otherwise `undefined`.
1297
- */
1298
889
  recordOutputReference(runId, registryContent, refKey, unresolved) {
1299
890
  if (this.toolOutputRegistry != null && refKey != null) this.toolOutputRegistry.set(runId, refKey, registryContent);
1300
891
  if (refKey == null && unresolved.length === 0) return void 0;
1301
892
  const meta = {};
1302
893
  if (refKey != null) {
1303
894
  meta._refKey = refKey;
1304
- /**
1305
- * Stamp the registry scope alongside the key so the lazy
1306
- * annotation transform can look up the right bucket. Anonymous
1307
- * invocations get a synthetic per-batch scope (`\0anon-<n>`)
1308
- * that `attemptInvoke` cannot derive from
1309
- * `config.configurable.run_id` — without this, anonymous-run
1310
- * refs would silently fail registry lookup and the LLM would
1311
- * never see `[ref: …]` markers for outputs that were registered.
1312
- */
1313
895
  if (runId != null) meta._refScope = runId;
1314
896
  }
1315
897
  if (unresolved.length > 0) meta._unresolvedRefs = unresolved;
1316
898
  return meta;
1317
899
  }
1318
- /**
1319
- * Builds code session context for injection into event-driven tool calls.
1320
- * Mirrors the session injection logic in runTool() for direct execution.
1321
- */
1322
900
  getCodeSessionContext() {
1323
901
  if (!this.sessions) return;
1324
902
  const codeSession = this.sessions.get("execute_code");
@@ -1328,23 +906,10 @@ var ToolNode = class extends RunnableCallable {
1328
906
  if (codeSession.files && codeSession.files.length > 0) context.files = codeSession.files.map((file) => toInjectedFileRef(file, execSessionId));
1329
907
  return context;
1330
908
  }
1331
- /**
1332
- * Extracts code execution session context from tool results and stores in Graph.sessions.
1333
- * Mirrors the session storage logic in handleRunToolCompletions for direct execution.
1334
- */
1335
- /**
1336
- * True when a tool's successful result should fold its returned exec
1337
- * `session_id` into the shared code session: built-in `CODE_EXECUTION_TOOLS`,
1338
- * plus host-declared sandbox-writing tools (`codeSessionToolNames`, e.g.
1339
- * create_file/edit_file). Kept name-scoped rather than a blanket artifact
1340
- * opt-in so only host-declared tools can influence the shared session.
1341
- */
1342
909
  participatesInCodeSession(name) {
1343
910
  if (name === "") return false;
1344
911
  return CODE_EXECUTION_TOOLS.has(name) || this.codeSessionToolNames?.has(name) === true;
1345
912
  }
1346
- /** Delegates to the shared resolver so the direct and event-driven planning
1347
- * paths derive the runtime session hint identically. */
1348
913
  resolveRuntimeSessionHint(config) {
1349
914
  return resolveRuntimeSessionHint(this.toolExecution, config.configurable?.thread_id);
1350
915
  }
@@ -1361,19 +926,6 @@ var ToolNode = class extends RunnableCallable {
1361
926
  updateCodeSession(this.sessions, execSessionId, artifact?.files);
1362
927
  }
1363
928
  }
1364
- /**
1365
- * Post-processes standard runTool outputs: dispatches ON_RUN_STEP_COMPLETED
1366
- * and stores code session context. Mirrors the completion handling in
1367
- * dispatchToolEvents for the event-driven path.
1368
- *
1369
- * By handling completions here in graph context (rather than in the
1370
- * stream consumer via ToolEndHandler), the race between the stream
1371
- * consumer and graph execution is eliminated.
1372
- *
1373
- * @param resolvedArgsByCallId Per-batch resolved-args sink populated
1374
- * by `runTool`. Threaded as a local map (instead of instance state)
1375
- * so concurrent batches cannot read each other's entries.
1376
- */
1377
929
  async handleRunToolCompletions(calls, outputs, config, resolvedArgsByCallId, errorOwnership) {
1378
930
  const ownership = errorOwnership ?? this.looseErrorOwnership;
1379
931
  for (let i = 0; i < calls.length; i++) {
@@ -1401,15 +953,7 @@ var ToolNode = class extends RunnableCallable {
1401
953
  if (isComputerCallOutputMessage(toolMessage)) contentString = truncateToolResultContent("[Computer screenshot omitted from completion event]", this.maxToolResultChars);
1402
954
  else if (typeof toolMessage.content === "string") contentString = toolMessage.content;
1403
955
  else contentString = serializeStructuredValueBounded(toolMessage.content, this.maxToolResultChars).content;
1404
- /**
1405
- * Prefer the post-substitution args when a `{{…}}` placeholder
1406
- * was resolved in `runTool`. This keeps
1407
- * `ON_RUN_STEP_COMPLETED.tool_call.args` consistent with what
1408
- * the tool actually received rather than leaking the template.
1409
- */
1410
956
  const effectiveArgs = resolvedArgsByCallId?.get(toolCallId) ?? call.args;
1411
- /** Authored outcomes apply to failed calls too (“Search failed for…”);
1412
- * without one, an error call simply stays unlabeled. */
1413
957
  const outcome = resolveToolOutcome(effectiveArgs, readOutcomeFields(toolMessage.artifact), { isError: toolMessage.status === "error" });
1414
958
  await safeDispatchCustomEvent("on_run_step_completed", { result: {
1415
959
  id: stepId,
@@ -1427,25 +971,6 @@ var ToolNode = class extends RunnableCallable {
1427
971
  } }, config);
1428
972
  }
1429
973
  }
1430
- /**
1431
- * Dispatches tool calls to the host via ON_TOOL_EXECUTE event and returns raw ToolMessages.
1432
- * Core logic for event-driven execution, separated from output shaping.
1433
- *
1434
- * Hook lifecycle (when `hookRegistry` is set):
1435
- * 1. **PreToolUse** fires per call in parallel before dispatch. Denied
1436
- * calls produce error ToolMessages and fire **PermissionDenied**;
1437
- * surviving calls proceed with optional `updatedInput`.
1438
- * 2. Surviving calls are dispatched to the host via `ON_TOOL_EXECUTE`.
1439
- * 3. **PostToolUse** / **PostToolUseFailure** fire per result. Post hooks
1440
- * can replace tool output via `updatedOutput`.
1441
- * 4. Injected messages from results are collected and returned alongside
1442
- * ToolMessages (appended AFTER to respect provider ordering).
1443
- */
1444
- /** Rethrows a stream-limit trip carried on the batch config's composed
1445
- * signal. Rechecked at each later execution/dispatch stage because a tool
1446
- * that ignores cancellation can complete normally across the trip, and
1447
- * the next stage would otherwise start fresh side effects on a failed
1448
- * run. */
1449
974
  throwIfBreakerTripped(config) {
1450
975
  const signal = config.signal;
1451
976
  if (signal?.aborted === true && signal.reason instanceof StreamLimitExceededError) throw signal.reason;
@@ -1454,13 +979,6 @@ var ToolNode = class extends RunnableCallable {
1454
979
  this.throwIfBreakerTripped(config);
1455
980
  const { batchIndices, turn, batchScopeId, preResolvedArgs, preBatchSnapshot } = batchContext;
1456
981
  const runId = config.configurable?.run_id ?? "";
1457
- /**
1458
- * Registry-facing scope id — prefers the caller-threaded
1459
- * `batchScopeId` so anonymous batches target their own unique
1460
- * bucket and don't step on concurrent anonymous invocations.
1461
- * Hooks and event payloads keep using the empty-string coerced
1462
- * `runId` for backward compat.
1463
- */
1464
982
  const registryRunId = batchScopeId ?? config.configurable?.run_id;
1465
983
  const threadId = config.configurable?.thread_id;
1466
984
  const registry = this.toolOutputRegistry;
@@ -1468,14 +986,6 @@ var ToolNode = class extends RunnableCallable {
1468
986
  const preToolCalls = toolCalls.map((call, i) => {
1469
987
  const originalArgs = call.args;
1470
988
  let resolvedArgs = originalArgs;
1471
- /**
1472
- * When the caller provided a pre-resolved map (the mixed
1473
- * direct+event path snapshots event args synchronously before
1474
- * awaiting directs so they can't accidentally resolve
1475
- * same-turn direct outputs), use those entries verbatim instead
1476
- * of re-resolving against a registry that may have changed
1477
- * since the batch started.
1478
- */
1479
989
  const pre = call.id != null ? preResolvedArgs?.get(call.id) : void 0;
1480
990
  if (pre != null) {
1481
991
  resolvedArgs = pre.resolved;
@@ -1494,26 +1004,7 @@ var ToolNode = class extends RunnableCallable {
1494
1004
  });
1495
1005
  const messageByCallId = /* @__PURE__ */ new Map();
1496
1006
  const approvedEntries = [];
1497
- /**
1498
- * Batch-level accumulator for `additionalContext` strings returned
1499
- * by any PreToolUse / PostToolUse / PostToolUseFailure hook in this
1500
- * dispatch. We emit one consolidated `HumanMessage` after all tool
1501
- * results land so the next model turn sees the injected context
1502
- * exactly once, ordered after the ToolMessages.
1503
- */
1504
1007
  const batchAdditionalContexts = [];
1505
- /**
1506
- * Batch-level outcome record keyed by `tool_call_id`. Captures
1507
- * every tool call's final result (success / error from the host,
1508
- * blocked from HITL deny / reject, substituted from HITL respond)
1509
- * across the three call sites that touch it. We materialize the
1510
- * `PostToolBatch` entry array in `toolCalls` order at dispatch
1511
- * time so hooks correlating outcomes by position see exactly the
1512
- * same sequence the model emitted — independent of when each
1513
- * outcome was recorded (deny entries land synchronously in the
1514
- * hook loop, approved entries land after host execution, respond
1515
- * entries land in the resume branch).
1516
- */
1517
1008
  const postToolBatchEntryByCallId = /* @__PURE__ */ new Map();
1518
1009
  const HOOK_FALLBACK = Object.freeze({
1519
1010
  additionalContexts: [],
@@ -1524,15 +1015,6 @@ var ToolNode = class extends RunnableCallable {
1524
1015
  const approvalReplaySessionId = getToolApprovalReplaySessionId(config, runId);
1525
1016
  const hasPendingApproval = preToolCalls.some((entry) => entry.call.id != null && hookRegistry?.getPendingToolApproval(approvalReplaySessionId, createToolApprovalReplayKey(config, this.executingAgentId ?? this.agentId ?? "", entry.call.id)) != null);
1526
1017
  if (hookRegistry != null && (hookRegistry.hasHookFor("PreToolUse", runId) || hasPendingApproval)) {
1527
- /**
1528
- * Pull each call's prestarted eager record BEFORE awaiting the hooks:
1529
- * an async deny must never race the eager host promise into emitting a
1530
- * successful completion (`dispatchEagerToolCompletions`' map-identity
1531
- * check skips deleted records). Allowed entries get their record
1532
- * restored in the decision loop below so consumption still works;
1533
- * denied entries stay deleted. Ask/interrupt configs never have eager
1534
- * records (HITL disables the reservation gate).
1535
- */
1536
1018
  const preemptedEagerRecords = /* @__PURE__ */ new Map();
1537
1019
  if (this.eagerEventToolExecutions != null) for (const entry of preToolCalls) {
1538
1020
  const callId = entry.call.id;
@@ -1566,20 +1048,6 @@ var ToolNode = class extends RunnableCallable {
1566
1048
  onceReplaySessionId: approvalReplaySessionId
1567
1049
  }).catch(() => HOOK_FALLBACK);
1568
1050
  }));
1569
- /**
1570
- * Side effects deferred from `blockEntry` until after any pending
1571
- * `interrupt()` resolves. Without deferral, a batch that mixes a
1572
- * `deny` decision with an `ask` decision would dispatch
1573
- * `ON_RUN_STEP_COMPLETED` for the denied tool on the FIRST node
1574
- * execution (before `interrupt()` throws), then dispatch the
1575
- * same event AGAIN on the resume re-execution — hosts would
1576
- * observe two completion events for one logical denial. By
1577
- * queueing the dispatch + PermissionDenied hook here and
1578
- * flushing after the interrupt block, we ensure each side effect
1579
- * fires exactly once: never on the first pass when interrupt
1580
- * throws (the flush is unreachable), once on resume / no-ask
1581
- * passes when control reaches the flush.
1582
- */
1583
1051
  const deferredBlockedSideEffects = [];
1584
1052
  const blockEntry = (entry, reason) => {
1585
1053
  const contentString = `Blocked: ${reason}`;
@@ -1594,15 +1062,6 @@ var ToolNode = class extends RunnableCallable {
1594
1062
  toolInput: entry.args,
1595
1063
  toolUseId: entry.call.id,
1596
1064
  stepId: entry.stepId,
1597
- /**
1598
- * Records the pre-invocation turn count — the same value the
1599
- * executed path captures before incrementing `toolUsageCount`.
1600
- * For a blocked tool the counter is never incremented (no
1601
- * invocation happened), so this is always the count of prior
1602
- * successful invocations of this tool name in earlier batches.
1603
- * Surfaces in the `PostToolBatch` entry so batch hooks see
1604
- * a uniform shape regardless of outcome.
1605
- */
1606
1065
  turn: this.toolUsageCount.get(entry.call.name) ?? 0,
1607
1066
  status: "error",
1608
1067
  error: contentString
@@ -1614,13 +1073,6 @@ var ToolNode = class extends RunnableCallable {
1614
1073
  contentString,
1615
1074
  reason
1616
1075
  });
1617
- /**
1618
- * A prestarted eager execution for a now-blocked call must neither be
1619
- * consumed nor emit its completion — the run reports this call as
1620
- * blocked. Deleting the record makes `dispatchEagerToolCompletions`'
1621
- * map-identity check skip the pending emission (same pattern as the
1622
- * rejected-results cleanup below).
1623
- */
1624
1076
  this.eagerEventToolExecutions?.delete(entry.call.id);
1625
1077
  };
1626
1078
  const flushDeferredBlockedSideEffects = async () => {
@@ -1645,19 +1097,6 @@ var ToolNode = class extends RunnableCallable {
1645
1097
  }
1646
1098
  deferredBlockedSideEffects.length = 0;
1647
1099
  };
1648
- /**
1649
- * Apply a hook-supplied or host-supplied input override to a pending
1650
- * entry, re-running the `{{tool<i>turn<n>}}` resolver so any new
1651
- * placeholders introduced by the override are substituted (and any
1652
- * formerly-unresolved refs cleared from the unresolved set).
1653
- *
1654
- * Mixed direct+event batches must use the pre-batch snapshot so a
1655
- * hook-introduced placeholder cannot accidentally resolve to a
1656
- * same-turn direct output that has just registered. Pure event
1657
- * batches don't have a snapshot and resolve against the live
1658
- * registry — safe because no event-side registrations have happened
1659
- * yet.
1660
- */
1661
1100
  const applyInputOverride = (entry, nextArgs) => {
1662
1101
  if (registry != null) {
1663
1102
  const { resolved, unresolved } = (preBatchSnapshot ?? { resolve: (args, options) => registry.resolve(registryRunId, args, options) }).resolve(nextArgs, { substituteIntentKey: this.toolDeclaresBusinessIntent(entry.call.name) });
@@ -1678,29 +1117,10 @@ var ToolNode = class extends RunnableCallable {
1678
1117
  continue;
1679
1118
  }
1680
1119
  if (hookResult.decision === "ask") {
1681
- /**
1682
- * HITL is OFF by default — hosts must explicitly opt in via
1683
- * `humanInTheLoop: { enabled: true }` to engage the
1684
- * `interrupt()` path. When opted out (or omitted), `ask`
1685
- * collapses into the pre-HITL fail-closed path: a blocked
1686
- * tool with an error `ToolMessage`. The default stays
1687
- * conservative until host UIs are ready to render
1688
- * `tool_approval` interrupts; see `HumanInTheLoopConfig`
1689
- * JSDoc for the full rationale and the migration plan.
1690
- */
1691
1120
  if (this.humanInTheLoop?.enabled !== true) {
1692
1121
  blockEntry(entry, hookResult.reason ?? "Blocked by hook");
1693
1122
  continue;
1694
1123
  }
1695
- /**
1696
- * Apply `updatedInput` BEFORE queuing into `askEntries` —
1697
- * a hook is allowed to return both a sanitization rewrite
1698
- * and an `ask` decision (e.g. one matcher redacts secrets,
1699
- * another matcher requires approval). Without this, the
1700
- * interrupt payload would surface the original args to the
1701
- * reviewer AND the post-approve execution would run with
1702
- * the original args, silently dropping the hook's rewrite.
1703
- */
1704
1124
  if (hookResult.updatedInput != null) applyInputOverride(entry, hookResult.updatedInput);
1705
1125
  askEntries.push({
1706
1126
  entry,
@@ -1716,26 +1136,8 @@ var ToolNode = class extends RunnableCallable {
1716
1136
  }
1717
1137
  approvedEntries.push(entry);
1718
1138
  }
1719
- /**
1720
- * If any entries asked for approval, raise a single LangGraph
1721
- * `interrupt()` carrying every pending request together. The host
1722
- * pauses, gathers human input, and resumes the run with one
1723
- * decision per request. On resume LangGraph re-executes this node
1724
- * from the start; `interrupt()` then returns the resume value
1725
- * instead of throwing. Reusable hooks rebuild their entries, while
1726
- * consumed one-shot hooks replay their pending approval aggregate.
1727
- */
1728
1139
  if (askEntries.length > 0) {
1729
1140
  const payload = buildToolApprovalInterruptPayload(askEntries, runId);
1730
- /**
1731
- * `interrupt()` reads the current `RunnableConfig` from
1732
- * AsyncLocalStorage. ToolNode usually runs with tracing disabled
1733
- * (unless Langfuse explicitly enables it), so the upstream
1734
- * `runWithConfig` frame may not exist. Re-anchor here using the
1735
- * node's own `config` — Pregel hands us a config that already
1736
- * carries every checkpoint/scratchpad key `interrupt()` needs to
1737
- * suspend and resume.
1738
- */
1739
1141
  const resumeValue = AsyncLocalStorageProviderSingleton.runWithConfig(config, () => interrupt(payload));
1740
1142
  for (const { entry } of askEntries) hookRegistry.clearPendingToolApproval(approvalReplaySessionId, createToolApprovalReplayKey(config, this.executingAgentId ?? this.agentId ?? "", entry.call.id));
1741
1143
  const decisionByCallId = normalizeApprovalDecisions(askEntries.map(({ entry }) => entry.call.id), resumeValue);
@@ -1744,27 +1146,7 @@ var ToolNode = class extends RunnableCallable {
1744
1146
  type: "reject",
1745
1147
  reason: "No decision provided for tool approval"
1746
1148
  };
1747
- /**
1748
- * Read `decision.type` through a widened view once: hosts
1749
- * deserialize resume payloads from untyped JSON, so the
1750
- * runtime value can be a typo, the wrong type, or missing
1751
- * entirely. Both the `allowedDecisions` enforcement
1752
- * immediately below and the unknown-type fallthrough at the
1753
- * end of this loop body share this single read so the
1754
- * fail-closed checks compare against the same source.
1755
- */
1756
1149
  const declaredType = decision.type;
1757
- /**
1758
- * Enforce the per-tool `allowedDecisions` allowlist that the
1759
- * `PreToolUse` hook surfaced in `review_configs`. The host
1760
- * UI is supposed to honor this when collecting the user's
1761
- * decision, but the wire is untrusted: a buggy or hostile
1762
- * host could submit a decision type the policy explicitly
1763
- * forbids (e.g. `'edit'` when the hook restricted to
1764
- * `['approve', 'reject']`), bypassing argument-mutation /
1765
- * response-substitution safeguards. Fail closed when the
1766
- * declared type isn't in the allowlist.
1767
- */
1768
1150
  if (allowedDecisions != null && (typeof declaredType !== "string" || !allowedDecisions.includes(declaredType))) {
1769
1151
  blockEntry(entry, `Decision "${typeof declaredType === "string" ? declaredType : "<missing>"}" not in allowedDecisions [${allowedDecisions.join(", ")}] — failing closed`);
1770
1152
  continue;
@@ -1773,38 +1155,12 @@ var ToolNode = class extends RunnableCallable {
1773
1155
  blockEntry(entry, decision.reason ?? askReason ?? "Rejected by user");
1774
1156
  continue;
1775
1157
  }
1776
- /**
1777
- * `respond` short-circuits tool execution: the human supplies
1778
- * the result the model should see in place of running the
1779
- * tool. We emit a successful `ToolMessage` directly and skip
1780
- * dispatch — no host event fires, no real tool side effect
1781
- * occurs. Mirrors LangChain HITL middleware semantics.
1782
- */
1783
1158
  if (decision.type === "respond") {
1784
- /**
1785
- * Validate the wire shape before touching it: hosts
1786
- * deserialize resume payloads from untyped JSON, so a
1787
- * malformed `{ type: 'respond' }` (no `responseText`) or
1788
- * `{ type: 'respond', responseText: 42 }` would crash
1789
- * `truncateToolResultContent` (which calls
1790
- * `content.length`) and turn a fail-closed approval path
1791
- * into a hard run failure. Route bad shapes through
1792
- * `blockEntry` like any other unusable decision.
1793
- */
1794
1159
  const responseText = decision.responseText;
1795
1160
  if (typeof responseText !== "string") {
1796
1161
  blockEntry(entry, `Decision "respond" missing string responseText (got ${describeOfferedShape(responseText)}) — failing closed`);
1797
1162
  continue;
1798
1163
  }
1799
- /**
1800
- * Truncate the human-supplied text just like the success
1801
- * path does for real tool output. Without this, a user
1802
- * pasting a large document as a manual response bypasses
1803
- * `maxToolResultChars` and can blow past the model's
1804
- * context window. The PostToolBatch entry surfaces the
1805
- * truncated text too so batch hooks see what the model
1806
- * will actually see.
1807
- */
1808
1164
  const truncatedResponse = truncateToolResultContent(responseText, this.maxToolResultChars);
1809
1165
  messageByCallId.set(entry.call.id, new ToolMessage({
1810
1166
  status: "success",
@@ -1821,30 +1177,10 @@ var ToolNode = class extends RunnableCallable {
1821
1177
  status: "success",
1822
1178
  toolOutput: truncatedResponse
1823
1179
  });
1824
- /**
1825
- * Safe to dispatch immediately — unlike `blockEntry` which
1826
- * defers, `respond` only executes inside the decision-
1827
- * processing loop, which is reachable only AFTER
1828
- * `interrupt()` has returned (the resume pass). There is
1829
- * no risk of being rolled back by a subsequent throw, so
1830
- * no risk of a duplicate `ON_RUN_STEP_COMPLETED` event.
1831
- */
1832
1180
  await this.dispatchStepCompleted(entry.call.id, entry.call.name, entry.args, truncatedResponse, config);
1833
1181
  continue;
1834
1182
  }
1835
1183
  if (decision.type === "edit") {
1836
- /**
1837
- * Validate the wire shape before touching it: hosts
1838
- * deserialize resume payloads from untyped JSON, so a
1839
- * malformed `{ type: 'edit' }` (no `updatedInput`),
1840
- * `{ type: 'edit', updatedInput: 'string' }` (non-object),
1841
- * or `{ type: 'edit', updatedInput: [...] }` (array, not a
1842
- * plain object) would feed garbage into
1843
- * `applyInputOverride` and silently approve a tool with
1844
- * undefined / wrong-shape args. Same trust boundary as
1845
- * the `respond` validation above — fail closed via
1846
- * `blockEntry` with a diagnostic.
1847
- */
1848
1184
  const updatedInput = decision.updatedInput;
1849
1185
  if (updatedInput === null || typeof updatedInput !== "object" || Array.isArray(updatedInput)) {
1850
1186
  blockEntry(entry, `Decision "edit" missing object updatedInput (got ${describeOfferedShape(updatedInput)}) — failing closed`);
@@ -1854,19 +1190,6 @@ var ToolNode = class extends RunnableCallable {
1854
1190
  approvedEntries.push(entry);
1855
1191
  continue;
1856
1192
  }
1857
- /**
1858
- * Defensive type widening: hosts deserialize resume payloads
1859
- * from untyped JSON, so the `decision.type` value at runtime
1860
- * is whatever string the wire sent — not necessarily one of
1861
- * the four union variants TS knows about. We compare against
1862
- * the literal `'approve'` through the widened `declaredType`
1863
- * captured at the top of this iteration, so a typo or schema
1864
- * drift (`'aproved'`, `null`, `undefined`) hits the fail-
1865
- * closed branch below instead of silently approving the
1866
- * tool. Without this widening, TS narrows the union after
1867
- * the three earlier branches and treats `=== 'approve'` as
1868
- * trivially true.
1869
- */
1870
1193
  if (declaredType === "approve") {
1871
1194
  approvedEntries.push(entry);
1872
1195
  continue;
@@ -1874,18 +1197,6 @@ var ToolNode = class extends RunnableCallable {
1874
1197
  blockEntry(entry, `Unknown approval decision type "${typeof declaredType === "string" ? declaredType : "<missing>"}" — failing closed`);
1875
1198
  }
1876
1199
  }
1877
- /**
1878
- * Flush deferred denial side effects exactly once. On the FIRST
1879
- * pass through a batch that contains an `ask`, `interrupt()`
1880
- * threw above and we never reach this line — so no
1881
- * `ON_RUN_STEP_COMPLETED` / `PermissionDenied` events fire
1882
- * for blocked tools yet. On resume the node re-executes from
1883
- * scratch, `blockEntry` re-queues the same entries, and the
1884
- * flush below dispatches them once. For batches without any
1885
- * `ask` (deny-only or empty), the flush still runs here and
1886
- * dispatches in the same relative position as the pre-deferral
1887
- * code did (after hook processing, before tool execution).
1888
- */
1889
1200
  await flushDeferredBlockedSideEffects();
1890
1201
  } else approvedEntries.push(...preToolCalls);
1891
1202
  const injected = [];
@@ -1925,33 +1236,13 @@ var ToolNode = class extends RunnableCallable {
1925
1236
  });
1926
1237
  else dispatchRequests.push(request);
1927
1238
  }
1928
- /**
1929
- * Per-call completion fast-path: when the host reports a result
1930
- * through `onResult` before the batch resolves, emit that call's
1931
- * completed run step immediately instead of waiting for the slowest
1932
- * call in the batch. Safe only when nothing can change the result
1933
- * after execution — post-tool hooks may rewrite output and HITL may
1934
- * deny a call, so those configurations keep batch-time emission.
1935
- * Ids are claimed synchronously before the async dispatch and
1936
- * released if the dispatch fails, letting the batch path re-emit.
1937
- */
1938
1239
  const canEmitEarlyCompletions = this.hookRegistry?.hasResultAlteringHooks(runId) !== true && this.humanInTheLoop?.enabled !== true;
1939
- /**
1940
- * Snapshot the post-hook gates at the same instant as the early-emission
1941
- * gate: a result-altering hook registered while this batch is in flight
1942
- * applies from the NEXT batch. Evaluating these after results settle
1943
- * would let a late hook rewrite the ToolMessage AFTER an early
1944
- * completion already emitted the pre-hook output — two views of the
1945
- * same call.
1946
- */
1947
1240
  const hasPostHook = this.hookRegistry?.hasHookFor("PostToolUse", runId) === true;
1948
1241
  const hasFailureHook = this.hookRegistry?.hasHookFor("PostToolUseFailure", runId) === true;
1949
1242
  const earlyCompletionDispatchedIds = /* @__PURE__ */ new Set();
1950
1243
  const earlyCompletionDispatches = [];
1951
1244
  const dispatchRequestById = new Map(dispatchRequests.map((request) => [request.id, request]));
1952
1245
  const onResult = (result) => {
1953
- /** Runtime-honest widening: hosts may omit the id despite the
1954
- * field type. */
1955
1246
  const resultToolCallId = result.toolCallId;
1956
1247
  const request = resultToolCallId != null ? dispatchRequestById.get(resultToolCallId) : void 0;
1957
1248
  if (request == null || earlyCompletionDispatchedIds.has(result.toolCallId)) return;
@@ -1962,9 +1253,6 @@ var ToolNode = class extends RunnableCallable {
1962
1253
  earlyCompletionDispatchedIds.delete(result.toolCallId);
1963
1254
  }));
1964
1255
  };
1965
- /** The approval hooks above are awaited; a sibling's trip during them
1966
- * must stop the approved batch before it reaches a host handler that
1967
- * may never inspect the request signal. */
1968
1256
  if (dispatchRequests.length > 0) this.throwIfBreakerTripped(config);
1969
1257
  const dispatchPromise = dispatchRequests.length === 0 ? Promise.resolve([]) : new Promise((resolve, reject) => {
1970
1258
  let dispatchSettled = false;
@@ -2019,24 +1307,9 @@ var ToolNode = class extends RunnableCallable {
2019
1307
  const toolName = request?.name ?? "unknown";
2020
1308
  let contentString;
2021
1309
  let toolMessage;
2022
- /**
2023
- * Tracks the post-PostToolUse-hook output so the
2024
- * `PostToolBatch` entry below sees the final transformed value
2025
- * even when a hook replaced the original via `updatedOutput`.
2026
- * Lives at the loop-iteration scope so the success branch can
2027
- * mutate it; the error branch leaves it unset (and the batch
2028
- * entry uses `error` instead of `toolOutput` in that case).
2029
- */
2030
1310
  let finalToolOutput = result.content;
2031
1311
  if (result.status === "error") {
2032
1312
  contentString = truncateToolResultContent(`Error: ${result.errorMessage ?? "Unknown error"}\n Please fix your mistakes.`, this.maxToolResultChars);
2033
- /**
2034
- * Error results bypass registration but stamp the
2035
- * unresolved-refs hint into `additional_kwargs` so the lazy
2036
- * annotation transform surfaces it to the LLM at request
2037
- * time, letting the model self-correct when its reference
2038
- * key caused the failure. Persisted `content` stays clean.
2039
- */
2040
1313
  const unresolved = unresolvedByCallId.get(result.toolCallId) ?? [];
2041
1314
  const errorRefMeta = unresolved.length > 0 ? this.recordOutputReference(registryRunId, contentString, void 0, unresolved) : void 0;
2042
1315
  toolMessage = new ToolMessage({
@@ -2065,15 +1338,6 @@ var ToolNode = class extends RunnableCallable {
2065
1338
  sessionId: runId,
2066
1339
  matchQuery: toolName
2067
1340
  }).catch(() => void 0);
2068
- /**
2069
- * Collect `additionalContext` from failure hooks too. Without
2070
- * this, recovery guidance returned on tool errors (e.g.
2071
- * "if this tool errors with X, suggest Y to the user") is
2072
- * silently dropped even though the API surface advertises
2073
- * `additionalContext` for this event. PostToolUseFailure
2074
- * remains observational for errors thrown by the hook
2075
- * itself, but a successfully-returned result is honored.
2076
- */
2077
1341
  if (failureHookResult != null) for (const ctx of failureHookResult.additionalContexts) batchAdditionalContexts.push(ctx);
2078
1342
  }
2079
1343
  } else {
@@ -2107,14 +1371,6 @@ var ToolNode = class extends RunnableCallable {
2107
1371
  registryRaw = serialized.registryContent;
2108
1372
  contentString = serialized.content;
2109
1373
  finalToolOutput = hookResult.updatedOutput;
2110
- /**
2111
- * The hook ACTUALLY rewrote this output: any completion the
2112
- * stream already emitted for the consumed eager result showed
2113
- * the raw content, so un-mark it and let the dispatch below
2114
- * re-emit the corrected version. Hooks that merely observe or
2115
- * add context leave the original emission final — no
2116
- * duplicates.
2117
- */
2118
1374
  eagerCompletionDispatchedIds.delete(result.toolCallId);
2119
1375
  }
2120
1376
  }
@@ -2156,7 +1412,6 @@ var ToolNode = class extends RunnableCallable {
2156
1412
  injected
2157
1413
  };
2158
1414
  }
2159
- /** Run-scoped so another run's session hooks can't flip this run's gate. */
2160
1415
  canConsumeEagerEventExecution(runId) {
2161
1416
  return this.eventDrivenMode && this.eagerEventToolExecution?.enabled === true && this.hookRegistry?.hasResultAlteringHooks(runId) !== true && this.humanInTheLoop?.enabled !== true;
2162
1417
  }
@@ -2196,24 +1451,6 @@ var ToolNode = class extends RunnableCallable {
2196
1451
  errorMessage: "Tool execution completed without a result for this tool call"
2197
1452
  }];
2198
1453
  }
2199
- /**
2200
- * Fires the `PostToolBatch` hook (if registered) and appends the
2201
- * accumulated batch-level `additionalContext` strings to `injected`
2202
- * as a single `HumanMessage`. Entries are materialized in the
2203
- * original `toolCalls` order so hooks correlating outcomes by
2204
- * position (as the type docs promise) see exactly the sequence
2205
- * the model emitted, regardless of when each individual outcome
2206
- * was recorded into the map (deny synchronous, approved
2207
- * post-execution, respond on resume).
2208
- *
2209
- * The PostToolBatch hook's `additionalContexts` flow into the same
2210
- * batch accumulator per-tool hooks already use, so a single
2211
- * batch-level convention message can be injected through one path.
2212
- *
2213
- * Mutates `batchAdditionalContexts` (push from batch hook) and
2214
- * `injected` (push the consolidated HumanMessage). The caller owns
2215
- * those arrays and consumes them right after this returns.
2216
- */
2217
1454
  async dispatchPostToolBatchAndInjectContext(args) {
2218
1455
  const { toolCalls, entriesByCallId, batchAdditionalContexts, injected, runId, threadId } = args;
2219
1456
  const orderedBatchEntries = [];
@@ -2242,40 +1479,19 @@ var ToolNode = class extends RunnableCallable {
2242
1479
  for (const msg of batchHookResult.injectedMessages) hookInjectedMessages.push(msg);
2243
1480
  }
2244
1481
  }
2245
- if (batchAdditionalContexts.length > 0)
2246
- /**
2247
- * `HumanMessage` carrying a metadata `role: 'system'` marker —
2248
- * see `convertInjectedMessages` for the wider rationale. Anthropic
2249
- * and Google reject mid-conversation `SystemMessage`s, so we use
2250
- * a user-role message and surface the system intent through
2251
- * `additional_kwargs` for hosts inspecting state. The model sees
2252
- * a user message; `role` is metadata only.
2253
- */
2254
- injected.push(new HumanMessage({
1482
+ if (batchAdditionalContexts.length > 0) injected.push(new HumanMessage({
2255
1483
  content: batchAdditionalContexts.join("\n\n"),
2256
1484
  additional_kwargs: {
2257
1485
  role: "system",
2258
1486
  source: "hook"
2259
1487
  }
2260
1488
  }));
2261
- /**
2262
- * Hook-returned `injectedMessages` land AFTER the consolidated context
2263
- * message: one converted `HumanMessage` per entry (role/source kept in
2264
- * `additional_kwargs`), preserving per-message identity so verbatim
2265
- * user speech (e.g. steering) sits closest to the next model call.
2266
- */
2267
1489
  if (hookInjectedMessages.length > 0) try {
2268
1490
  injected.push(...convertInjectedMessages(hookInjectedMessages));
2269
1491
  } catch (e) {
2270
1492
  console.warn("[ToolNode] Failed to convert PostToolBatch injectedMessages:", e instanceof Error ? e.message : e);
2271
1493
  }
2272
1494
  }
2273
- /**
2274
- * Whether `name`'s own schema declares a BUSINESS parameter called
2275
- * `intent` (declared, and not the injected label contract — see
2276
- * `isIntentLabelProperty`). Such a parameter must keep participating in
2277
- * `{{tool…}}` placeholder substitution; only the display label is exempt.
2278
- */
2279
1495
  toolDeclaresBusinessIntent(name) {
2280
1496
  const instance = this.toolMap.get(name);
2281
1497
  const instanceProp = instance?.schema?.properties?.["intent"] ?? instance?.schema?.shape?.["intent"];
@@ -2302,50 +1518,10 @@ var ToolNode = class extends RunnableCallable {
2302
1518
  completed_at: Date.now()
2303
1519
  } }, config) !== false;
2304
1520
  }
2305
- /**
2306
- * Emits the completed run step for a single host-reported result before
2307
- * the batch resolves. Mirrors the batch loop's output formatting exactly;
2308
- * callers gate on the no-hooks/no-HITL configuration, so the raw result
2309
- * content here is also the final content. Returns whether the event was
2310
- * actually dispatched so the caller can fall back to batch-time emission.
2311
- */
2312
1521
  async dispatchEarlyToolCompletion(result, request, config) {
2313
1522
  const output = result.status === "error" ? truncateToolResultContent(`Error: ${result.errorMessage ?? "Unknown error"}\n Please fix your mistakes.`, this.maxToolResultChars) : serializeToolOutputWithinLimits(result.content, this.maxToolResultChars).content;
2314
1523
  return this.dispatchStepCompleted(result.toolCallId, request.name, request.args, output, config, request.turn, resolveToolOutcome(request.args, outcomeFieldsFromResult(result), { isError: result.status === "error" }));
2315
1524
  }
2316
- /**
2317
- * Execute a group of direct (in-process) tool calls with interrupt-safe
2318
- * ordering, returning outputs aligned 1:1 with `directCalls`.
2319
- *
2320
- * Fast path (the common case): when no call in the group is in
2321
- * `interruptingToolNames`, this is a single `Promise.all` — byte-for-byte
2322
- * the prior behavior, so ordinary batches are unaffected.
2323
- *
2324
- * Interrupt-safe path: when the group contains an interrupting tool (e.g.
2325
- * `ask_user_question`, whose body raises a LangGraph `interrupt()` to
2326
- * collect a human answer), the interrupting calls run as their own awaited
2327
- * group **first**; only after they all settle without interrupting do the
2328
- * remaining (potentially non-idempotent) siblings run. If an interrupting
2329
- * call throws a `GraphInterrupt`, the `await` below rejects and unwinds the
2330
- * whole ToolNode *before* any non-interrupting sibling has started — so a
2331
- * sibling with real side effects (send_email, billing) never executes on
2332
- * the first pass. Terminal interrupting siblings are cached by call id, so
2333
- * LangGraph replay reuses their complete lifecycle output instead of
2334
- * repeating model calls, hooks, or side effects.
2335
- *
2336
- * Without this ordering, a flat `Promise.all` starts every sibling
2337
- * concurrently, so a non-idempotent sibling can complete its side effect
2338
- * before the interrupt unwinds and then run a SECOND time on resume — the
2339
- * duplicate side effect this method exists to prevent. A tool that actually
2340
- * suspends re-enters until it reaches a terminal result; siblings that
2341
- * already settled do not re-enter.
2342
- *
2343
- * `batchIndices[i]` is `directCalls[i]`'s position within the parent
2344
- * ToolNode batch (used for `{{tool<i>turn<n>}}` registration); it is
2345
- * preserved regardless of execution order. `baseContext` carries the
2346
- * batch-scoped fields every call shares; `batchIndex` is filled in
2347
- * per-call here.
2348
- */
2349
1525
  async runDirectBatchInterruptSafe(directCalls, batchIndices, config, baseContext) {
2350
1526
  const settledBatchResults = baseContext.replayBatchKey == null ? void 0 : this.settledInterruptingResults.get(baseContext.replayBatchKey);
2351
1527
  const restoreResult = (call, result) => {
@@ -2377,9 +1553,6 @@ var ToolNode = class extends RunnableCallable {
2377
1553
  for (let i = 0; i < directCalls.length; i++) if (interrupting.has(directCalls[i].name)) interruptingPositions.push(i);
2378
1554
  else regularPositions.push(i);
2379
1555
  const interruptingResults = await Promise.allSettled(interruptingPositions.map((i) => runOne(directCalls[i], i)));
2380
- /** A sibling may have tripped the run-wide breaker while another raised
2381
- * a GraphInterrupt. Safety failures take precedence over approval pauses
2382
- * regardless of input order. */
2383
1556
  this.throwIfBreakerTripped(config);
2384
1557
  let hasInterruptingError = false;
2385
1558
  let interruptingError;
@@ -2429,9 +1602,6 @@ var ToolNode = class extends RunnableCallable {
2429
1602
  }
2430
1603
  throw interruptingError;
2431
1604
  }
2432
- /** The breaker can trip while the interrupting group is awaited — e.g.
2433
- * a tool that ignores cancellation and completes normally. Recheck
2434
- * before starting the non-idempotent siblings. */
2435
1605
  this.throwIfBreakerTripped(config);
2436
1606
  const regularOutputs = await Promise.all(regularPositions.map((i) => runOne(directCalls[i], i)));
2437
1607
  regularPositions.forEach((i, k) => {
@@ -2439,34 +1609,14 @@ var ToolNode = class extends RunnableCallable {
2439
1609
  });
2440
1610
  return outputs;
2441
1611
  }
2442
- /**
2443
- * Execute all tool calls via ON_TOOL_EXECUTE event dispatch.
2444
- * Injected messages are placed AFTER ToolMessages to respect provider
2445
- * message ordering (AIMessage tool_calls must be immediately followed
2446
- * by their ToolMessage results).
2447
- *
2448
- * `batchIndices` mirrors `toolCalls` and carries each call's position
2449
- * within the parent batch. `turn` is the per-`run()` batch index
2450
- * captured locally by the caller. Both are threaded so concurrent
2451
- * invocations cannot race on shared mutable state.
2452
- */
2453
1612
  async executeViaEvent(toolCalls, config, input, batchContext = {}) {
2454
1613
  const { toolMessages, injected } = await this.dispatchToolEvents(toolCalls, config, batchContext);
2455
1614
  const outputs = [...toolMessages, ...injected];
2456
1615
  return Array.isArray(input) ? outputs : { messages: outputs };
2457
1616
  }
2458
1617
  async run(input, config) {
2459
- /**
2460
- * Breaker read once at batch entry: every downstream path (direct
2461
- * `tool.invoke` runtimes and the ON_TOOL_EXECUTE dispatch) inherits this
2462
- * config, and a graph reset mid-batch must not detach in-flight tools
2463
- * from an already-tripped signal.
2464
- */
2465
1618
  const breakerSignal = this.getBreakerSignal?.();
2466
1619
  const composedSignal = composeAbortSignals(config.signal, breakerSignal);
2467
- /** Immutable batch scope, captured with the signal BEFORE hooks: tools
2468
- * that spawn runs (subagents) bind their child to this controller, so a
2469
- * reset during a PreToolUse hook cannot hand them the new run's one. */
2470
1620
  const batchRunScope = this.getRunScope?.();
2471
1621
  if (composedSignal !== config.signal || batchRunScope != null) config = {
2472
1622
  ...config,
@@ -2476,41 +1626,16 @@ var ToolNode = class extends RunnableCallable {
2476
1626
  ["lc_run_breaker_scope"]: batchRunScope
2477
1627
  } }
2478
1628
  };
2479
- /** Already-tripped-at-entry: a parallel sibling's breach failed the run
2480
- * before this batch was scheduled. Rethrow before hooks, direct
2481
- * `tool.invoke` calls, or ON_TOOL_EXECUTE dispatch — a tool or host
2482
- * handler that doesn't synchronously inspect an aborted signal would
2483
- * otherwise perform side effects on a failed run. */
2484
1629
  if (composedSignal?.aborted === true && composedSignal.reason instanceof StreamLimitExceededError) throw composedSignal.reason;
2485
1630
  this.toolCallTurns.clear();
2486
- /**
2487
- * Per-batch local map for resolved (post-substitution) args.
2488
- * Lives on the stack so concurrent `run()` calls on the same
2489
- * ToolNode cannot read or wipe each other's entries.
2490
- */
2491
1631
  const resolvedArgsByCallId = /* @__PURE__ */ new Map();
2492
- /** Per-invocation error-completion ownership — see `ToolErrorOwnership`. */
2493
1632
  const errorOwnership = createToolErrorOwnership();
2494
- /**
2495
- * Claim this batch's turn synchronously from the registry (or
2496
- * fall back to 0 when the feature is disabled). The registry is
2497
- * partitioned by scope id so overlapping batches cannot
2498
- * overwrite each other's state even under a shared registry.
2499
- *
2500
- * For anonymous callers (no `run_id` in config), mint a unique
2501
- * per-batch scope id so two concurrent anonymous invocations
2502
- * don't target the same bucket. The scope is threaded down to
2503
- * every subsequent registry call on this batch.
2504
- */
2505
1633
  const incomingRunId = config.configurable?.run_id;
2506
1634
  const incomingThreadId = config.configurable?.thread_id;
2507
1635
  const batchScopeId = incomingRunId ?? `\0anon-${this.anonBatchCounter++}`;
2508
1636
  const turn = this.toolOutputRegistry?.nextTurn(batchScopeId) ?? 0;
2509
1637
  let outputs;
2510
1638
  let replayBatchKey;
2511
- /** Hoisted from the messages-state branch so the Command tail can carry
2512
- * the promotion into handoff updates (same-id state copies there would
2513
- * otherwise overwrite the replacement message). */
2514
1639
  let promotedAiMessage;
2515
1640
  let invalidCallResults = [];
2516
1641
  if (this.isSendInput(input)) {
@@ -2560,12 +1685,6 @@ var ToolNode = class extends RunnableCallable {
2560
1685
  this.programmaticCache = void 0;
2561
1686
  }
2562
1687
  const filteredCalls = aiMessage.tool_calls?.filter((call) => {
2563
- /**
2564
- * Filter out:
2565
- * 1. Already processed tool calls (present in toolMessageIds)
2566
- * 2. Server tool calls (e.g., web_search with IDs starting with 'srvtoolu_')
2567
- * which are executed by the provider's API and don't require invocation
2568
- */
2569
1688
  return (call.id == null || !toolMessageIds.has(call.id)) && !(call.id?.startsWith("srvtoolu_") ?? false);
2570
1689
  }) ?? [];
2571
1690
  const attributableInvalidCalls = !(!Array.isArray(input) && typeof aiMessage.id === "string" && aiMessage.id.length > 0) ? [] : (aiMessage.invalid_tool_calls ?? []).filter((call) => call.id != null && call.id !== "" && !toolMessageIds.has(call.id) && !call.id.startsWith("srvtoolu_"));
@@ -2576,20 +1695,6 @@ var ToolNode = class extends RunnableCallable {
2576
1695
  name: normalizeInvalidCallName(call.name),
2577
1696
  tool_call_id: call.id
2578
1697
  }));
2579
- /**
2580
- * Promote the answered invalid calls into well-formed `tool_calls` on a
2581
- * REPLACEMENT copy of the AI message (`messagesStateReducer` upserts by
2582
- * id). Without this, provider converters that rebuild the call side of
2583
- * the wire from `tool_calls` — OpenAI Completions `tool_calls`, OpenAI
2584
- * Responses `function_call` items, Gemini/Bedrock function-call parts —
2585
- * drop the invalid call while the synthesized result above still
2586
- * references it, inverting the dangling-pair rejection (an output whose
2587
- * call is missing). Promoting at this single seam keeps the call and
2588
- * result sides agreeing for EVERY provider; args become `{}` (the raw
2589
- * string never parsed — the paired error result tells the model why).
2590
- * Skipped when the message has no id: the reducer would append a
2591
- * duplicate instead of replacing, which is worse than the dangle.
2592
- */
2593
1698
  promotedAiMessage = attributableInvalidCalls.length > 0 ? new AIMessage({
2594
1699
  id: aiMessage.id,
2595
1700
  content: sanitizeInvalidToolUseBlocks(aiMessage.content, attributableInvalidCalls),
@@ -2628,27 +1733,7 @@ var ToolNode = class extends RunnableCallable {
2628
1733
  const directIndices = directEntries.map((e) => e.batchIndex);
2629
1734
  const eventCalls = eventEntries.map((e) => e.call);
2630
1735
  const eventIndices = eventEntries.map((e) => e.batchIndex);
2631
- /**
2632
- * Snapshot the event calls' args against the *pre-batch*
2633
- * registry state synchronously, before any await runs. The
2634
- * directs are then awaited first (preserving fail-fast
2635
- * semantics — a thrown error in a direct tool, e.g. with
2636
- * `handleToolErrors=false` or a `GraphInterrupt`, aborts
2637
- * before we dispatch any event-driven tools to the host).
2638
- * Because the event args were captured pre-await, they stay
2639
- * isolated from same-turn direct outputs that register
2640
- * during the await.
2641
- */
2642
1736
  const preResolvedEventArgs = /* @__PURE__ */ new Map();
2643
- /**
2644
- * Take a frozen snapshot of the registry state before any
2645
- * direct registrations land. The snapshot resolves
2646
- * placeholders against this point-in-time view, so a
2647
- * `PreToolUse` hook later rewriting event args via
2648
- * `updatedInput` can introduce placeholders that resolve
2649
- * cross-batch (against prior runs) without ever picking up
2650
- * same-turn direct outputs.
2651
- */
2652
1737
  const preBatchSnapshot = this.toolOutputRegistry?.snapshot(batchScopeId);
2653
1738
  if (preBatchSnapshot != null) {
2654
1739
  for (const entry of eventEntries) if (entry.call.id != null) {
@@ -2728,15 +1813,6 @@ var ToolNode = class extends RunnableCallable {
2728
1813
  ...invalidCallResults
2729
1814
  ];
2730
1815
  }
2731
- /**
2732
- * Resolve the streamed tool-call cards for invalid calls, best-effort.
2733
- * Runs AFTER the direct batch settled: on an interrupting first pass
2734
- * this line is unreachable (the node unwound), so interrupt/resume
2735
- * flows emit the completion exactly once — same reasoning as the
2736
- * deferred blocked-call side effects. Skipped when the stream never
2737
- * registered a step for the call (non-streaming providers), where a
2738
- * completion could not be routed to a card anyway.
2739
- */
2740
1816
  for (const result of invalidCallResults) {
2741
1817
  const invalidStepId = this.toolCallStepIds?.get(result.tool_call_id);
2742
1818
  if (invalidStepId == null || invalidStepId === "") continue;
@@ -2747,64 +1823,28 @@ var ToolNode = class extends RunnableCallable {
2747
1823
  if (replayBatchKey != null) this.settledInterruptingResults.delete(replayBatchKey);
2748
1824
  return Array.isArray(input) ? outputs : { messages: outputs };
2749
1825
  }
2750
- /**
2751
- * Carry the invalid-call promotion into handoff commands. A handoff
2752
- * tool's Command snapshots `update.messages` from the PRE-promotion
2753
- * state (MultiAgentGraph builds a filtered same-id copy of the original
2754
- * AI message), and commands apply after the sibling reducer updates —
2755
- * so the stale copy would overwrite the replacement message, and a
2756
- * Send handoff's child state could omit the synthesized results
2757
- * entirely. Patch each command's same-id AI message with the promotion
2758
- * and append any missing synthesized results.
2759
- */
2760
1826
  if (promotedAiMessage != null) outputs = outputs.map((output) => isCommand(output) ? patchCommandUpdateForPromotedInvalidCalls(output, promotedAiMessage, invalidCallResults) : output);
2761
1827
  const combinedOutputs = [];
2762
1828
  let parentCommand = null;
2763
- /**
2764
- * Collect handoff commands (Commands with string goto and Command.PARENT)
2765
- * for potential parallel handoff aggregation
2766
- */
2767
1829
  const handoffCommands = [];
2768
1830
  const nonCommandOutputs = [];
2769
- for (const output of outputs) if (isCommand(output)) if (output.graph === Command.PARENT && Array.isArray(output.goto) && output.goto.every((send) => isSend(send)))
2770
- /** Aggregate Send-based commands */
2771
- if (parentCommand) parentCommand.goto.push(...output.goto);
1831
+ for (const output of outputs) if (isCommand(output)) if (output.graph === Command.PARENT && Array.isArray(output.goto) && output.goto.every((send) => isSend(send))) if (parentCommand) parentCommand.goto.push(...output.goto);
2772
1832
  else parentCommand = new Command({
2773
1833
  graph: Command.PARENT,
2774
1834
  goto: output.goto
2775
1835
  });
2776
1836
  else if (output.graph === Command.PARENT) {
2777
- /**
2778
- * Handoff Command with destination.
2779
- * Handle both string ('agent') and array (['agent']) formats.
2780
- * Collect for potential parallel aggregation.
2781
- */
2782
1837
  const goto = output.goto;
2783
1838
  const isSingleStringDest = typeof goto === "string";
2784
1839
  const isSingleArrayDest = Array.isArray(goto) && goto.length === 1 && typeof goto[0] === "string";
2785
1840
  if (isSingleStringDest || isSingleArrayDest) handoffCommands.push(output);
2786
- else
2787
- /** Multi-destination or other command - pass through */
2788
- combinedOutputs.push(output);
2789
- } else
2790
- /** Other commands - pass through */
2791
- combinedOutputs.push(output);
1841
+ else combinedOutputs.push(output);
1842
+ } else combinedOutputs.push(output);
2792
1843
  else {
2793
1844
  nonCommandOutputs.push(output);
2794
1845
  combinedOutputs.push(Array.isArray(input) ? [output] : { messages: [output] });
2795
1846
  }
2796
- /**
2797
- * Handle handoff commands - convert to Send objects for parallel execution
2798
- * when multiple handoffs are requested
2799
- */
2800
1847
  if (handoffCommands.length > 1) {
2801
- /**
2802
- * Multiple parallel handoffs - convert to Send objects.
2803
- * Each Send carries its own state with the appropriate messages.
2804
- * This enables LLM-initiated parallel execution when calling multiple
2805
- * transfer tools simultaneously.
2806
- */
2807
- /** Collect all destinations for sibling tracking */
2808
1848
  const allDestinations = handoffCommands.map((cmd) => {
2809
1849
  const goto = cmd.goto;
2810
1850
  return typeof goto === "string" ? goto : goto[0];
@@ -2813,7 +1853,6 @@ var ToolNode = class extends RunnableCallable {
2813
1853
  const parallelGroupId = getRuntimeHandoffGroupId(parallelBatch);
2814
1854
  const sends = handoffCommands.map((cmd, idx) => {
2815
1855
  const destination = allDestinations[idx];
2816
- /** Get siblings (other destinations, not this one) */
2817
1856
  const siblings = allDestinations.filter((d) => d !== destination);
2818
1857
  const update = cmd.update;
2819
1858
  const handoffMessage = update?.messages ? findHandoffMessage(update.messages, destination) : void 0;
@@ -2829,9 +1868,7 @@ var ToolNode = class extends RunnableCallable {
2829
1868
  goto: sends
2830
1869
  });
2831
1870
  combinedOutputs.push(parallelCommand);
2832
- } else if (handoffCommands.length === 1)
2833
- /** Single handoff - pass through as-is */
2834
- combinedOutputs.push(handoffCommands[0]);
1871
+ } else if (handoffCommands.length === 1) combinedOutputs.push(handoffCommands[0]);
2835
1872
  if (parentCommand) combinedOutputs.push(parentCommand);
2836
1873
  if (replayBatchKey != null) this.settledInterruptingResults.delete(replayBatchKey);
2837
1874
  return combinedOutputs;
@@ -2847,17 +1884,6 @@ function areToolCallsInvoked(message, invokedToolIds) {
2847
1884
  if (!invokedToolIds || invokedToolIds.size === 0) return false;
2848
1885
  return message.tool_calls?.every((toolCall) => toolCall.id != null && invokedToolIds.has(toolCall.id)) ?? false;
2849
1886
  }
2850
- /**
2851
- * Normalize the `tool_use` content blocks of promoted invalid calls so the
2852
- * replacement AI message is valid on EVERY provider surface, not just
2853
- * `tool_calls`. Anthropic formats an array-content AI message from its blocks
2854
- * verbatim, and a call whose streamed `input_json` never parsed leaves the
2855
- * block's `input` as the raw accumulated STRING — replayed as-is, the API
2856
- * rejects it with `tool_use.input: Input should be an object` before pairing
2857
- * is even checked. Blocks matching a promoted call id get `input: {}`
2858
- * (mirroring the promoted args); everything else passes through untouched.
2859
- * String content (OpenAI-style) is returned as-is.
2860
- */
2861
1887
  function sanitizeInvalidToolUseBlocks(content, promotedCalls) {
2862
1888
  if (!Array.isArray(content)) return content;
2863
1889
  const promotedNamesById = new Map(promotedCalls.filter((call) => call.id != null).map((call) => [call.id, normalizeInvalidCallName(call.name)]));
@@ -2866,9 +1892,6 @@ function sanitizeInvalidToolUseBlocks(content, promotedCalls) {
2866
1892
  const toolUse = block;
2867
1893
  if (toolUse.id == null || !promotedNamesById.has(toolUse.id)) return block;
2868
1894
  const inputIsObject = typeof toolUse.input === "object" && toolUse.input != null && !Array.isArray(toolUse.input);
2869
- /** `name` normalizes with the SAME fallback the promoted `tool_calls`
2870
- * entry uses — a nameless block would fail provider validation on its
2871
- * own even with a valid input. */
2872
1895
  const nameIsValid = typeof toolUse.name === "string" && toolUse.name !== "";
2873
1896
  if (inputIsObject && nameIsValid) return block;
2874
1897
  return {
@@ -2878,41 +1901,9 @@ function sanitizeInvalidToolUseBlocks(content, promotedCalls) {
2878
1901
  };
2879
1902
  });
2880
1903
  }
2881
- /**
2882
- * Name fallback for attributable invalid calls, shared by every surface that
2883
- * materializes them (synthesized result, promoted tool_calls entry, sanitized
2884
- * block, handoff patch): `''` is normalized like `undefined` — providers
2885
- * reject nameless calls, so an empty string would defeat the promotion.
2886
- *
2887
- * INVARIANT MAP — a tool call lives in several parallel representations, and
2888
- * any surface that materializes, copies, filters, routes on, or reports one
2889
- * must keep ALL of them agreeing (`tool_calls`, `invalid_tool_calls`,
2890
- * provider content blocks, paired results). The attribution predicate is:
2891
- * id-bearing (non-empty), non-server (`srvtoolu_`), unanswered
2892
- * (`toolMessageIds`), messages-state input, id-bearing AI message. Surfaces
2893
- * that apply it today — extend this list when adding another:
2894
- * - `run()`'s `canPromoteInvalidCalls` gate + attributable filter
2895
- * - `toolsCondition`'s invalid-only / server-mix routing branch
2896
- * - `sanitizeInvalidToolUseBlocks` (block input AND name)
2897
- * - `patchCommandUpdateForPromotedInvalidCalls` (handoff snapshots)
2898
- * - `processHandoffReception`'s transfer-block filtering (MultiAgentGraph)
2899
- * - `findPendingToolCalls` in langfuseTraceShaping (span claims)
2900
- * - `serializeMessage`/`deserializeMessage` (session round-trip keeps
2901
- * `invalid_tool_calls` with the content blocks they repair)
2902
- */
2903
1904
  function normalizeInvalidCallName(name) {
2904
1905
  return name != null && name !== "" ? name : "unknown";
2905
1906
  }
2906
- /**
2907
- * Rewrite a handoff Command's `update.messages` so the invalid-call promotion
2908
- * survives into the child state: the same-id AI message copy (snapshotted
2909
- * pre-promotion by the handoff tool) gets the sanitized content, the promoted
2910
- * `tool_calls` entries for the answered invalid calls, and the leftover
2911
- * `invalid_tool_calls`; synthesized results missing from the update are
2912
- * appended so the child's history keeps every call/result pair. The update
2913
- * copy's own `tool_calls` narrowing (parallel handoffs filter to a single
2914
- * call) is preserved. Commands without a same-id AI message pass through.
2915
- */
2916
1907
  function patchCommandUpdateForPromotedInvalidCalls(command, promoted, invalidResults) {
2917
1908
  const update = command.update;
2918
1909
  const messages = update?.messages;
@@ -2950,13 +1941,6 @@ function patchCommandUpdateForPromotedInvalidCalls(command, promoted, invalidRes
2950
1941
  }
2951
1942
  });
2952
1943
  }
2953
- /**
2954
- * Whether the message carries an `invalid_tool_calls` entry ToolNode can pair a
2955
- * synthesized error result with (id-bearing, non-server). Shared by the routing
2956
- * condition below so an invalid-only turn still enters ToolNode — otherwise the
2957
- * malformed `tool_use` block is committed with no `tool_result` and the next
2958
- * model call is rejected by pairing-strict providers.
2959
- */
2960
1944
  function hasAttributableInvalidToolCalls(message) {
2961
1945
  return message.invalid_tool_calls?.some((call) => call.id != null && call.id !== "" && !call.id.startsWith("srvtoolu_")) ?? false;
2962
1946
  }
@@ -2964,22 +1948,6 @@ function toolsCondition(state, toolNode, invokedToolIds) {
2964
1948
  const messages = Array.isArray(state) ? state : state.messages;
2965
1949
  const message = messages[messages.length - 1];
2966
1950
  if (message && "tool_calls" in message && (message.tool_calls?.length ?? 0) > 0 && !areToolCallsInvoked(message, invokedToolIds)) return toolNode;
2967
- /**
2968
- * The valid calls (if any) did not route above, but ToolNode still owes any
2969
- * malformed calls their synthesized error results. Route when EVERY valid
2970
- * call is provider-server-executed (`srvtoolu_` — ToolNode's batch filter
2971
- * excludes those before execution, so nothing re-runs): that covers both the
2972
- * invalid-only turn and the Anthropic server-call + malformed-client-call
2973
- * mix, where `handleAnthropicSearchResults` marks the server call invoked
2974
- * and the first branch declines. A valid NON-server call that was invoked
2975
- * externally stays conservative (no routing) — ToolNode does not filter on
2976
- * `invokedToolIds`, so entering it would re-execute that call.
2977
- *
2978
- * Mirrors ToolNode's own gating exactly, or the routed turn would no-op and
2979
- * bounce back to the model with the dangle intact: array-state graphs get a
2980
- * plain output list (no reducer upsert — ToolNode skips invalid handling
2981
- * there), and an id-less message cannot take the replacement upsert either.
2982
- */
2983
1951
  if (!Array.isArray(state) && message && typeof message.id === "string" && message.id.length > 0 && hasAttributableInvalidToolCalls(message) && (message.tool_calls ?? []).every((call) => call.id?.startsWith("srvtoolu_") === true)) return toolNode;
2984
1952
  return END;
2985
1953
  }