deepline 0.3.530 → 0.3.531

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 (139) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +6 -0
  3. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +10 -8
  4. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +95 -9
  5. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +7 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +615 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +16 -1
  8. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +26 -8
  9. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +27 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/tool-call-retry-facts.ts +317 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +129 -39
  12. package/dist/cli/{auth-LRWNDQFT.mjs → auth-33B3OEM4.mjs} +5 -5
  13. package/dist/cli/auth-3UDRBF5D.js +43 -0
  14. package/dist/cli/{billing-7T73MRYF.mjs → billing-X4OQRH6D.mjs} +7 -7
  15. package/dist/cli/{billing-5FDPWGCG.js → billing-Y2M2ABLW.js} +82 -82
  16. package/dist/cli/{chunk-5DJUNUHN.mjs → chunk-2CUPFDW5.mjs} +5 -5
  17. package/dist/cli/{chunk-V4EK7ZZX.js → chunk-2WWTIR2G.js} +98 -98
  18. package/dist/cli/{chunk-YI7QOP6L.js → chunk-3PMVNMG4.js} +16 -16
  19. package/dist/cli/{chunk-2FLODRM2.js → chunk-4M4AASO3.js} +13 -13
  20. package/dist/cli/{chunk-KUHH7RW4.js → chunk-4O7UET74.js} +44 -44
  21. package/dist/cli/{chunk-VYSQ76RP.js → chunk-4WPHK2R3.js} +7 -7
  22. package/dist/cli/{chunk-YVLPGYRS.mjs → chunk-567HD6G6.mjs} +1 -1
  23. package/dist/cli/{chunk-QWEPCX6L.mjs → chunk-57PPAYDB.mjs} +2 -2
  24. package/dist/cli/{chunk-SJQ7Z3NI.js → chunk-5M24K577.js} +132 -81
  25. package/dist/cli/{chunk-4VQ63Y6S.mjs → chunk-623FFVZU.mjs} +5 -5
  26. package/dist/cli/{chunk-QI2LKPW5.mjs → chunk-6W73VXMK.mjs} +2 -2
  27. package/dist/cli/{chunk-7E7CP5KA.js → chunk-BUK6WHY2.js} +4 -4
  28. package/dist/cli/{chunk-QQ4LNSY5.mjs → chunk-CVOFP6BU.mjs} +1 -1
  29. package/dist/cli/{chunk-4WPIORJX.js → chunk-D5BLTX5L.js} +1 -1
  30. package/dist/cli/{chunk-E6L3NEFV.js → chunk-DWYX5DFJ.js} +41 -41
  31. package/dist/cli/{chunk-K4Y6CNFV.mjs → chunk-EURLINZT.mjs} +1 -1
  32. package/dist/cli/{chunk-7FCD34YS.mjs → chunk-EVXRQXNV.mjs} +3 -2
  33. package/dist/cli/{chunk-L4QR7CYL.js → chunk-H26ZSNLX.js} +14 -14
  34. package/dist/cli/{chunk-6NG3FRJB.mjs → chunk-HYPLMUMA.mjs} +5 -5
  35. package/dist/cli/{chunk-M4Q4LEMM.js → chunk-IOOWKPF7.js} +2 -2
  36. package/dist/cli/{chunk-MHR3XVJD.js → chunk-IXOEKHOY.js} +5 -5
  37. package/dist/cli/{chunk-32NTC5UD.js → chunk-JFTO33FK.js} +7 -7
  38. package/dist/cli/{chunk-VKVLJTW5.js → chunk-L4XVL4LW.js} +9 -9
  39. package/dist/cli/{chunk-MVF7ZBJX.mjs → chunk-MGWYYTZN.mjs} +1 -1
  40. package/dist/cli/{chunk-2LKVNWRA.mjs → chunk-MYTA37IL.mjs} +10 -10
  41. package/dist/cli/{chunk-D7Y7I4EE.js → chunk-NXEQMKSM.js} +2 -2
  42. package/dist/cli/{chunk-EADHDZW2.js → chunk-O267YGUV.js} +6 -6
  43. package/dist/cli/{chunk-X547OW3I.js → chunk-O4NTPEQV.js} +16 -16
  44. package/dist/cli/{chunk-LNZILMVK.mjs → chunk-O7EFJR6Y.mjs} +4 -4
  45. package/dist/cli/{chunk-GW76IDID.js → chunk-PTKSHGUM.js} +22 -22
  46. package/dist/cli/{chunk-J6XSBTEX.mjs → chunk-PTOPMO22.mjs} +1 -1
  47. package/dist/cli/{chunk-WWLIDAVT.js → chunk-RBPCXQBE.js} +11 -11
  48. package/dist/cli/{chunk-5B37ER3C.js → chunk-RLRPEHQ3.js} +3 -3
  49. package/dist/cli/{chunk-C44RZGM5.js → chunk-RZXSCWEB.js} +26 -26
  50. package/dist/cli/{chunk-OUM2V7R6.mjs → chunk-SPODXGBZ.mjs} +6 -6
  51. package/dist/cli/{chunk-KEXGBXUG.js → chunk-TDJCNVDE.js} +5 -5
  52. package/dist/cli/{chunk-KI63L5H3.mjs → chunk-TU7HU5K2.mjs} +2 -2
  53. package/dist/cli/{chunk-HCWPX2UP.mjs → chunk-U5YBINPF.mjs} +2 -2
  54. package/dist/cli/{chunk-ERMDXXP5.mjs → chunk-UNTFERUX.mjs} +1 -1
  55. package/dist/cli/{chunk-WL6GAZBD.js → chunk-V6LUMGVI.js} +3 -2
  56. package/dist/cli/{chunk-3MAHDV5C.mjs → chunk-VGWUCBNA.mjs} +1 -1
  57. package/dist/cli/{chunk-5KX3TWBK.mjs → chunk-VHIHGMZD.mjs} +1 -1
  58. package/dist/cli/{chunk-A5MYJM4K.mjs → chunk-VWOOOU6G.mjs} +2 -2
  59. package/dist/cli/{chunk-WYI3VMTO.js → chunk-WDLY4HST.js} +6 -6
  60. package/dist/cli/{chunk-7WGMCOM6.js → chunk-WHAMLN6B.js} +2 -2
  61. package/dist/cli/{chunk-BVY4QRVT.mjs → chunk-XOXKVLJZ.mjs} +82 -31
  62. package/dist/cli/{chunk-2FLRKNME.mjs → chunk-XQGLHKDI.mjs} +2 -2
  63. package/dist/cli/{chunk-XNWS2WJG.mjs → chunk-XWQI4TMS.mjs} +1 -1
  64. package/dist/cli/{chunk-VQMGCNX2.mjs → chunk-YMGQP7WI.mjs} +5 -5
  65. package/dist/cli/{chunk-WAWOMHWO.mjs → chunk-YVOFNLGN.mjs} +2 -2
  66. package/dist/cli/{chunk-MVFKZQ7E.js → chunk-ZBL4CP75.js} +3 -3
  67. package/dist/cli/{chunk-I2YXEHDO.mjs → chunk-ZJQITGPV.mjs} +3 -3
  68. package/dist/cli/command-docs.js +2 -2
  69. package/dist/cli/command-docs.mjs +1 -1
  70. package/dist/cli/{csv-VY2S7KKV.mjs → csv-CMUWCM46.mjs} +4 -4
  71. package/dist/cli/{csv-EFIEDJA2.js → csv-N4P2XOKP.js} +13 -13
  72. package/dist/cli/{db-3DLI5TYW.js → db-GFI45WV5.js} +27 -27
  73. package/dist/cli/{db-D32CBDTN.mjs → db-J5HFGOUO.mjs} +6 -6
  74. package/dist/cli/describe-HFUWQN3A.js +50 -0
  75. package/dist/cli/{describe-6MYKK2P3.mjs → describe-NKHH3VVI.mjs} +18 -18
  76. package/dist/cli/{executions-U6TPX4RX.mjs → executions-54QEYYE6.mjs} +6 -6
  77. package/dist/cli/{executions-QG3DEEY3.js → executions-FMWHU72C.js} +8 -8
  78. package/dist/cli/{feedback-YZ6H4VMQ.mjs → feedback-HA4QUWMU.mjs} +6 -6
  79. package/dist/cli/{feedback-ZSPW6NXL.js → feedback-R7C3AZKN.js} +14 -14
  80. package/dist/cli/git-ETBABM6D.js +25 -0
  81. package/dist/cli/{git-ENN72IK4.mjs → git-OVG63PJV.mjs} +5 -5
  82. package/dist/cli/index.js +145 -145
  83. package/dist/cli/index.mjs +44 -44
  84. package/dist/cli/{legacy-noops-Q6EVYIGN.js → legacy-noops-GM2F7GMV.js} +9 -9
  85. package/dist/cli/{legacy-noops-MNA6LWJU.mjs → legacy-noops-PLQWYZ7A.mjs} +6 -6
  86. package/dist/cli/{monitors-KENWEEWC.mjs → monitors-QXK7JTRG.mjs} +7 -7
  87. package/dist/cli/{monitors-BUH54HXJ.js → monitors-SJBIPV4K.js} +100 -100
  88. package/dist/cli/{org-HWOHKYP3.mjs → org-OFMMMVYT.mjs} +6 -6
  89. package/dist/cli/{org-AHWQJMV7.js → org-XKO7BBT4.js} +86 -86
  90. package/dist/cli/{pages-I7DYTCW6.mjs → pages-NDI2K34M.mjs} +6 -6
  91. package/dist/cli/{pages-Z5R7NYEF.js → pages-ZGXRON5S.js} +18 -18
  92. package/dist/cli/{play-3LXZB4ED.js → play-2YD5NTH6.js} +317 -317
  93. package/dist/cli/{play-ET7CRVWJ.mjs → play-SMKNTBRK.mjs} +18 -18
  94. package/dist/cli/{providers-ZV2E7NGX.js → providers-52PIA36O.js} +9 -9
  95. package/dist/cli/{providers-GZSAZVHZ.mjs → providers-6SKF5W4Y.mjs} +6 -6
  96. package/dist/cli/{quickstart-VJZAT4RY.js → quickstart-4Z22WVLK.js} +6 -6
  97. package/dist/cli/{quickstart-5746NBS2.mjs → quickstart-RVA335ED.mjs} +4 -4
  98. package/dist/cli/{run-WGUAVYZC.js → run-FDTSTMDM.js} +41 -41
  99. package/dist/cli/{run-WOQ6XMTT.mjs → run-GMN4TCVV.mjs} +23 -23
  100. package/dist/cli/{search-NNPFJYEW.mjs → search-2FG2USCF.mjs} +8 -8
  101. package/dist/cli/search-63X5FPDM.js +33 -0
  102. package/dist/cli/{search-output-K4ISMPKD.js → search-output-5FKQYLFW.js} +6 -6
  103. package/dist/cli/{search-output-65HDEEFS.mjs → search-output-AC3AAV6E.mjs} +4 -4
  104. package/dist/cli/{secrets-NBKGWMF4.js → secrets-5A7AY2YU.js} +15 -15
  105. package/dist/cli/{secrets-RK44OV3X.mjs → secrets-MA4ZTNVG.mjs} +6 -6
  106. package/dist/cli/{sessions-ULQJJN3J.mjs → sessions-LBYKV5O4.mjs} +6 -6
  107. package/dist/cli/sessions-SMWWKKD4.js +22 -0
  108. package/dist/cli/{settings-V5ZRL2EF.mjs → settings-6MQVNROV.mjs} +13 -13
  109. package/dist/cli/{settings-IHNA7X3Y.js → settings-HA3D4GNZ.js} +86 -86
  110. package/dist/cli/{setup-HTEBFMOQ.js → setup-3JWTNSOK.js} +78 -63
  111. package/dist/cli/{setup-54VZPJGM.mjs → setup-BXCUZOZH.mjs} +28 -13
  112. package/dist/cli/{skills-3FCPWMHX.mjs → skills-7ASML2WZ.mjs} +8 -8
  113. package/dist/cli/skills-OJ7NZL6S.js +37 -0
  114. package/dist/cli/{tools-2NTDNUQT.mjs → tools-7IJWJXZ3.mjs} +17 -17
  115. package/dist/cli/tools-Y2VMPUSI.js +57 -0
  116. package/dist/cli/{update-25MTBTGU.mjs → update-JFKH4SVK.mjs} +10 -10
  117. package/dist/cli/update-JURCS2FE.js +35 -0
  118. package/dist/cli/{views-OBE5LUSW.mjs → views-2EURG3P5.mjs} +6 -6
  119. package/dist/cli/{views-37K4JNNS.js → views-XTAIIX2Y.js} +18 -18
  120. package/dist/cli/{workflow-HAPCL4K6.mjs → workflow-7FCQ34QD.mjs} +7 -7
  121. package/dist/cli/{workflow-6YTIHHJH.js → workflow-AXOF74HO.js} +17 -17
  122. package/dist/index.js +9 -9
  123. package/dist/index.mjs +6 -6
  124. package/dist/install-integrity.json +108 -106
  125. package/dist/release.d.mts +1 -1
  126. package/dist/release.d.ts +1 -1
  127. package/dist/release.js +2 -2
  128. package/dist/release.mjs +1 -1
  129. package/dist/server.js +5 -5
  130. package/dist/server.mjs +3 -3
  131. package/package.json +1 -1
  132. package/dist/cli/auth-QFIXECQV.js +0 -43
  133. package/dist/cli/describe-U6HM52X6.js +0 -50
  134. package/dist/cli/git-OBV73OVY.js +0 -25
  135. package/dist/cli/search-IGHNMXI4.js +0 -33
  136. package/dist/cli/sessions-ZJNV4SEL.js +0 -22
  137. package/dist/cli/skills-ZCJ6FOOK.js +0 -37
  138. package/dist/cli/tools-Q75XC2BS.js +0 -57
  139. package/dist/cli/update-3G3GO7IE.js +0 -35
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
205
205
  // getters keep their established compatibility behavior.
