@openai/agents-core 0.8.5 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/dist/agentToolRunConfig.js +3 -0
  2. package/dist/agentToolRunConfig.js.map +1 -1
  3. package/dist/agentToolRunConfig.mjs +3 -0
  4. package/dist/agentToolRunConfig.mjs.map +1 -1
  5. package/dist/errors.d.ts +10 -0
  6. package/dist/errors.js +15 -1
  7. package/dist/errors.js.map +1 -1
  8. package/dist/errors.mjs +13 -0
  9. package/dist/errors.mjs.map +1 -1
  10. package/dist/handoff.js +1 -1
  11. package/dist/handoff.js.map +1 -1
  12. package/dist/handoff.mjs +1 -1
  13. package/dist/handoff.mjs.map +1 -1
  14. package/dist/index.d.ts +5 -4
  15. package/dist/index.js +6 -2
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +3 -2
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/items.d.ts +13 -0
  20. package/dist/items.js +15 -0
  21. package/dist/items.js.map +1 -1
  22. package/dist/items.mjs +15 -0
  23. package/dist/items.mjs.map +1 -1
  24. package/dist/memory/historyMutations.d.ts +6 -0
  25. package/dist/memory/historyMutations.js +32 -0
  26. package/dist/memory/historyMutations.js.map +1 -0
  27. package/dist/memory/historyMutations.mjs +29 -0
  28. package/dist/memory/historyMutations.mjs.map +1 -0
  29. package/dist/memory/memorySession.d.ts +3 -2
  30. package/dist/memory/memorySession.js +7 -0
  31. package/dist/memory/memorySession.js.map +1 -1
  32. package/dist/memory/memorySession.mjs +7 -0
  33. package/dist/memory/memorySession.mjs.map +1 -1
  34. package/dist/memory/session.d.ts +22 -0
  35. package/dist/memory/session.js +6 -0
  36. package/dist/memory/session.js.map +1 -1
  37. package/dist/memory/session.mjs +5 -0
  38. package/dist/memory/session.mjs.map +1 -1
  39. package/dist/metadata.js +2 -2
  40. package/dist/metadata.mjs +2 -2
  41. package/dist/model.d.ts +21 -0
  42. package/dist/run.d.ts +7 -1
  43. package/dist/run.js +152 -57
  44. package/dist/run.js.map +1 -1
  45. package/dist/run.mjs +153 -58
  46. package/dist/run.mjs.map +1 -1
  47. package/dist/runState.d.ts +110 -3
  48. package/dist/runState.js +414 -53
  49. package/dist/runState.js.map +1 -1
  50. package/dist/runState.mjs +412 -53
  51. package/dist/runState.mjs.map +1 -1
  52. package/dist/runner/errorHandlers.d.ts +13 -4
  53. package/dist/runner/errorHandlers.js +22 -4
  54. package/dist/runner/errorHandlers.js.map +1 -1
  55. package/dist/runner/errorHandlers.mjs +21 -4
  56. package/dist/runner/errorHandlers.mjs.map +1 -1
  57. package/dist/runner/items.js +11 -1
  58. package/dist/runner/items.js.map +1 -1
  59. package/dist/runner/items.mjs +11 -1
  60. package/dist/runner/items.mjs.map +1 -1
  61. package/dist/runner/modelPreparation.d.ts +1 -1
  62. package/dist/runner/modelPreparation.js +7 -7
  63. package/dist/runner/modelPreparation.js.map +1 -1
  64. package/dist/runner/modelPreparation.mjs +7 -7
  65. package/dist/runner/modelPreparation.mjs.map +1 -1
  66. package/dist/runner/runLoop.d.ts +2 -1
  67. package/dist/runner/runLoop.js +2 -2
  68. package/dist/runner/runLoop.js.map +1 -1
  69. package/dist/runner/runLoop.mjs +2 -2
  70. package/dist/runner/runLoop.mjs.map +1 -1
  71. package/dist/runner/sandbox.d.ts +33 -0
  72. package/dist/runner/sandbox.js +92 -0
  73. package/dist/runner/sandbox.js.map +1 -0
  74. package/dist/runner/sandbox.mjs +83 -0
  75. package/dist/runner/sandbox.mjs.map +1 -0
  76. package/dist/runner/sessionPersistence.js +33 -12
  77. package/dist/runner/sessionPersistence.js.map +1 -1
  78. package/dist/runner/sessionPersistence.mjs +33 -12
  79. package/dist/runner/sessionPersistence.mjs.map +1 -1
  80. package/dist/runner/streamReconciliation.d.ts +14 -0
  81. package/dist/runner/streamReconciliation.js +80 -0
  82. package/dist/runner/streamReconciliation.js.map +1 -0
  83. package/dist/runner/streamReconciliation.mjs +72 -0
  84. package/dist/runner/streamReconciliation.mjs.map +1 -0
  85. package/dist/runner/toolExecution.js +25 -13
  86. package/dist/runner/toolExecution.js.map +1 -1
  87. package/dist/runner/toolExecution.mjs +25 -13
  88. package/dist/runner/toolExecution.mjs.map +1 -1
  89. package/dist/runner/toolUseTracker.d.ts +3 -1
  90. package/dist/runner/toolUseTracker.js +2 -2
  91. package/dist/runner/toolUseTracker.js.map +1 -1
  92. package/dist/runner/toolUseTracker.mjs +2 -2
  93. package/dist/runner/toolUseTracker.mjs.map +1 -1
  94. package/dist/runner/tracing.js +1 -0
  95. package/dist/runner/tracing.js.map +1 -1
  96. package/dist/runner/tracing.mjs +1 -0
  97. package/dist/runner/tracing.mjs.map +1 -1
  98. package/dist/runner/turnPreparation.d.ts +2 -4
  99. package/dist/runner/turnPreparation.js +7 -3
  100. package/dist/runner/turnPreparation.js.map +1 -1
  101. package/dist/runner/turnPreparation.mjs +7 -3
  102. package/dist/runner/turnPreparation.mjs.map +1 -1
  103. package/dist/runner/turnResolution.js +158 -31
  104. package/dist/runner/turnResolution.js.map +1 -1
  105. package/dist/runner/turnResolution.mjs +160 -33
  106. package/dist/runner/turnResolution.mjs.map +1 -1
  107. package/dist/runner/types.d.ts +8 -8
  108. package/dist/sandbox/agent.d.ts +24 -0
  109. package/dist/sandbox/agent.js +68 -0
  110. package/dist/sandbox/agent.js.map +1 -0
  111. package/dist/sandbox/agent.mjs +64 -0
  112. package/dist/sandbox/agent.mjs.map +1 -0
  113. package/dist/sandbox/brand.d.ts +1 -0
  114. package/dist/sandbox/brand.js +5 -0
  115. package/dist/sandbox/brand.js.map +1 -0
  116. package/dist/sandbox/brand.mjs +2 -0
  117. package/dist/sandbox/brand.mjs.map +1 -0
  118. package/dist/sandbox/capabilities/base.d.ts +25 -0
  119. package/dist/sandbox/capabilities/base.js +89 -0
  120. package/dist/sandbox/capabilities/base.js.map +1 -0
  121. package/dist/sandbox/capabilities/base.mjs +84 -0
  122. package/dist/sandbox/capabilities/base.mjs.map +1 -0
  123. package/dist/sandbox/capabilities/compaction.d.ts +33 -0
  124. package/dist/sandbox/capabilities/compaction.js +172 -0
  125. package/dist/sandbox/capabilities/compaction.js.map +1 -0
  126. package/dist/sandbox/capabilities/compaction.mjs +164 -0
  127. package/dist/sandbox/capabilities/compaction.mjs.map +1 -0
  128. package/dist/sandbox/capabilities/filesystem.d.ts +14 -0
  129. package/dist/sandbox/capabilities/filesystem.js +447 -0
  130. package/dist/sandbox/capabilities/filesystem.js.map +1 -0
  131. package/dist/sandbox/capabilities/filesystem.mjs +444 -0
  132. package/dist/sandbox/capabilities/filesystem.mjs.map +1 -0
  133. package/dist/sandbox/capabilities/index.d.ts +19 -0
  134. package/dist/sandbox/capabilities/index.js +31 -0
  135. package/dist/sandbox/capabilities/index.js.map +1 -0
  136. package/dist/sandbox/capabilities/index.mjs +17 -0
  137. package/dist/sandbox/capabilities/index.mjs.map +1 -0
  138. package/dist/sandbox/capabilities/memory.d.ts +52 -0
  139. package/dist/sandbox/capabilities/memory.js +290 -0
  140. package/dist/sandbox/capabilities/memory.js.map +1 -0
  141. package/dist/sandbox/capabilities/memory.mjs +286 -0
  142. package/dist/sandbox/capabilities/memory.mjs.map +1 -0
  143. package/dist/sandbox/capabilities/shell.d.ts +15 -0
  144. package/dist/sandbox/capabilities/shell.js +130 -0
  145. package/dist/sandbox/capabilities/shell.js.map +1 -0
  146. package/dist/sandbox/capabilities/shell.mjs +127 -0
  147. package/dist/sandbox/capabilities/shell.mjs.map +1 -0
  148. package/dist/sandbox/capabilities/skills.d.ts +47 -0
  149. package/dist/sandbox/capabilities/skills.js +453 -0
  150. package/dist/sandbox/capabilities/skills.js.map +1 -0
  151. package/dist/sandbox/capabilities/skills.mjs +449 -0
  152. package/dist/sandbox/capabilities/skills.mjs.map +1 -0
  153. package/dist/sandbox/capabilities/transport.d.ts +3 -0
  154. package/dist/sandbox/capabilities/transport.js +33 -0
  155. package/dist/sandbox/capabilities/transport.js.map +1 -0
  156. package/dist/sandbox/capabilities/transport.mjs +28 -0
  157. package/dist/sandbox/capabilities/transport.mjs.map +1 -0
  158. package/dist/sandbox/client.d.ts +53 -0
  159. package/dist/sandbox/client.js +34 -0
  160. package/dist/sandbox/client.js.map +1 -0
  161. package/dist/sandbox/client.mjs +31 -0
  162. package/dist/sandbox/client.mjs.map +1 -0
  163. package/dist/sandbox/entries/factories.d.ts +17 -0
  164. package/dist/sandbox/entries/factories.js +112 -0
  165. package/dist/sandbox/entries/factories.js.map +1 -0
  166. package/dist/sandbox/entries/factories.mjs +94 -0
  167. package/dist/sandbox/entries/factories.mjs.map +1 -0
  168. package/dist/sandbox/entries/guards.d.ts +5 -0
  169. package/dist/sandbox/entries/guards.js +19 -0
  170. package/dist/sandbox/entries/guards.js.map +1 -0
  171. package/dist/sandbox/entries/guards.mjs +13 -0
  172. package/dist/sandbox/entries/guards.mjs.map +1 -0
  173. package/dist/sandbox/entries/index.d.ts +3 -0
  174. package/dist/sandbox/entries/index.js +26 -0
  175. package/dist/sandbox/entries/index.js.map +1 -0
  176. package/dist/sandbox/entries/index.mjs +3 -0
  177. package/dist/sandbox/entries/index.mjs.map +1 -0
  178. package/dist/sandbox/entries/types.d.ts +177 -0
  179. package/dist/sandbox/entries/types.js +3 -0
  180. package/dist/sandbox/entries/types.js.map +1 -0
  181. package/dist/sandbox/entries/types.mjs +2 -0
  182. package/dist/sandbox/entries/types.mjs.map +1 -0
  183. package/dist/sandbox/errors.d.ts +151 -0
  184. package/dist/sandbox/errors.js +303 -0
  185. package/dist/sandbox/errors.js.map +1 -0
  186. package/dist/sandbox/errors.mjs +251 -0
  187. package/dist/sandbox/errors.mjs.map +1 -0
  188. package/dist/sandbox/events.d.ts +51 -0
  189. package/dist/sandbox/events.js +104 -0
  190. package/dist/sandbox/events.js.map +1 -0
  191. package/dist/sandbox/events.mjs +95 -0
  192. package/dist/sandbox/events.mjs.map +1 -0
  193. package/dist/sandbox/index.d.ts +14 -0
  194. package/dist/sandbox/index.js +31 -0
  195. package/dist/sandbox/index.js.map +1 -0
  196. package/dist/sandbox/index.mjs +15 -0
  197. package/dist/sandbox/index.mjs.map +1 -0
  198. package/dist/sandbox/internal.d.ts +7 -0
  199. package/dist/sandbox/internal.js +46 -0
  200. package/dist/sandbox/internal.js.map +1 -0
  201. package/dist/sandbox/internal.mjs +8 -0
  202. package/dist/sandbox/internal.mjs.map +1 -0
  203. package/dist/sandbox/local.d.ts +3 -0
  204. package/dist/sandbox/local.js +20 -0
  205. package/dist/sandbox/local.js.map +1 -0
  206. package/dist/sandbox/local.mjs +4 -0
  207. package/dist/sandbox/local.mjs.map +1 -0
  208. package/dist/sandbox/localSkills.d.ts +13 -0
  209. package/dist/sandbox/localSkills.js +62 -0
  210. package/dist/sandbox/localSkills.js.map +1 -0
  211. package/dist/sandbox/localSkills.mjs +59 -0
  212. package/dist/sandbox/localSkills.mjs.map +1 -0
  213. package/dist/sandbox/manifest.d.ts +86 -0
  214. package/dist/sandbox/manifest.js +553 -0
  215. package/dist/sandbox/manifest.js.map +1 -0
  216. package/dist/sandbox/manifest.mjs +545 -0
  217. package/dist/sandbox/manifest.mjs.map +1 -0
  218. package/dist/sandbox/memory/generation.d.ts +56 -0
  219. package/dist/sandbox/memory/generation.js +426 -0
  220. package/dist/sandbox/memory/generation.js.map +1 -0
  221. package/dist/sandbox/memory/generation.mjs +385 -0
  222. package/dist/sandbox/memory/generation.mjs.map +1 -0
  223. package/dist/sandbox/memory/prompts.d.ts +16 -0
  224. package/dist/sandbox/memory/prompts.js +1685 -0
  225. package/dist/sandbox/memory/prompts.js.map +1 -0
  226. package/dist/sandbox/memory/prompts.mjs +1679 -0
  227. package/dist/sandbox/memory/prompts.mjs.map +1 -0
  228. package/dist/sandbox/memory/rollouts.d.ts +33 -0
  229. package/dist/sandbox/memory/rollouts.js +228 -0
  230. package/dist/sandbox/memory/rollouts.js.map +1 -0
  231. package/dist/sandbox/memory/rollouts.mjs +221 -0
  232. package/dist/sandbox/memory/rollouts.mjs.map +1 -0
  233. package/dist/sandbox/memory/storage.d.ts +70 -0
  234. package/dist/sandbox/memory/storage.js +543 -0
  235. package/dist/sandbox/memory/storage.js.map +1 -0
  236. package/dist/sandbox/memory/storage.mjs +537 -0
  237. package/dist/sandbox/memory/storage.mjs.map +1 -0
  238. package/dist/sandbox/pathGrants.d.ts +11 -0
  239. package/dist/sandbox/pathGrants.js +28 -0
  240. package/dist/sandbox/pathGrants.js.map +1 -0
  241. package/dist/sandbox/pathGrants.mjs +25 -0
  242. package/dist/sandbox/pathGrants.mjs.map +1 -0
  243. package/dist/sandbox/permissions.d.ts +29 -0
  244. package/dist/sandbox/permissions.js +140 -0
  245. package/dist/sandbox/permissions.js.map +1 -0
  246. package/dist/sandbox/permissions.mjs +134 -0
  247. package/dist/sandbox/permissions.mjs.map +1 -0
  248. package/dist/sandbox/runtime/agentKeys.d.ts +7 -0
  249. package/dist/sandbox/runtime/agentKeys.js +76 -0
  250. package/dist/sandbox/runtime/agentKeys.js.map +1 -0
  251. package/dist/sandbox/runtime/agentKeys.mjs +69 -0
  252. package/dist/sandbox/runtime/agentKeys.mjs.map +1 -0
  253. package/dist/sandbox/runtime/agentPreparation.d.ts +20 -0
  254. package/dist/sandbox/runtime/agentPreparation.js +178 -0
  255. package/dist/sandbox/runtime/agentPreparation.js.map +1 -0
  256. package/dist/sandbox/runtime/agentPreparation.mjs +172 -0
  257. package/dist/sandbox/runtime/agentPreparation.mjs.map +1 -0
  258. package/dist/sandbox/runtime/index.d.ts +5 -0
  259. package/dist/sandbox/runtime/index.js +22 -0
  260. package/dist/sandbox/runtime/index.js.map +1 -0
  261. package/dist/sandbox/runtime/index.mjs +6 -0
  262. package/dist/sandbox/runtime/index.mjs.map +1 -0
  263. package/dist/sandbox/runtime/livePreservedSessions.d.ts +25 -0
  264. package/dist/sandbox/runtime/livePreservedSessions.js +58 -0
  265. package/dist/sandbox/runtime/livePreservedSessions.js.map +1 -0
  266. package/dist/sandbox/runtime/livePreservedSessions.mjs +51 -0
  267. package/dist/sandbox/runtime/livePreservedSessions.mjs.map +1 -0
  268. package/dist/sandbox/runtime/manager.d.ts +68 -0
  269. package/dist/sandbox/runtime/manager.js +704 -0
  270. package/dist/sandbox/runtime/manager.js.map +1 -0
  271. package/dist/sandbox/runtime/manager.mjs +697 -0
  272. package/dist/sandbox/runtime/manager.mjs.map +1 -0
  273. package/dist/sandbox/runtime/prompts.d.ts +6 -0
  274. package/dist/sandbox/runtime/prompts.js +108 -0
  275. package/dist/sandbox/runtime/prompts.js.map +1 -0
  276. package/dist/sandbox/runtime/prompts.mjs +101 -0
  277. package/dist/sandbox/runtime/prompts.mjs.map +1 -0
  278. package/dist/sandbox/runtime/providedSessionManifest.d.ts +3 -0
  279. package/dist/sandbox/runtime/providedSessionManifest.js +175 -0
  280. package/dist/sandbox/runtime/providedSessionManifest.js.map +1 -0
  281. package/dist/sandbox/runtime/providedSessionManifest.mjs +172 -0
  282. package/dist/sandbox/runtime/providedSessionManifest.mjs.map +1 -0
  283. package/dist/sandbox/runtime/runAsManifest.d.ts +4 -0
  284. package/dist/sandbox/runtime/runAsManifest.js +40 -0
  285. package/dist/sandbox/runtime/runAsManifest.js.map +1 -0
  286. package/dist/sandbox/runtime/runAsManifest.mjs +36 -0
  287. package/dist/sandbox/runtime/runAsManifest.mjs.map +1 -0
  288. package/dist/sandbox/runtime/sessionLifecycle.d.ts +6 -0
  289. package/dist/sandbox/runtime/sessionLifecycle.js +222 -0
  290. package/dist/sandbox/runtime/sessionLifecycle.js.map +1 -0
  291. package/dist/sandbox/runtime/sessionLifecycle.mjs +215 -0
  292. package/dist/sandbox/runtime/sessionLifecycle.mjs.map +1 -0
  293. package/dist/sandbox/runtime/sessionSerialization.d.ts +12 -0
  294. package/dist/sandbox/runtime/sessionSerialization.js +74 -0
  295. package/dist/sandbox/runtime/sessionSerialization.js.map +1 -0
  296. package/dist/sandbox/runtime/sessionSerialization.mjs +71 -0
  297. package/dist/sandbox/runtime/sessionSerialization.mjs.map +1 -0
  298. package/dist/sandbox/runtime/sessionState.d.ts +26 -0
  299. package/dist/sandbox/runtime/sessionState.js +113 -0
  300. package/dist/sandbox/runtime/sessionState.js.map +1 -0
  301. package/dist/sandbox/runtime/sessionState.mjs +104 -0
  302. package/dist/sandbox/runtime/sessionState.mjs.map +1 -0
  303. package/dist/sandbox/runtime/spans.d.ts +1 -0
  304. package/dist/sandbox/runtime/spans.js +51 -0
  305. package/dist/sandbox/runtime/spans.js.map +1 -0
  306. package/dist/sandbox/runtime/spans.mjs +48 -0
  307. package/dist/sandbox/runtime/spans.mjs.map +1 -0
  308. package/dist/sandbox/runtime/toolRehydration.d.ts +34 -0
  309. package/dist/sandbox/runtime/toolRehydration.js +207 -0
  310. package/dist/sandbox/runtime/toolRehydration.js.map +1 -0
  311. package/dist/sandbox/runtime/toolRehydration.mjs +200 -0
  312. package/dist/sandbox/runtime/toolRehydration.mjs.map +1 -0
  313. package/dist/sandbox/sandboxes/docker.d.ts +75 -0
  314. package/dist/sandbox/sandboxes/docker.js +2015 -0
  315. package/dist/sandbox/sandboxes/docker.js.map +1 -0
  316. package/dist/sandbox/sandboxes/docker.mjs +2010 -0
  317. package/dist/sandbox/sandboxes/docker.mjs.map +1 -0
  318. package/dist/sandbox/sandboxes/index.d.ts +3 -0
  319. package/dist/sandbox/sandboxes/index.js +20 -0
  320. package/dist/sandbox/sandboxes/index.js.map +1 -0
  321. package/dist/sandbox/sandboxes/index.mjs +4 -0
  322. package/dist/sandbox/sandboxes/index.mjs.map +1 -0
  323. package/dist/sandbox/sandboxes/shared/localSnapshotPaths.d.ts +1 -0
  324. package/dist/sandbox/sandboxes/shared/localSnapshotPaths.js +22 -0
  325. package/dist/sandbox/sandboxes/shared/localSnapshotPaths.js.map +1 -0
  326. package/dist/sandbox/sandboxes/shared/localSnapshotPaths.mjs +19 -0
  327. package/dist/sandbox/sandboxes/shared/localSnapshotPaths.mjs.map +1 -0
  328. package/dist/sandbox/sandboxes/shared/localSnapshots.d.ts +34 -0
  329. package/dist/sandbox/sandboxes/shared/localSnapshots.js +525 -0
  330. package/dist/sandbox/sandboxes/shared/localSnapshots.js.map +1 -0
  331. package/dist/sandbox/sandboxes/shared/localSnapshots.mjs +508 -0
  332. package/dist/sandbox/sandboxes/shared/localSnapshots.mjs.map +1 -0
  333. package/dist/sandbox/sandboxes/shared/localWorkspace.d.ts +27 -0
  334. package/dist/sandbox/sandboxes/shared/localWorkspace.js +693 -0
  335. package/dist/sandbox/sandboxes/shared/localWorkspace.js.map +1 -0
  336. package/dist/sandbox/sandboxes/shared/localWorkspace.mjs +684 -0
  337. package/dist/sandbox/sandboxes/shared/localWorkspace.mjs.map +1 -0
  338. package/dist/sandbox/sandboxes/shared/manifestPersistence.d.ts +15 -0
  339. package/dist/sandbox/sandboxes/shared/manifestPersistence.js +191 -0
  340. package/dist/sandbox/sandboxes/shared/manifestPersistence.js.map +1 -0
  341. package/dist/sandbox/sandboxes/shared/manifestPersistence.mjs +182 -0
  342. package/dist/sandbox/sandboxes/shared/manifestPersistence.mjs.map +1 -0
  343. package/dist/sandbox/sandboxes/shared/pty.d.ts +9 -0
  344. package/dist/sandbox/sandboxes/shared/pty.js +151 -0
  345. package/dist/sandbox/sandboxes/shared/pty.js.map +1 -0
  346. package/dist/sandbox/sandboxes/shared/pty.mjs +148 -0
  347. package/dist/sandbox/sandboxes/shared/pty.mjs.map +1 -0
  348. package/dist/sandbox/sandboxes/shared/runProcess.d.ts +16 -0
  349. package/dist/sandbox/sandboxes/shared/runProcess.js +90 -0
  350. package/dist/sandbox/sandboxes/shared/runProcess.js.map +1 -0
  351. package/dist/sandbox/sandboxes/shared/runProcess.mjs +86 -0
  352. package/dist/sandbox/sandboxes/shared/runProcess.mjs.map +1 -0
  353. package/dist/sandbox/sandboxes/shared/sessionStateValues.d.ts +18 -0
  354. package/dist/sandbox/sandboxes/shared/sessionStateValues.js +40 -0
  355. package/dist/sandbox/sandboxes/shared/sessionStateValues.js.map +1 -0
  356. package/dist/sandbox/sandboxes/shared/sessionStateValues.mjs +35 -0
  357. package/dist/sandbox/sandboxes/shared/sessionStateValues.mjs.map +1 -0
  358. package/dist/sandbox/sandboxes/shared/shellCommand.d.ts +17 -0
  359. package/dist/sandbox/sandboxes/shared/shellCommand.js +38 -0
  360. package/dist/sandbox/sandboxes/shared/shellCommand.js.map +1 -0
  361. package/dist/sandbox/sandboxes/shared/shellCommand.mjs +34 -0
  362. package/dist/sandbox/sandboxes/shared/shellCommand.mjs.map +1 -0
  363. package/dist/sandbox/sandboxes/types.d.ts +11 -0
  364. package/dist/sandbox/sandboxes/types.js +3 -0
  365. package/dist/sandbox/sandboxes/types.js.map +1 -0
  366. package/dist/sandbox/sandboxes/types.mjs +2 -0
  367. package/dist/sandbox/sandboxes/types.mjs.map +1 -0
  368. package/dist/sandbox/sandboxes/unixLocal.d.ts +95 -0
  369. package/dist/sandbox/sandboxes/unixLocal.js +863 -0
  370. package/dist/sandbox/sandboxes/unixLocal.js.map +1 -0
  371. package/dist/sandbox/sandboxes/unixLocal.mjs +858 -0
  372. package/dist/sandbox/sandboxes/unixLocal.mjs.map +1 -0
  373. package/dist/sandbox/session.d.ts +123 -0
  374. package/dist/sandbox/session.js +58 -0
  375. package/dist/sandbox/session.js.map +1 -0
  376. package/dist/sandbox/session.mjs +50 -0
  377. package/dist/sandbox/session.mjs.map +1 -0
  378. package/dist/sandbox/shared/compare.d.ts +2 -0
  379. package/dist/sandbox/shared/compare.js +13 -0
  380. package/dist/sandbox/shared/compare.js.map +1 -0
  381. package/dist/sandbox/shared/compare.mjs +9 -0
  382. package/dist/sandbox/shared/compare.mjs.map +1 -0
  383. package/dist/sandbox/shared/environment.d.ts +14 -0
  384. package/dist/sandbox/shared/environment.js +69 -0
  385. package/dist/sandbox/shared/environment.js.map +1 -0
  386. package/dist/sandbox/shared/environment.mjs +59 -0
  387. package/dist/sandbox/shared/environment.mjs.map +1 -0
  388. package/dist/sandbox/shared/hostPath.d.ts +4 -0
  389. package/dist/sandbox/shared/hostPath.js +22 -0
  390. package/dist/sandbox/shared/hostPath.js.map +1 -0
  391. package/dist/sandbox/shared/hostPath.mjs +16 -0
  392. package/dist/sandbox/shared/hostPath.mjs.map +1 -0
  393. package/dist/sandbox/shared/manifestCollections.d.ts +12 -0
  394. package/dist/sandbox/shared/manifestCollections.js +40 -0
  395. package/dist/sandbox/shared/manifestCollections.js.map +1 -0
  396. package/dist/sandbox/shared/manifestCollections.mjs +34 -0
  397. package/dist/sandbox/shared/manifestCollections.mjs.map +1 -0
  398. package/dist/sandbox/shared/media.d.ts +6 -0
  399. package/dist/sandbox/shared/media.js +126 -0
  400. package/dist/sandbox/shared/media.js.map +1 -0
  401. package/dist/sandbox/shared/media.mjs +119 -0
  402. package/dist/sandbox/shared/media.mjs.map +1 -0
  403. package/dist/sandbox/shared/output.d.ts +12 -0
  404. package/dist/sandbox/shared/output.js +108 -0
  405. package/dist/sandbox/shared/output.js.map +1 -0
  406. package/dist/sandbox/shared/output.mjs +103 -0
  407. package/dist/sandbox/shared/output.mjs.map +1 -0
  408. package/dist/sandbox/shared/posixPath.d.ts +7 -0
  409. package/dist/sandbox/shared/posixPath.js +90 -0
  410. package/dist/sandbox/shared/posixPath.js.map +1 -0
  411. package/dist/sandbox/shared/posixPath.mjs +81 -0
  412. package/dist/sandbox/shared/posixPath.mjs.map +1 -0
  413. package/dist/sandbox/shared/remoteMountCommandAllowlist.d.ts +3 -0
  414. package/dist/sandbox/shared/remoteMountCommandAllowlist.js +33 -0
  415. package/dist/sandbox/shared/remoteMountCommandAllowlist.js.map +1 -0
  416. package/dist/sandbox/shared/remoteMountCommandAllowlist.mjs +28 -0
  417. package/dist/sandbox/shared/remoteMountCommandAllowlist.mjs.map +1 -0
  418. package/dist/sandbox/shared/shell.d.ts +1 -0
  419. package/dist/sandbox/shared/shell.js +7 -0
  420. package/dist/sandbox/shared/shell.js.map +1 -0
  421. package/dist/sandbox/shared/shell.mjs +4 -0
  422. package/dist/sandbox/shared/shell.mjs.map +1 -0
  423. package/dist/sandbox/shared/stableJson.d.ts +12 -0
  424. package/dist/sandbox/shared/stableJson.js +40 -0
  425. package/dist/sandbox/shared/stableJson.js.map +1 -0
  426. package/dist/sandbox/shared/stableJson.mjs +35 -0
  427. package/dist/sandbox/shared/stableJson.mjs.map +1 -0
  428. package/dist/sandbox/shared/typeGuards.d.ts +6 -0
  429. package/dist/sandbox/shared/typeGuards.js +34 -0
  430. package/dist/sandbox/shared/typeGuards.js.map +1 -0
  431. package/dist/sandbox/shared/typeGuards.mjs +26 -0
  432. package/dist/sandbox/shared/typeGuards.mjs.map +1 -0
  433. package/dist/sandbox/snapshot.d.ts +60 -0
  434. package/dist/sandbox/snapshot.js +45 -0
  435. package/dist/sandbox/snapshot.js.map +1 -0
  436. package/dist/sandbox/snapshot.mjs +39 -0
  437. package/dist/sandbox/snapshot.mjs.map +1 -0
  438. package/dist/sandbox/users.d.ts +11 -0
  439. package/dist/sandbox/users.js +31 -0
  440. package/dist/sandbox/users.js.map +1 -0
  441. package/dist/sandbox/users.mjs +26 -0
  442. package/dist/sandbox/users.mjs.map +1 -0
  443. package/dist/sandbox/workspacePaths.d.ts +20 -0
  444. package/dist/sandbox/workspacePaths.js +73 -0
  445. package/dist/sandbox/workspacePaths.js.map +1 -0
  446. package/dist/sandbox/workspacePaths.mjs +69 -0
  447. package/dist/sandbox/workspacePaths.mjs.map +1 -0
  448. package/dist/tool.js +1 -1
  449. package/dist/tool.js.map +1 -1
  450. package/dist/tool.mjs +1 -1
  451. package/dist/tool.mjs.map +1 -1
  452. package/dist/types/protocol.d.ts +8 -0
  453. package/dist/types/protocol.js +1 -0
  454. package/dist/types/protocol.js.map +1 -1
  455. package/dist/types/protocol.mjs +1 -0
  456. package/dist/types/protocol.mjs.map +1 -1
  457. package/dist/utils/messages.d.ts +6 -0
  458. package/dist/utils/messages.js +21 -0
  459. package/dist/utils/messages.js.map +1 -1
  460. package/dist/utils/messages.mjs +20 -0
  461. package/dist/utils/messages.mjs.map +1 -1
  462. package/dist/utils/strictToolSchema.d.ts +4 -0
  463. package/dist/utils/strictToolSchema.js +358 -0
  464. package/dist/utils/strictToolSchema.js.map +1 -0
  465. package/dist/utils/strictToolSchema.mjs +353 -0
  466. package/dist/utils/strictToolSchema.mjs.map +1 -0
  467. package/dist/utils/tools.d.ts +3 -1
  468. package/dist/utils/tools.js +18 -7
  469. package/dist/utils/tools.js.map +1 -1
  470. package/dist/utils/tools.mjs +18 -7
  471. package/dist/utils/tools.mjs.map +1 -1
  472. package/dist/utils/zodJsonSchemaCompat.js +18 -16
  473. package/dist/utils/zodJsonSchemaCompat.js.map +1 -1
  474. package/dist/utils/zodJsonSchemaCompat.mjs +18 -16
  475. package/dist/utils/zodJsonSchemaCompat.mjs.map +1 -1
  476. package/package.json +25 -1