206
206
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
207
207
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
208
- version: '0.3.530',
208
+ version: '0.3.531',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -25,3 +25,9 @@ export const FLEET_REFUSAL = {
25
25
  } as const;
26
26
  export const MAX_MEMBER_DEFINITION_BYTES = 2_048;
27
27
  export const MAX_FLEET_SETTLE_ITEMS = 100;
28
+ /**
29
+ * How long a convergence claim leases its members. The create path posts
30
+ * only well inside it (KAR-260): a pass past it may have lost its members to
31
+ * a reclaim, and a POST then races the release that reclaim makes.
32
+ */
33
+ export const FLEET_CONVERGENCE_LEASE_MS = 90_000;
@@ -227,10 +227,10 @@ export async function uploadBufferToR2(input: {
227
227
  const bucketKind = input.bucketKind ?? 'default';
228
228
  const configStartedAt = Date.now();
229
229
  const config = getR2Config(bucketKind);
230
- logR2Perf('config', input.key, configStartedAt, { kind: bucketKind });
230
+ const configMs = Date.now() - configStartedAt;
231
231
  const clientStartedAt = Date.now();
232
232
  const client = getR2Client(config);
233
- logR2Perf('client', input.key, clientStartedAt, { kind: bucketKind });
233
+ const clientMs = Date.now() - clientStartedAt;
234
234
 
235
235
  const sendStartedAt = Date.now();
236
236
  const result = await client.send(
@@ -242,15 +242,17 @@ export async function uploadBufferToR2(input: {
242
242
  ContentType: input.contentType,
243
243
  }),
244
244
  );
245
- logR2Perf('put-send', input.key, sendStartedAt, {
246
- attempts: result.$metadata.attempts ?? null,
247
- retryDelayMs: result.$metadata.totalRetryDelay ?? null,
248
- kind: bucketKind,
249
- bytes: input.body.byteLength,
250
- });
245
+ // One line per upload. Separate config/client/put-send lines quadrupled the
246
+ // most frequent R2 record (~315K extra Axiom rows/day) for sub-millisecond
247
+ // phases; their timings ride on the single `put` record instead.
251
248
  logR2Perf('put', input.key, startedAt, {
252
249
  kind: bucketKind,
253
250
  bytes: input.body.byteLength,
251
+ configMs,
252
+ clientMs,
253
+ sendMs: Date.now() - sendStartedAt,
254
+ attempts: result.$metadata.attempts ?? null,
255
+ retryDelayMs: result.$metadata.totalRetryDelay ?? null,
254
256
  });
255
257
 
256
258
  if (bucketKind === 'playArtifacts') {
@@ -28,6 +28,18 @@ import {
28
28
  * - onBatchComplete: called after each provider batch for scheduler checkpointing
29
29
  */
30
30
  import { AsyncLocalStorage } from 'async_hooks';
31
+ import {
32
+ createToolCallRetryFacts,
33
+ recordToolCallError,
34
+ recordToolCallRetry,
35
+ recordToolCallSend,
36
+ toolCallFailureLogFields,
37
+ toolCallRetryFactsLogFields,
38
+ toolCallRetryFactsScope,
39
+ toolCallRetryFactsTargetList,
40
+ type ToolCallRetryFacts,
41
+ type ToolCallRetryFactsTargets,
42
+ } from './tool-call-retry-facts';
31
43
  import { isDatasetPayloadField } from '../play-data-plane/sheet-contract';
32
44
  import {
33
45
  createDeferredPlayDataset,
@@ -739,6 +751,17 @@ function newToolCallPhaseClock(): ToolCallPhaseClock {
739
751
  };
740
752
  }
741
753
 
754
+ /** The retry facts of the calls a dispatched request sends for. */
755
+ function toolCallRetryFactsOf(
756
+ requests: readonly ToolCallRequest[],
757
+ ): readonly ToolCallRetryFacts[] {
758
+ const facts: ToolCallRetryFacts[] = [];
759
+ for (const request of requests) {
760
+ if (request.retryFacts) facts.push(request.retryFacts);
761
+ }
762
+ return facts;
763
+ }
764
+
742
765
  function recordToolCallReceiptWall(startedAt: number): void {
743
766
  const clock = toolCallPhaseClock.getStore();
744
767
  if (!clock) return;
@@ -2183,6 +2206,13 @@ type ToolExecutionApiOptions = {
2183
2206
  * inside a row's async scope, where the scope is read from there instead.
2184
2207
  */
2185
2208
  memoryLedgerRowScopes?: readonly (MemoryLedgerRowScope | null | undefined)[];
2209
+ /**
2210
+ * The logical calls this physical request sends for, whose retry facts it
2211
+ * records. The batched dispatcher runs outside its members' async scope and
2212
+ * names them here, an empty list for none; omitted, the call records into
2213
+ * the calling `executeTool` scope. Runner-local; never on the wire.
2214
+ */
2215
+ retryFactsTargets?: readonly ToolCallRetryFacts[];
2186
2216
  /** Runner-local map ownership; this must never be serialized to the gateway. */
2187
2217
  providerBackpressureMapRows?: boolean;
2188
2218
  /**
@@ -4398,7 +4428,6 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
4398
4428
  );
4399
4429
  }
4400
4430
 
4401
-
4402
4431
  private async executeFreshnessControlledCall<T>(input: {
4403
4432
  operation: DurableCtxOperation;
4404
4433
  id: string;
@@ -7676,6 +7705,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7676
7705
  */
7677
7706
  resultReceipts?: ToolResultReceipts;
7678
7707
  apiOptions: ToolExecutionApiOptions;
7708
+ /**
7709
+ * Every logical call this physical request sends for: a native batch's
7710
+ * members. Omitted, the request sends for `request` alone.
7711
+ */
7712
+ retryFactsMembers?: readonly ToolCallRequest[];
7679
7713
  }): Promise<ToolExecuteResult> {
7680
7714
  const providerActionVersion =
7681
7715
  (
@@ -7733,6 +7767,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
7733
7767
  },
7734
7768
  }
7735
7769
  : {}),
7770
+ // Likewise the calls whose retry facts this request records.
7771
+ retryFactsTargets: toolCallRetryFactsOf(
7772
+ input.retryFactsMembers ?? [input.request],
7773
+ ),
7736
7774
  // The dispatcher runs outside the row's async scope, so the row
7737
7775
  // and column that will retain this body have to be named here.
7738
7776
  // This is a runner-local accounting field: it never reaches the
@@ -14788,12 +14826,17 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14788
14826
  // an async-context clock would not belong to one call.
14789
14827
  const phaseClock =
14790
14828
  this.#callSplitTrace && !row ? newToolCallPhaseClock() : null;
14829
+ // Fixed-size counters the retry loop fills in for this logical call. A
14830
+ // queued row call carries the same object to the dispatcher.
14831
+ const retryFacts = createToolCallRetryFacts();
14791
14832
  try {
14792
- result = phaseClock
14793
- ? await toolCallPhaseClock.run(phaseClock, () =>
14794
- this.executeToolInternal(key, toolId, input, options),
14795
- )
14796
- : await this.executeToolInternal(key, toolId, input, options);
14833
+ result = await toolCallRetryFactsScope.run(retryFacts, () =>
14834
+ phaseClock
14835
+ ? toolCallPhaseClock.run(phaseClock, () =>
14836
+ this.executeToolInternal(key, toolId, input, options),
14837
+ )
14838
+ : this.executeToolInternal(key, toolId, input, options),
14839
+ );
14797
14840
  } catch (error) {
14798
14841
  // Parking is control flow, not a failed tool execution.
14799
14842
  if (
@@ -14824,6 +14867,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14824
14867
  ...(savedKey ? { receipt_key: savedKey } : {}),
14825
14868
  status: 'failed',
14826
14869
  duration_ms: Math.max(0, Date.now() - startedAt),
14870
+ ...toolCallRetryFactsLogFields(retryFacts),
14871
+ ...toolCallFailureLogFields(error),
14827
14872
  }),
14828
14873
  { level: 'error' },
14829
14874
  );
@@ -14844,6 +14889,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
14844
14889
  // Caller wall time includes queueing/reuse and result delivery. It is
14845
14890
  // deliberately not described as provider request duration.
14846
14891
  duration_ms: Math.max(0, Date.now() - startedAt),
14892
+ ...toolCallRetryFactsLogFields(retryFacts),
14847
14893
  }),