package/dist/runState.mjs CHANGED
@@ -13,11 +13,13 @@ import { getCurrentTrace } from "./tracing/index.mjs";
13
13
  import logger from "./logger.mjs";
14
14
  import { handoff } from "./handoff.mjs";
15
15
  import * as protocol from "./types/protocol.mjs";
16
+ import { SANDBOX_SESSION_STATE_VERSION } from "./sandbox/session.mjs";
16
17
  import { safeExecute } from "./utils/safeExecute.mjs";
17
18
  import { getClientToolSearchExecutor, getToolSearchRuntimeToolKey, } from "./tool.mjs";
18
19
  import { getFunctionToolQualifiedName, toolQualifiedName, resolveFunctionToolCallName, } from "./toolIdentity.mjs";
19
20
  import { getToolSearchExecution, getToolSearchOutputReplacementKey, resolveToolSearchCallId, } from "./utils/toolSearch.mjs";
20
21
  import { executeCustomClientToolSearch, getClientToolSearchHelper, } from "./runner/toolSearch.mjs";
22
+ import { getSerializedApplyPatchToolPlaceholder, getSerializedComputerToolPlaceholder, getSerializedFunctionToolPlaceholder, getSerializedShellToolPlaceholder, } from "./sandbox/runtime/toolRehydration.mjs";
21
23
  /**
22
24
  * The schema version of the serialized run state. This is used to ensure that the serialized
23
25
  * run state is compatible with the current version of the SDK.
@@ -36,8 +38,12 @@ import { executeCustomClientToolSearch, getClientToolSearchHelper, } from "./run
36
38
  * - 1.7: Adds optional approval rejection messages.
37
39
  * - 1.8: Adds tool search item variants, batched computer actions, and GA computer tool
38
40
  * aliasing to serialized run state payloads.
41
+ * - 1.9: Adds optional sandbox session persistence with a versioned session-state
42
+ * envelope for sandbox-agent resume.
43
+ * - 1.10: Adds optional stable agent identity keys so duplicate-name agent graphs can
44
+ * serialize and resume without ambiguous name resolution.
39
45
  */