14848
14894
  );
14849
14895
  const split = phaseClock
@@ -15372,8 +15418,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
15372
15418
  const toolCachePolicy = this.effectiveToolCallCachePolicy(options);
15373
15419
  const store = rowContext.getStore();
15374
15420
  const callIndexKey = this.toolCallIndexKey(normalizedKey, toolId, input);
15375
- const callIndex =
15376
- reservedCallIndex ?? this.nextToolCallIndex(callIndexKey);
15421
+ const callIndex = reservedCallIndex ?? this.nextToolCallIndex(callIndexKey);
15377
15422
  const logicalCallId =
15378
15423
  logicalCallIdOverride ?? stableDigest(`${callIndexKey}:${callIndex}`);
15379
15424
  // Reserved with its operation slot (or a fresh replay identity): its forced
@@ -16186,6 +16231,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
16186
16231
  tableNamespace: store.tableNamespace,
16187
16232
  rowKey: store.rowKey ?? null,
16188
16233
  description: normalizeStepDescription(options?.description),
16234
+ // The dispatcher sends outside this call's async scope; it records
16235
+ // into the calling `executeTool`'s facts through this reference.
16236
+ retryFacts: toolCallRetryFactsScope.getStore(),
16189
16237
  };
16190
16238
  const pendingToolCall = new Promise((resolve, reject) => {
16191
16239
  this.toolCallResolvers.set(callId, { resolve, reject });
@@ -19312,6 +19360,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
19312
19360
  ],
19313
19361
  completedResultCache: true,
19314
19362
  batchResultView: detail.compiled.resultView,
19363
+ retryFactsTargets: toolCallRetryFactsOf(detail.members),
19315
19364
  memoryLedgerRowScopes: detail.members.map((member) => ({
19316
19365
  rowKey: member.rowKey,
19317
19366
  fieldName: member.fieldName,
@@ -19908,6 +19957,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
19908
19957
  const execution =
19909
19958
  await this.executeMappedToolCallThroughModule({
19910
19959
  request: batch.memberRequests[0]!,
19960
+ retryFactsMembers: batch.memberRequests,
19911
19961
  dispatchToolId: batch.batchOperation,
19912
19962
  dispatchPayload: batch.batchPayload,
19913
19963
  resultReceiptKey: aggregateReceiptKey,
@@ -20486,6 +20536,12 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
20486
20536
  startInput: Record<string, unknown>;
20487
20537
  startResponse: ParsedToolExecuteResponse;
20488
20538
  batchResultView?: 'rawV2';
20539
+ /**
20540
+ * The launch request's retry-fact targets. Poll and finish requests send
20541
+ * for the same logical calls, and the batched dispatcher runs outside
20542
+ * their async scope, so they are named here too.
20543
+ */
20544
+ retryFactsTargets: readonly ToolCallRetryFacts[];
20489
20545
  }): Promise<ParsedToolExecuteResponse> {
20490
20546
  const startResult = input.startResponse.toolResponse?.raw;
20491
20547
  const startClassificationFallback = input.startResponse.toolResponse?.rawV2;
@@ -20565,6 +20621,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
20565
20621
  abortSignal,
20566
20622
  skipAsyncOperationResolution: true,
20567
20623
  uncachedAsyncLifecycleCall: true,
20624
+ retryFactsTargets: input.retryFactsTargets,
20568
20625
  }),
20569
20626
  responseValue: (response) =>
20570
20627
  input.batchResultView === 'rawV2' &&
@@ -20847,6 +20904,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
20847
20904
  // body over to it.
20848
20905
  const nativeBatchBodyAttribution =
20849
20906
  options?.nativeBatchBodyAttribution ?? null;
20907
+ // The logical calls whose retry facts this request records: named by the
20908
+ // batched dispatcher, else the calling `executeTool`'s own.
20909
+ const retryFactsTargets: ToolCallRetryFactsTargets =
20910
+ options?.retryFactsTargets ?? toolCallRetryFactsScope.getStore();
20850
20911
  let retryActivityEmitted = false;
20851
20912
  let toolCallSucceeded = false;
20852
20913
 
@@ -21411,6 +21472,13 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21411
21472
  }): Promise<void> => {
21412
21473
  if (!input.connectionNeverOpened)
21413
21474
  earlierDeliveryMayHaveArrived = true;
21475
+ recordToolCallError(retryFactsTargets, {
21476
+ reason: input.connectionNeverOpened ? 'connect' : 'transport',
21477
+ status: null,
21478
+ knownNotDispatched:
21479
+ input.connectionNeverOpened === true ||
21480
+ input.knownNotDispatched === true,
21481
+ });
21414
21482
  let connectRetryDelayMs: number | null = null;
21415
21483
  if (input.connectionNeverOpened) {
21416
21484
  connectFailures += 1;
@@ -21445,6 +21513,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21445
21513
  this.runtimeLog(
21446
21514
  `Tool ${toolId} could not open a connection for ${url}; this attempt sent no request; retrying after ${connectRetryDelayMs}ms: ${diagnostic.message ?? 'unknown transport error'}`,
21447
21515
  );
21516
+ recordToolCallRetry(retryFactsTargets, connectRetryDelayMs);
21448
21517
  await waitForToolRetry(connectRetryDelayMs, false);
21449
21518
  return;
21450
21519
  }
@@ -21474,6 +21543,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21474
21543
  this.runtimeLog(
21475
21544
  `Tool ${toolId} transport failed calling ${url} on attempt ${transportAttempt}/${TOOL_EXECUTE_TRANSPORT_MAX_ATTEMPTS}; retrying after ${retryAfterMs}ms: ${diagnostic.message ?? 'unknown transport error'}`,
21476
21545
  );
21546
+ recordToolCallRetry(retryFactsTargets, retryAfterMs);
21477
21547
  await options?.parkProviderCall?.();
21478
21548
  await this.sleepWithCheckpointHeartbeat(retryAfterMs);
21479
21549
  return;
@@ -21598,6 +21668,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
21598
21668
  if (providerDispatchCounted) return;
21599
21669
  providerDispatchCounted = true;
21600
21670
  this.resourceGovernor.recordProviderDispatch();
21671
+ recordToolCallSend(retryFactsTargets, provider);
21601
21672
  };
21602
21673
  // A provider 429 must be reported while its server-minted
21603
21674
  // admission lease is still live. Keep its parsed outcome here so
@@ -22791,6 +22862,15 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22791
22862
  ? { providerLatencyMs: providerCallElapsedMs }
22792
22863
  : {}),
22793
22864
  });
22865
+ recordToolCallError(retryFactsTargets, {
22866
+ reason: failure.reason,
22867
+ status: response.status,
22868
+ error: failure.error,
22869
+ retryAfterPresent: Boolean(
22870
+ response.headers.get('retry-after')?.trim(),
22871
+ ),
22872
+ knownNotDispatched: failure.knownNotDispatched,
22873
+ });
22794
22874
  let surfacedError = failure.error;
22795
22875
  if (
22796
22876
  response.status === 429 &&
@@ -22921,10 +23001,13 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22921
23001
  // turns straight into customer row failures. A scheduler refusal
22922
23002
  // proves only that this delivery went nowhere: an earlier delivery
22923
23003
  // of the same attempt may have a row, so the attempt must not move.
23004
+ // A billing-plane refusal is the same: the charge for this
23005
+ // request identity may already be open, and the resend keeps both.
22924
23006
  const shedKnownNotDispatched =
22925
23007
  failure.reason === 'concurrency_backpressure' ||
22926
23008
  failure.reason === 'provider_pacing_wait' ||
22927
- failure.reason === 'runtime_scheduler_capacity';
23009
+ failure.reason === 'runtime_scheduler_capacity' ||
23010
+ failure.reason === 'billing_unavailable_before_dispatch';
22928
23011
  if (
22929
23012
  failure.shouldRetry &&
22930
23013
  (failure.knownNotDispatched ||
@@ -22969,6 +23052,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
22969
23052
  }
22970
23053
  const retryDelayMs =
22971
23054
  remainingProviderWaitMs ?? failure.retryDelayMs;
23055
+ recordToolCallRetry(retryFactsTargets, retryDelayMs);
22972
23056
  const retryAttributePrefix =
22973
23057
  failure.reason === 'provider_pacing_wait'
22974
23058
  ? 'provider_pacing_wait'
@@ -23082,6 +23166,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
23082
23166
  startInput: toolInputSnapshot,
23083
23167
  startResponse: parsed,
23084
23168
  batchResultView: options?.batchResultView,
23169
+ retryFactsTargets:
23170
+ toolCallRetryFactsTargetList(retryFactsTargets),
23085
23171
  })
23086
23172
  : parsed;
23087
23173
  // Only the configured execution relay may mint this header. The
@@ -12,6 +12,7 @@ import type { PlayDatasetColumnTypes } from '../play-data-plane/contracts';
12
12
  import type { PlayStructuredDefinition } from '../plays/definition';
13
13
  import type { PlayStaticPipeline } from '../plays/static-pipeline';
14
14
  import type { PlayLogContext, PlayLogMetadata } from './log-context';
15
+ import type { ToolCallRetryFacts } from './tool-call-retry-facts';
15
16
  import type { RuntimeSheetDatasetPageReader } from './runtime-api';
16
17
  import type {
17
18
  AsyncPlayRunRef,
@@ -156,6 +157,12 @@ export interface ToolCallRequest {
156
157
  * closed at the row's delivery site. Measurement only.
157
158
  */
158
159
  deliveryCompletionSettledAtMs?: number | null;
160
+ /**
161
+ * The calling `executeTool`'s retry counters. The dispatcher records the
162
+ * requests it sends for this call into them. Runner-local and in memory
163
+ * only; absent when the call was not made through `executeTool`.
164
+ */
165
+ retryFacts?: ToolCallRetryFacts;
159
166
  }
160
167
 
161
168
  export interface ToolBatchResult {