40
- export const CURRENT_SCHEMA_VERSION = '1.8';
46
+ export const CURRENT_SCHEMA_VERSION = '1.10';
41
47
  const SUPPORTED_SCHEMA_VERSIONS = [
42
48
  '1.0',
43
49
  '1.1',
@@ -47,11 +53,14 @@ const SUPPORTED_SCHEMA_VERSIONS = [
47
53
  '1.5',
48
54
  '1.6',
49
55
  '1.7',
56
+ '1.8',
57
+ '1.9',
50
58
  CURRENT_SCHEMA_VERSION,
51
59
  ];
52
60
  const $schemaVersion = z.enum(SUPPORTED_SCHEMA_VERSIONS);
53
61
  const serializedAgentSchema = z.object({
54
62
  name: z.string(),
63
+ identity: z.string().optional(),
55
64
  });
56
65
  const serializedSpanBase = z.object({
57
66
  object: z.literal('trace.span'),
@@ -160,6 +169,32 @@ const serializedTraceSchema = z.object({
160
169
  // and serialization opts in to include it. By default this is omitted to avoid persisting secrets.
161
170
  tracing_api_key: z.string().optional().nullable(),
162
171
  });
172
+ const sandboxSessionStateEnvelopeSchema = z.object({
173
+ version: z.literal(SANDBOX_SESSION_STATE_VERSION),
174
+ backendId: z.string(),
175
+ manifest: z.record(z.string(), z.any()),
176
+ snapshot: z.record(z.string(), z.any()).nullable().optional(),
177
+ snapshotFingerprint: z.string().nullable().optional(),
178
+ snapshotFingerprintVersion: z.string().nullable().optional(),
179
+ workspaceReady: z.boolean(),
180
+ exposedPorts: z.record(z.string(), z.any()).optional(),
181
+ providerState: z.record(z.string(), z.any()),
182
+ });
183
+ const sandboxSessionEntrySchema = z.object({
184
+ backendId: z.string(),
185
+ currentAgentKey: z.string(),
186
+ currentAgentName: z.string(),
187
+ sessionState: sandboxSessionStateEnvelopeSchema,
188
+ preservedOwnedSession: z.boolean().optional(),
189
+ reuseLiveSession: z.boolean().optional(),
190
+ });
191
+ const sandboxStateSchema = z.object({
192
+ backendId: z.string(),
193
+ currentAgentKey: z.string(),
194
+ currentAgentName: z.string(),
195
+ sessionState: sandboxSessionStateEnvelopeSchema,
196
+ sessionsByAgent: z.record(z.string(), sandboxSessionEntrySchema),
197
+ });
163
198
  const serializedProcessedResponseSchema = z.object({
164
199
  newItems: z.array(itemSchema),
165
200
  toolsUsed: z.array(z.string()),
@@ -300,6 +335,7 @@ export const SerializedRunState = z.object({
300
335
  previousResponseId: z.string().optional(),
301
336
  reasoningItemIdPolicy: z.enum(['preserve', 'omit']).optional(),
302
337
  trace: serializedTraceSchema.nullable(),
338
+ sandbox: sandboxStateSchema.optional(),
303
339
  });
304
340
  /**
305
341
  * Serializable snapshot of an agent's run, including context, usage and trace.
@@ -438,10 +474,14 @@ export class RunState {
438
474
  */
439
475
  _trace = null;
440
476
  /**
441
- * Runtime-only tool_search-loaded tools, scoped by agent name and preserved across turns for
477
+ * Runtime-only tool_search-loaded tools, scoped by agent object and preserved across turns for
442
478
  * the lifetime of this in-memory run.
443
479
  */
444
- _toolSearchRuntimeToolsByAgentName = new Map();
480
+ _toolSearchRuntimeToolsByAgent = new Map();
481
+ /**
482
+ * Persisted sandbox session metadata for sandbox-agent resume.
483
+ */
484
+ _sandbox = undefined;
445
485
  constructor(context, originalInput, startingAgent, maxTurns) {
446
486
  this._context = context;
447
487
  this._agentToolInvocation = undefined;
@@ -481,20 +521,20 @@ export class RunState {
481
521
  setCurrentAgentSpan(span) {
482
522
  this._currentAgentSpan = span;
483
523
  }
484
- getOrCreateToolSearchRuntimeToolState(agentName) {
485
- let state = this._toolSearchRuntimeToolsByAgentName.get(agentName);
524
+ getOrCreateToolSearchRuntimeToolState(agent) {
525
+ let state = this._toolSearchRuntimeToolsByAgent.get(agent);
486
526
  if (!state) {
487
527
  state = {
488
528
  anonymousEntries: [],
489
529
  keyedEntries: new Map(),
490
530
  nextOrder: 0,
491
531
  };
492
- this._toolSearchRuntimeToolsByAgentName.set(agentName, state);
532
+ this._toolSearchRuntimeToolsByAgent.set(agent, state);
493
533
  }
494
534
  return state;
495
535
  }
496
536
  recordToolSearchRuntimeTools(agent, toolSearchOutput, tools) {
497
- const runtimeState = this.getOrCreateToolSearchRuntimeToolState(agent.name);
537
+ const runtimeState = this.getOrCreateToolSearchRuntimeToolState(agent);
498
538
  const entry = {
499
539
  order: runtimeState.nextOrder++,
500
540
  tools,
@@ -507,7 +547,7 @@ export class RunState {
507
547
  runtimeState.anonymousEntries.push(entry);
508
548
  }
509
549
  getToolSearchRuntimeTools(agent) {
510
- const runtimeState = this._toolSearchRuntimeToolsByAgentName.get(agent.name);
550
+ const runtimeState = this._toolSearchRuntimeToolsByAgent.get(agent);
511
551
  if (!runtimeState) {
512
552
  return [];
513
553
  }
@@ -644,15 +684,13 @@ export class RunState {
644
684
  * rehydrate in a separate process that lacks the original environment variables).
645
685
  */
646
686
  toJSON(options = {}) {
647
- buildAgentMap(this.#startingAgent);
687
+ const agentIdentity = buildAgentIdentityMap(this.#startingAgent);
648
688
  const includeTracingApiKey = options.includeTracingApiKey === true;
649
689
  const contextJson = this._context.toJSON();
650
690
  const output = {
651
691
  $schemaVersion: CURRENT_SCHEMA_VERSION,
652
692
  currentTurn: this._currentTurn,
653
- currentAgent: {
654
- name: this._currentAgent.name,
655
- },
693
+ currentAgent: serializeAgentReference(this._currentAgent, agentIdentity.byAgent),
656
694
  originalInput: this._originalInput,
657
695
  modelResponses: this._modelResponses.map((response) => {
658
696
  return {
@@ -684,7 +722,9 @@ export class RunState {
684
722
  };
685
723
  }),
686
724
  context: contextJson,
687
- toolUseTracker: this._toolUseTracker.toJSON(),
725
+ toolUseTracker: this._toolUseTracker.toJSON({
726
+ agentIdentityKeys: agentIdentity.byAgent,
727
+ }),
688
728
  maxTurns: this._maxTurns,
689
729
  currentAgentSpan: this._currentAgentSpan?.toJSON(),
690
730
  noActiveAgentRun: this._noActiveAgentRun,
@@ -692,22 +732,25 @@ export class RunState {
692
732
  inputGuardrailResults: this._inputGuardrailResults,
693
733
  outputGuardrailResults: this._outputGuardrailResults.map((r) => ({
694
734
  ...r,
695
- agent: r.agent.toJSON(),
735
+ agent: serializeAgentReference(r.agent, agentIdentity.byAgent),
696
736
  })),
697
737
  toolInputGuardrailResults: this._toolInputGuardrailResults,
698
738
  toolOutputGuardrailResults: this._toolOutputGuardrailResults,
699
- currentStep: this._currentStep,
739
+ currentStep: serializeCurrentStep(this._currentStep, agentIdentity.byAgent),
700
740
  lastModelResponse: this._lastTurnResponse,
701
- generatedItems: this._generatedItems.map((item) => item.toJSON()),
741
+ generatedItems: this._generatedItems.map((item) => serializeRunItem(item, agentIdentity.byAgent)),
702
742
  pendingAgentToolRuns: Object.fromEntries(this._pendingAgentToolRuns.entries()),
703
743
  currentTurnPersistedItemCount: this._currentTurnPersistedItemCount,
704
- lastProcessedResponse: this._lastProcessedResponse,
744
+ lastProcessedResponse: this._lastProcessedResponse
745
+ ? serializeProcessedResponse(this._lastProcessedResponse, agentIdentity.byAgent)
746
+ : undefined,
705
747
  conversationId: this._conversationId,
706
748
  previousResponseId: this._previousResponseId,
707
749
  reasoningItemIdPolicy: this._reasoningItemIdPolicy,
708
750
  trace: this._trace
709
751
  ? this._trace.toJSON({ includeTracingApiKey })
710
752
  : null,
753
+ sandbox: this._sandbox,
711
754
  };
712
755
  // parsing the schema to ensure the output is valid for reparsing
713
756
  const parsed = SerializedRunState.safeParse(output);
@@ -760,7 +803,9 @@ async function buildRunStateFromString(initialAgent, str, options = {}) {
760
803
  return buildRunStateFromJson(initialAgent, stateJson, options);
761
804
  }
762
805
  function assertSchemaVersionSupportsToolSearch(schemaVersion, stateJson) {
763
- if (schemaVersion === '1.8') {
806
+ if (schemaVersion === '1.8' ||
807
+ schemaVersion === '1.9' ||
808
+ schemaVersion === CURRENT_SCHEMA_VERSION) {
764
809
  return;
765
810
  }
766
811
  if (!containsSerializedToolSearchState(stateJson)) {
@@ -768,6 +813,9 @@ function assertSchemaVersionSupportsToolSearch(schemaVersion, stateJson) {
768
813
  }
769
814
  throw new UserError(`Run state schema version ${schemaVersion} does not support tool_search items. Please reserialize the run state with schema ${CURRENT_SCHEMA_VERSION}.`);
770
815
  }
816
+ function schemaVersionSupportsAgentIdentity(schemaVersion) {
817
+ return schemaVersion === CURRENT_SCHEMA_VERSION;
818
+ }
771
819
  function containsSerializedToolSearchState(stateJson) {
772
820
  return (containsToolSearchProtocolItems(stateJson.originalInput) ||
773
821
  containsToolSearchInModelResponses(stateJson.modelResponses) ||
@@ -871,17 +919,17 @@ function assertRuntimeToolKeysMatch(args) {
871
919
  throw new UserError(`RunState cannot resume custom client tool_search call ${callId} for agent ${agent.name} because the registered execute callback returned runtime tools [${formatRuntimeToolKeys(actualRuntimeToolKeys)}] but the serialized state expects [${formatRuntimeToolKeys(expectedRuntimeToolKeys)}].`);
872
920
  }
873
921
  async function getConfiguredAgentTools(args) {
874
- const { agent, context, configuredToolsByAgentName } = args;
875
- const existing = configuredToolsByAgentName.get(agent.name);
922
+ const { agent, context, configuredToolsByAgent } = args;
923
+ const existing = configuredToolsByAgent.get(agent);
876
924
  if (existing) {
877
925
  return existing;
878
926
  }
879
927
  const configuredTools = (await agent.getAllTools(context));
880
- configuredToolsByAgentName.set(agent.name, configuredTools);
928
+ configuredToolsByAgent.set(agent, configuredTools);
881
929
  return configuredTools;
882
930
  }
883
931
  async function rehydrateToolSearchRuntimeTools(state) {
884
- const configuredToolsByAgentName = new Map();
932
+ const configuredToolsByAgent = new Map();
885
933
  const pendingToolSearchCalls = new Map();
886
934
  for (const item of state._generatedItems) {
887
935
  if (item instanceof RunToolSearchCallItem) {
@@ -889,10 +937,14 @@ async function rehydrateToolSearchRuntimeTools(state) {
889
937
  continue;
890
938
  }
891
939
  const callId = resolveToolSearchCallId(item.rawItem);
892
- pendingToolSearchCalls.set(`${item.agent.name}:${callId}`, {
940
+ const agent = item.agent;
941
+ const pendingCallsById = pendingToolSearchCalls.get(agent) ??
942
+ new Map();
943
+ pendingCallsById.set(callId, {
893
944
  agent: item.agent,
894
945
  toolSearchCall: item.rawItem,
895
946
  });
947
+ pendingToolSearchCalls.set(agent, pendingCallsById);
896
948
  continue;
897
949
  }
898
950
  if (!(item instanceof RunToolSearchOutputItem)) {
@@ -904,7 +956,7 @@ async function rehydrateToolSearchRuntimeTools(state) {
904
956
  const configuredTools = await getConfiguredAgentTools({
905
957
  agent: item.agent,
906
958
  context: state._context,
907
- configuredToolsByAgentName,
959
+ configuredToolsByAgent,
908
960
  });
909
961
  const configuredToolKeys = getRuntimeToolKeys(configuredTools, {
910
962
  allowUnsupported: true,
@@ -914,7 +966,9 @@ async function rehydrateToolSearchRuntimeTools(state) {
914
966
  continue;
915
967
  }
916
968
  const callId = resolveToolSearchCallId(item.rawItem);
917
- const pendingCall = pendingToolSearchCalls.get(`${item.agent.name}:${callId}`);
969
+ const pendingCall = pendingToolSearchCalls
970
+ .get(item.agent)
971
+ ?.get(callId);
918
972
  if (!pendingCall) {
919
973
  throw new UserError(`RunState cannot resume custom client tool_search output ${callId} for agent ${item.agent.name} because the serialized state is missing the matching tool_search call item.`);
920
974
  }
@@ -957,7 +1011,9 @@ async function rehydrateToolSearchRuntimeTools(state) {
957
1011
  }
958
1012
  }
959
1013
  async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
960
- const agentMap = buildAgentMap(initialAgent);
1014
+ const agentMap = schemaVersionSupportsAgentIdentity(stateJson.$schemaVersion)
1015
+ ? buildAgentIdentityMap(initialAgent).byIdentity
1016
+ : buildAgentMap(initialAgent);
961
1017
  const contextOverride = options.contextOverride;
962
1018
  const contextStrategy = options.contextStrategy ?? 'merge';
963
1019
  //
@@ -982,10 +1038,7 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
982
1038
  //
983
1039
  // Find the current agent from the initial agent
984
1040
  //
985
- const currentAgent = agentMap.get(stateJson.currentAgent.name);
986
- if (!currentAgent) {
987
- throw new UserError(`Agent ${stateJson.currentAgent.name} not found`);
988
- }
1041
+ const currentAgent = resolveSerializedAgent(stateJson.currentAgent, agentMap);
989
1042
  const state = new RunState(context, '', initialAgent, stateJson.maxTurns);
990
1043
  state._currentAgent = currentAgent;
991
1044
  state._currentTurn = stateJson.currentTurn;
@@ -996,7 +1049,13 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
996
1049
  // rebuild tool use tracker
997
1050
  state._toolUseTracker = new AgentToolUseTracker();
998
1051
  for (const [agentName, toolNames] of Object.entries(stateJson.toolUseTracker)) {
999
- state._toolUseTracker.addToolUse(agentMap.get(agentName), toolNames, { allowEmpty: true });
1052
+ const agent = agentMap.get(agentName);
1053
+ if (!agent) {
1054
+ throw new UserError(`Agent ${agentName} not found`);
1055
+ }
1056
+ state._toolUseTracker.addToolUse(agent, toolNames, {
1057
+ allowEmpty: true,
1058
+ });
1000
1059
  }
1001
1060
  state._pendingAgentToolRuns = new Map(Object.entries(stateJson.pendingAgentToolRuns ?? {}));
1002
1061
  // rebuild current agent span
@@ -1019,7 +1078,7 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
1019
1078
  stateJson.inputGuardrailResults;
1020
1079
  state._outputGuardrailResults = stateJson.outputGuardrailResults.map((r) => ({
1021
1080
  ...r,
1022
- agent: agentMap.get(r.agent.name),
1081
+ agent: resolveSerializedAgent(r.agent, agentMap),
1023
1082
  }));
1024
1083
  state._toolInputGuardrailResults =
1025
1084
  stateJson.toolInputGuardrailResults;
@@ -1034,6 +1093,7 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
1034
1093
  state._generatedItems = stateJson.generatedItems.map((item) => deserializeItem(item, agentMap));
1035
1094
  state._currentTurnPersistedItemCount =
1036
1095
  stateJson.currentTurnPersistedItemCount ?? 0;
1096
+ state._sandbox = stateJson.sandbox ?? undefined;
1037
1097
  await rehydrateToolSearchRuntimeTools(state);
1038
1098
  state._lastProcessedResponse = stateJson.lastProcessedResponse
1039
1099
  ? await deserializeProcessedResponse(agentMap, state, stateJson.lastProcessedResponse)
@@ -1041,7 +1101,7 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
1041
1101
  if (stateJson.currentStep?.type === 'next_step_handoff') {
1042
1102
  state._currentStep = {
1043
1103
  type: 'next_step_handoff',
1044
- newAgent: agentMap.get(stateJson.currentStep.newAgent.name),
1104
+ newAgent: resolveSerializedAgent(stateJson.currentStep.newAgent, agentMap),
1045
1105
  };
1046
1106
  }
1047
1107
  else if (stateJson.currentStep?.type === 'next_step_interruption') {
@@ -1055,6 +1115,20 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
1055
1115
  }
1056
1116
  return state;
1057
1117
  }
1118
+ /**
1119
+ * @internal
1120
+ */
1121
+ export async function rehydrateProcessedResponseTools(initialAgent, state, executionTools) {
1122
+ if (!state._lastProcessedResponse) {
1123
+ return;
1124
+ }
1125
+ const agentIdentity = buildAgentIdentityMap(initialAgent);
1126
+ const serializedProcessedResponse = serializeProcessedResponse(state._lastProcessedResponse, agentIdentity.byAgent);
1127
+ state._lastProcessedResponse = await deserializeProcessedResponse(agentIdentity.byIdentity, state, serializedProcessedResponse, {
1128
+ executionTools,
1129
+ allowSerializedExecutionToolPlaceholder: false,
1130
+ });
1131
+ }
1058
1132
  /**
1059
1133
  * @internal
1060
1134
  */
@@ -1090,6 +1164,249 @@ export function buildAgentMap(initialAgent) {
1090
1164
  }
1091
1165
  return map;
1092
1166
  }
1167
+ /**
1168
+ * @internal
1169
+ */
1170
+ export function buildAgentIdentityMap(initialAgent) {
1171
+ const agents = collectAgentGraph(initialAgent);
1172
+ const groups = new Map();
1173
+ const literalNames = new Set();
1174
+ for (const entry of agents) {
1175
+ literalNames.add(entry.agent.name);
1176
+ const group = groups.get(entry.agent.name) ?? [];
1177
+ group.push(entry);
1178
+ groups.set(entry.agent.name, group);
1179
+ }
1180
+ const byIdentity = new Map();
1181
+ const byAgent = new Map();
1182
+ const usedIdentities = new Set();
1183
+ for (const [agentName, group] of groups) {
1184
+ const sortedGroup = group.length === 1
1185
+ ? group
1186
+ : [...group].sort((left, right) => {
1187
+ if (left.agent === initialAgent) {
1188
+ return -1;
1189
+ }
1190
+ if (right.agent === initialAgent) {
1191
+ return 1;
1192
+ }
1193
+ const leftSignature = getAgentIdentitySignature(left.agent);
1194
+ const rightSignature = getAgentIdentitySignature(right.agent);
1195
+ if (leftSignature !== rightSignature) {
1196
+ return leftSignature < rightSignature ? -1 : 1;
1197
+ }
1198
+ return left.index - right.index;
1199
+ });
1200
+ let nextSuffix = 0;
1201
+ for (const { agent } of sortedGroup) {
1202
+ let identity;
1203
+ do {
1204
+ identity =
1205
+ nextSuffix === 0 ? agentName : `${agentName}#${nextSuffix + 1}`;
1206
+ nextSuffix += 1;
1207
+ } while (usedIdentities.has(identity) ||
1208
+ (identity !== agent.name && literalNames.has(identity)));
1209
+ usedIdentities.add(identity);
1210
+ byIdentity.set(identity, agent);
1211
+ byAgent.set(agent, identity);
1212
+ }
1213
+ }
1214
+ return { byIdentity, byAgent };
1215
+ }
1216
+ function collectAgentGraph(initialAgent) {
1217
+ const agents = [];
1218
+ const visitedAgents = new Set();
1219
+ const queue = [initialAgent];
1220
+ while (queue.length > 0) {
1221
+ const currentAgent = queue.shift();
1222
+ if (visitedAgents.has(currentAgent)) {
1223
+ continue;
1224
+ }
1225
+ visitedAgents.add(currentAgent);
1226
+ agents.push({ agent: currentAgent, index: agents.length });
1227
+ for (const handoff of currentAgent.handoffs) {
1228
+ if (handoff instanceof Agent) {
1229
+ queue.push(handoff);
1230
+ }
1231
+ else if (handoff.agent) {
1232
+ queue.push(handoff.agent);
1233
+ }
1234
+ }
1235
+ for (const tool of currentAgent.tools) {
1236
+ const sourceAgent = getAgentToolSourceAgent(tool);
1237
+ if (sourceAgent) {
1238
+ queue.push(sourceAgent);
1239
+ }
1240
+ }
1241
+ }
1242
+ return agents;
1243
+ }
1244
+ function getAgentIdentitySignature(agent) {
1245
+ const sandboxAgent = agent;
1246
+ const signature = {
1247
+ type: agent.constructor?.name,
1248
+ name: agent.name,
1249
+ handoffDescription: agent.handoffDescription,
1250
+ instructions: summarizeIdentityValue(agent.instructions),
1251
+ prompt: summarizeIdentityValue(agent.prompt),
1252
+ model: summarizeIdentityValue(agent.model),
1253
+ modelSettings: summarizeIdentityValue(agent.modelSettings),
1254
+ tools: agent.tools.map(summarizeToolIdentity),
1255
+ handoffs: agent.handoffs.map((entry) => entry instanceof Agent
1256
+ ? { type: 'agent', name: entry.name }
1257
+ : {
1258
+ type: 'handoff',
1259
+ toolName: entry.toolName,
1260
+ agentName: entry.agentName,
1261
+ targetName: entry.agent?.name,
1262
+ }),
1263
+ mcpServers: agent.mcpServers.map(summarizeIdentityValue),
1264
+ inputGuardrails: agent.inputGuardrails.map(summarizeIdentityValue),
1265
+ outputGuardrails: agent.outputGuardrails.map(summarizeIdentityValue),
1266
+ outputType: summarizeIdentityValue(agent.outputType),
1267
+ toolUseBehavior: summarizeIdentityValue(agent.toolUseBehavior),
1268
+ resetToolChoice: agent.resetToolChoice,
1269
+ defaultManifest: summarizeIdentityValue(sandboxAgent.defaultManifest),
1270
+ baseInstructions: summarizeIdentityValue(sandboxAgent.baseInstructions),
1271
+ capabilities: sandboxAgent.capabilities?.map(summarizeIdentityValue),
1272
+ runAs: summarizeIdentityValue(sandboxAgent.runAs),
1273
+ };
1274
+ return stableStringify(signature);
1275
+ }
1276
+ function summarizeToolIdentity(tool) {
1277
+ return {
1278
+ type: tool.type,
1279
+ name: tool.name,
1280
+ namespace: tool.namespace,
1281
+ strict: tool.strict,
1282
+ parameters: summarizeIdentityValue(tool.parameters),
1283
+ };
1284
+ }
1285
+ function summarizeIdentityValue(value) {
1286
+ return normalizeForIdentity(value, new WeakSet(), 0);
1287
+ }
1288
+ function normalizeForIdentity(value, seen, depth) {
1289
+ if (value === null || typeof value === 'undefined') {
1290
+ return value;
1291
+ }
1292
+ if (typeof value === 'string' ||
1293
+ typeof value === 'number' ||
1294
+ typeof value === 'boolean') {
1295
+ return value;
1296
+ }
1297
+ if (typeof value === 'function') {
1298
+ return `[function:${value.name || 'anonymous'}]`;
1299
+ }
1300
+ if (typeof value !== 'object') {
1301
+ return String(value);
1302
+ }
1303
+ if (seen.has(value)) {
1304
+ return '[circular]';
1305
+ }
1306
+ if (depth >= 4) {
1307
+ return `[${value.constructor?.name ?? 'Object'}]`;
1308
+ }
1309
+ seen.add(value);
1310
+ if (Array.isArray(value)) {
1311
+ return value.map((item) => normalizeForIdentity(item, seen, depth + 1));
1312
+ }
1313
+ if (value instanceof Map) {
1314
+ return [...value.entries()]
1315
+ .map(([key, entryValue]) => [
1316
+ normalizeForIdentity(key, seen, depth + 1),
1317
+ normalizeForIdentity(entryValue, seen, depth + 1),
1318
+ ])
1319
+ .sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));
1320
+ }
1321
+ if (value instanceof Set) {
1322
+ return [...value.values()]
1323
+ .map((entry) => normalizeForIdentity(entry, seen, depth + 1))
1324
+ .sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));
1325
+ }
1326
+ const record = value;
1327
+ const normalized = {
1328
+ constructor: value.constructor?.name,
1329
+ };
1330
+ for (const key of Object.keys(record).sort()) {
1331
+ normalized[key] = normalizeForIdentity(record[key], seen, depth + 1);
1332
+ }
1333
+ return normalized;
1334
+ }
1335
+ function stableStringify(value) {
1336
+ return JSON.stringify(value, (_key, currentValue) => {
1337
+ if (!currentValue ||
1338
+ typeof currentValue !== 'object' ||
1339
+ Array.isArray(currentValue)) {
1340
+ return currentValue;
1341
+ }
1342
+ return Object.fromEntries(Object.entries(currentValue).sort(([left], [right]) => left.localeCompare(right)));
1343
+ });
1344
+ }
1345
+ function serializeAgentReference(agent, agentIdentityKeys) {
1346
+ const identity = agentIdentityKeys.get(agent);
1347
+ if (!identity || identity === agent.name) {
1348
+ return { name: agent.name };
1349
+ }
1350
+ return { name: agent.name, identity };
1351
+ }
1352
+ function resolveSerializedAgent(serializedAgent, agentMap, fallbackAgent) {
1353
+ const identity = serializedAgent.identity ?? serializedAgent.name;
1354
+ const agent = agentMap.get(identity);
1355
+ if (agent) {
1356
+ return agent;
1357
+ }
1358
+ if (!serializedAgent.identity && fallbackAgent) {
1359
+ return fallbackAgent;
1360
+ }
1361
+ if (serializedAgent.identity) {
1362
+ throw new UserError(`Agent identity ${serializedAgent.identity} not found`);
1363
+ }
1364
+ throw new UserError(`Agent ${serializedAgent.name} not found`);
1365
+ }
1366
+ function serializeRunItem(item, agentIdentityKeys) {
1367
+ const serialized = item.toJSON();
1368
+ switch (item.type) {
1369
+ case 'handoff_output_item':
1370
+ serialized.sourceAgent = serializeAgentReference(item.sourceAgent, agentIdentityKeys);
1371
+ serialized.targetAgent = serializeAgentReference(item.targetAgent, agentIdentityKeys);
1372
+ return serialized;
1373
+ default:
1374
+ serialized.agent = serializeAgentReference(item.agent, agentIdentityKeys);
1375
+ return serialized;
1376
+ }
1377
+ }
1378
+ function serializeCurrentStep(currentStep, agentIdentityKeys) {
1379
+ if (!currentStep) {
1380
+ return undefined;
1381
+ }
1382
+ if (currentStep.type === 'next_step_handoff') {
1383
+ return {
1384
+ ...currentStep,
1385
+ newAgent: serializeAgentReference(currentStep.newAgent, agentIdentityKeys),
1386
+ };
1387
+ }
1388
+ if (currentStep.type === 'next_step_interruption') {
1389
+ const interruptions = Array.isArray(currentStep.data?.interruptions)
1390
+ ? currentStep.data.interruptions.map((item) => item instanceof RunToolApprovalItem
1391
+ ? serializeRunItem(item, agentIdentityKeys)
1392
+ : item)
1393
+ : currentStep.data?.interruptions;
1394
+ return {
1395
+ ...currentStep,
1396
+ data: {
1397
+ ...currentStep.data,
1398
+ interruptions,
1399
+ },
1400
+ };
1401
+ }
1402
+ return currentStep;
1403
+ }
1404
+ function serializeProcessedResponse(processedResponse, agentIdentityKeys) {
1405
+ return {
1406
+ ...processedResponse,
1407
+ newItems: processedResponse.newItems.map((item) => serializeRunItem(item, agentIdentityKeys)),
1408
+ };
1409
+ }
1093
1410
  /**
1094
1411
  * @internal
1095
1412
  */
@@ -1128,23 +1445,23 @@ export function deserializeModelResponse(serializedModelResponse) {
1128
1445
  export function deserializeItem(serializedItem, agentMap) {
1129
1446
  switch (serializedItem.type) {
1130
1447
  case 'message_output_item':
1131
- return new RunMessageOutputItem(serializedItem.rawItem, agentMap.get(serializedItem.agent.name));
1448
+ return new RunMessageOutputItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
1132
1449
  case 'tool_search_call_item':
1133
- return new RunToolSearchCallItem(serializedItem.rawItem, agentMap.get(serializedItem.agent.name));
1450
+ return new RunToolSearchCallItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
1134
1451
  case 'tool_search_output_item':
1135
- return new RunToolSearchOutputItem(serializedItem.rawItem, agentMap.get(serializedItem.agent.name));
1452
+ return new RunToolSearchOutputItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
1136
1453
  case 'tool_call_item':
1137
- return new RunToolCallItem(serializedItem.rawItem, agentMap.get(serializedItem.agent.name));
1454
+ return new RunToolCallItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
1138
1455
  case 'tool_call_output_item':
1139
- return new RunToolCallOutputItem(serializedItem.rawItem, agentMap.get(serializedItem.agent.name), serializedItem.output);
1456
+ return new RunToolCallOutputItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap), serializedItem.output);
1140
1457
  case 'reasoning_item':
1141
- return new RunReasoningItem(serializedItem.rawItem, agentMap.get(serializedItem.agent.name));
1458
+ return new RunReasoningItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
1142
1459
  case 'handoff_call_item':
1143
- return new RunHandoffCallItem(serializedItem.rawItem, agentMap.get(serializedItem.agent.name));
1460
+ return new RunHandoffCallItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
1144
1461
  case 'handoff_output_item':
1145
- return new RunHandoffOutputItem(serializedItem.rawItem, agentMap.get(serializedItem.sourceAgent.name), agentMap.get(serializedItem.targetAgent.name));
1462
+ return new RunHandoffOutputItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.sourceAgent, agentMap), resolveSerializedAgent(serializedItem.targetAgent, agentMap));
1146
1463
  case 'tool_approval_item':
1147
- return new RunToolApprovalItem(serializedItem.rawItem, agentMap.get(serializedItem.agent.name), serializedItem.toolName);
1464
+ return new RunToolApprovalItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap), serializedItem.toolName);
1148
1465
  }
1149
1466
  }
1150
1467
  function deserializeInterruptionItem(serializedItem, agentMap, currentAgent) {
@@ -1154,7 +1471,7 @@ function deserializeInterruptionItem(serializedItem, agentMap, currentAgent) {
1154
1471
  const parsed = itemSchema.safeParse(serializedItem);
1155
1472
  if (parsed.success) {
1156
1473
  if (parsed.data.type === 'tool_approval_item') {
1157
- const mappedAgent = agentMap.get(parsed.data.agent.name) ?? currentAgent;
1474
+ const mappedAgent = resolveSerializedAgent(parsed.data.agent, agentMap, currentAgent);
1158
1475
  return new RunToolApprovalItem(parsed.data.rawItem, mappedAgent, parsed.data.toolName);
1159
1476
  }
1160
1477
  const item = deserializeItem(parsed.data, agentMap);
@@ -1178,7 +1495,15 @@ function deserializeInterruptionItem(serializedItem, agentMap, currentAgent) {
1178
1495
  const agentName = value.agent && typeof value.agent.name === 'string'
1179
1496
  ? value.agent.name
1180
1497
  : undefined;
1181
- const mappedAgent = (agentName ? agentMap.get(agentName) : undefined) ?? currentAgent;
1498
+ const agentIdentity = value.agent && typeof value.agent.identity === 'string'
1499
+ ? value.agent.identity
1500
+ : undefined;
1501
+ const mappedAgent = agentName || agentIdentity
1502
+ ? resolveSerializedAgent({
1503
+ name: agentName ?? currentAgent.name,
1504
+ identity: agentIdentity,
1505
+ }, agentMap, currentAgent)
1506
+ : currentAgent;
1182
1507
  const toolName = typeof value.toolName === 'string'
1183
1508
  ? value.toolName
1184
1509
  : typeof rawItem.name === 'string'
@@ -1197,13 +1522,15 @@ function deserializeInterruptions(serializedInterruptions, agentMap, currentAgen
1197
1522
  /**
1198
1523
  * @internal
1199
1524
  */
1200
- async function deserializeProcessedResponse(agentMap, state, serializedProcessedResponse) {
1525
+ async function deserializeProcessedResponse(agentMap, state, serializedProcessedResponse, options = {}) {
1201
1526
  const currentAgent = state._currentAgent;
1202
- const configuredTools = await currentAgent.getAllTools(state._context);
1527
+ const configuredTools = options.executionTools ?? (await currentAgent.getAllTools(state._context));
1203
1528
  const allTools = [
1204
1529
  ...configuredTools,
1205
1530
  ...state.getToolSearchRuntimeTools(currentAgent),
1206
1531
  ];
1532
+ const baseAgentTools = currentAgent.tools;
1533
+ const allowSerializedExecutionToolPlaceholder = options.allowSerializedExecutionToolPlaceholder ?? true;
1207
1534
  const tools = new Map(allTools
1208
1535
  .filter((tool) => tool.type === 'function')
1209
1536
  .map((tool) => [getFunctionToolQualifiedName(tool) ?? tool.name, tool]));
@@ -1250,17 +1577,33 @@ async function deserializeProcessedResponse(agentMap, state, serializedProcessed
1250
1577
  functions: await Promise.all(serializedProcessedResponse.functions.map(async (functionCall) => {
1251
1578
  const toolIdentity = resolveFunctionToolCallName(functionCall.toolCall, tools) ??
1252
1579
  functionCall.tool.name;
1253
- if (!tools.has(toolIdentity)) {
1580
+ const resolvedTool = tools.get(toolIdentity) ??
1581
+ getSerializedFunctionToolPlaceholder({
1582
+ agent: currentAgent,
1583
+ baseAgentTools,
1584
+ serializedTool: functionCall.tool,
1585
+ toolCall: functionCall.toolCall,
1586
+ toolIdentity,
1587
+ allowSerializedExecutionToolPlaceholder,
1588
+ });
1589
+ if (!resolvedTool) {
1254
1590
  throw new UserError(`Tool ${toolIdentity} not found`);
1255
1591
  }
1256
1592
  return {
1257
1593
  toolCall: functionCall.toolCall,
1258
- tool: tools.get(toolIdentity),
1594
+ tool: resolvedTool,
1259
1595
  };
1260
1596
  })),
1261
1597
  computerActions: serializedProcessedResponse.computerActions.map((computerAction) => {
1262
1598
  const toolName = computerAction.computer.name;
1263
- const computerTool = resolveComputerTool(toolName);
1599
+ const computerTool = resolveComputerTool(toolName) ??
1600
+ getSerializedComputerToolPlaceholder({
1601
+ agent: currentAgent,
1602
+ baseAgentTools,
1603
+ serializedTool: computerAction.computer,
1604
+ toolName,
1605
+ allowSerializedExecutionToolPlaceholder,
1606
+ });
1264
1607
  if (!computerTool) {
1265
1608
  throw new UserError(`Computer tool ${toolName} not found`);
1266
1609
  }
@@ -1271,22 +1614,38 @@ async function deserializeProcessedResponse(agentMap, state, serializedProcessed
1271
1614
  }),
1272
1615
  shellActions: (serializedProcessedResponse.shellActions ?? []).map((shellAction) => {
1273
1616
  const toolName = shellAction.shell.name;
1274
- if (!shellTools.has(toolName)) {
1617
+ const shellTool = shellTools.get(toolName) ??
1618
+ getSerializedShellToolPlaceholder({
1619
+ agent: currentAgent,
1620
+ baseAgentTools,
1621
+ serializedTool: shellAction.shell,
1622
+ toolName,
1623
+ allowSerializedExecutionToolPlaceholder,
1624
+ });
1625
+ if (!shellTool) {
1275
1626
  throw new UserError(`Shell tool ${toolName} not found`);
1276
1627
  }
1277
1628
  return {
1278
1629
  toolCall: shellAction.toolCall,
1279
- shell: shellTools.get(toolName),
1630
+ shell: shellTool,
1280
1631
  };
1281
1632
  }),
1282
1633
  applyPatchActions: (serializedProcessedResponse.applyPatchActions ?? []).map((applyPatchAction) => {
1283
1634
  const toolName = applyPatchAction.applyPatch.name;
1284
- if (!applyPatchTools.has(toolName)) {
1635
+ const applyPatchTool = applyPatchTools.get(toolName) ??
1636
+ getSerializedApplyPatchToolPlaceholder({
1637
+ agent: currentAgent,
1638
+ baseAgentTools,
1639
+ serializedTool: applyPatchAction.applyPatch,
1640
+ toolName,
1641
+ allowSerializedExecutionToolPlaceholder,
1642
+ });
1643
+ if (!applyPatchTool) {
1285
1644
  throw new UserError(`Apply patch tool ${toolName} not found`);
1286
1645
  }
1287
1646
  return {
1288
1647
  toolCall: applyPatchAction.toolCall,
1289
- applyPatch: applyPatchTools.get(toolName),
1648
+ applyPatch: applyPatchTool,
1290
1649
  };
1291
1650
  }),
1292
1651
  mcpApprovalRequests: (serializedProcessedResponse.mcpApprovalRequests ?? []).map((approvalRequest) => ({