llm-large-files 0.8.2 → 0.10.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 (288) hide show
  1. package/CHANGELOG.md +981 -0
  2. package/README.md +22 -17
  3. package/dist/access.d.ts +128 -0
  4. package/dist/access.d.ts.map +1 -0
  5. package/dist/access.js +234 -0
  6. package/dist/access.js.map +1 -0
  7. package/dist/aggregate.d.ts +6 -0
  8. package/dist/aggregate.d.ts.map +1 -1
  9. package/dist/aggregate.js +86 -13
  10. package/dist/aggregate.js.map +1 -1
  11. package/dist/analyze.d.ts +4 -0
  12. package/dist/analyze.d.ts.map +1 -1
  13. package/dist/analyze.js +2 -2
  14. package/dist/analyze.js.map +1 -1
  15. package/dist/answer-info.d.ts +26 -0
  16. package/dist/answer-info.d.ts.map +1 -0
  17. package/dist/answer-info.js +32 -0
  18. package/dist/answer-info.js.map +1 -0
  19. package/dist/anthropic/adapter.d.ts +5 -1
  20. package/dist/anthropic/adapter.d.ts.map +1 -1
  21. package/dist/anthropic/adapter.js +35 -10
  22. package/dist/anthropic/adapter.js.map +1 -1
  23. package/dist/ask.d.ts +159 -14
  24. package/dist/ask.d.ts.map +1 -1
  25. package/dist/ask.js +743 -113
  26. package/dist/ask.js.map +1 -1
  27. package/dist/cache.d.ts +12 -3
  28. package/dist/cache.d.ts.map +1 -1
  29. package/dist/cache.js +18 -5
  30. package/dist/cache.js.map +1 -1
  31. package/dist/citations.d.ts +36 -0
  32. package/dist/citations.d.ts.map +1 -0
  33. package/dist/citations.js +291 -0
  34. package/dist/citations.js.map +1 -0
  35. package/dist/encoding.js +5 -3
  36. package/dist/encoding.js.map +1 -1
  37. package/dist/error-info.d.ts +70 -0
  38. package/dist/error-info.d.ts.map +1 -0
  39. package/dist/error-info.js +253 -0
  40. package/dist/error-info.js.map +1 -0
  41. package/dist/errors.d.ts +74 -8
  42. package/dist/errors.d.ts.map +1 -1
  43. package/dist/errors.js +104 -15
  44. package/dist/errors.js.map +1 -1
  45. package/dist/events.d.ts +57 -13
  46. package/dist/events.d.ts.map +1 -1
  47. package/dist/events.js +42 -11
  48. package/dist/events.js.map +1 -1
  49. package/dist/evidence.d.ts +4 -2
  50. package/dist/evidence.d.ts.map +1 -1
  51. package/dist/evidence.js +35 -5
  52. package/dist/evidence.js.map +1 -1
  53. package/dist/extract.d.ts +32 -8
  54. package/dist/extract.d.ts.map +1 -1
  55. package/dist/extract.js +52 -36
  56. package/dist/extract.js.map +1 -1
  57. package/dist/gemini/adapter.d.ts +54 -7
  58. package/dist/gemini/adapter.d.ts.map +1 -1
  59. package/dist/gemini/adapter.js +152 -41
  60. package/dist/gemini/adapter.js.map +1 -1
  61. package/dist/gemini/chat.d.ts +38 -53
  62. package/dist/gemini/chat.d.ts.map +1 -1
  63. package/dist/gemini/chat.js +20 -25
  64. package/dist/gemini/chat.js.map +1 -1
  65. package/dist/gemini/endpoints.d.ts +59 -11
  66. package/dist/gemini/endpoints.d.ts.map +1 -1
  67. package/dist/gemini/endpoints.js +33 -7
  68. package/dist/gemini/endpoints.js.map +1 -1
  69. package/dist/gemini/errors.d.ts +39 -5
  70. package/dist/gemini/errors.d.ts.map +1 -1
  71. package/dist/gemini/errors.js +70 -9
  72. package/dist/gemini/errors.js.map +1 -1
  73. package/dist/gemini/generate.d.ts +53 -2
  74. package/dist/gemini/generate.d.ts.map +1 -1
  75. package/dist/gemini/generate.js +100 -50
  76. package/dist/gemini/generate.js.map +1 -1
  77. package/dist/gemini/index.d.ts +4 -4
  78. package/dist/gemini/index.d.ts.map +1 -1
  79. package/dist/http.d.ts +41 -3
  80. package/dist/http.d.ts.map +1 -1
  81. package/dist/http.js +40 -2
  82. package/dist/http.js.map +1 -1
  83. package/dist/index.d.ts +13 -8
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +8 -5
  86. package/dist/index.js.map +1 -1
  87. package/dist/ingest.d.ts +78 -0
  88. package/dist/ingest.d.ts.map +1 -0
  89. package/dist/ingest.js +893 -0
  90. package/dist/ingest.js.map +1 -0
  91. package/dist/library.d.ts +295 -33
  92. package/dist/library.d.ts.map +1 -1
  93. package/dist/library.js +458 -650
  94. package/dist/library.js.map +1 -1
  95. package/dist/map-reduce.d.ts +176 -10
  96. package/dist/map-reduce.d.ts.map +1 -1
  97. package/dist/map-reduce.js +807 -61
  98. package/dist/map-reduce.js.map +1 -1
  99. package/dist/model.d.ts +79 -6
  100. package/dist/model.d.ts.map +1 -1
  101. package/dist/model.js +80 -4
  102. package/dist/model.js.map +1 -1
  103. package/dist/node/handlers.d.ts +247 -14
  104. package/dist/node/handlers.d.ts.map +1 -1
  105. package/dist/node/handlers.js +491 -227
  106. package/dist/node/handlers.js.map +1 -1
  107. package/dist/node/index.d.ts +3 -2
  108. package/dist/node/index.d.ts.map +1 -1
  109. package/dist/node/index.js +2 -1
  110. package/dist/node/index.js.map +1 -1
  111. package/dist/node/ingest-child.d.ts +7 -1
  112. package/dist/node/ingest-child.d.ts.map +1 -1
  113. package/dist/node/ingest-child.js +19 -4
  114. package/dist/node/ingest-child.js.map +1 -1
  115. package/dist/node/isolated.d.ts +3 -1
  116. package/dist/node/isolated.d.ts.map +1 -1
  117. package/dist/node/isolated.js +11 -4
  118. package/dist/node/isolated.js.map +1 -1
  119. package/dist/node/originals.d.ts +19 -0
  120. package/dist/node/originals.d.ts.map +1 -0
  121. package/dist/node/originals.js +82 -0
  122. package/dist/node/originals.js.map +1 -0
  123. package/dist/node/spool.d.ts +106 -0
  124. package/dist/node/spool.d.ts.map +1 -0
  125. package/dist/node/spool.js +378 -0
  126. package/dist/node/spool.js.map +1 -0
  127. package/dist/node/sse.d.ts +6 -4
  128. package/dist/node/sse.d.ts.map +1 -1
  129. package/dist/node/sse.js +9 -7
  130. package/dist/node/sse.js.map +1 -1
  131. package/dist/openai/adapter.d.ts +5 -1
  132. package/dist/openai/adapter.d.ts.map +1 -1
  133. package/dist/openai/adapter.js +53 -12
  134. package/dist/openai/adapter.js.map +1 -1
  135. package/dist/output-limit.d.ts +2 -1
  136. package/dist/output-limit.d.ts.map +1 -1
  137. package/dist/output-limit.js +5 -2
  138. package/dist/output-limit.js.map +1 -1
  139. package/dist/pdf-layout.d.ts.map +1 -1
  140. package/dist/pdf-layout.js +71 -12
  141. package/dist/pdf-layout.js.map +1 -1
  142. package/dist/pdf-outline.d.ts +71 -0
  143. package/dist/pdf-outline.d.ts.map +1 -0
  144. package/dist/pdf-outline.js +414 -0
  145. package/dist/pdf-outline.js.map +1 -0
  146. package/dist/plan.d.ts +137 -7
  147. package/dist/plan.d.ts.map +1 -1
  148. package/dist/plan.js +248 -26
  149. package/dist/plan.js.map +1 -1
  150. package/dist/prepare.d.ts +50 -0
  151. package/dist/prepare.d.ts.map +1 -0
  152. package/dist/prepare.js +207 -0
  153. package/dist/prepare.js.map +1 -0
  154. package/dist/ranged.d.ts +16 -11
  155. package/dist/ranged.d.ts.map +1 -1
  156. package/dist/ranged.js +56 -12
  157. package/dist/ranged.js.map +1 -1
  158. package/dist/retry.d.ts +3 -1
  159. package/dist/retry.d.ts.map +1 -1
  160. package/dist/retry.js +6 -2
  161. package/dist/retry.js.map +1 -1
  162. package/dist/scope.d.ts +25 -0
  163. package/dist/scope.d.ts.map +1 -0
  164. package/dist/scope.js +60 -0
  165. package/dist/scope.js.map +1 -0
  166. package/dist/search.d.ts +7 -0
  167. package/dist/search.d.ts.map +1 -1
  168. package/dist/search.js +72 -10
  169. package/dist/search.js.map +1 -1
  170. package/dist/source.d.ts +60 -0
  171. package/dist/source.d.ts.map +1 -0
  172. package/dist/source.js +170 -0
  173. package/dist/source.js.map +1 -0
  174. package/dist/stores.d.ts +126 -31
  175. package/dist/stores.d.ts.map +1 -1
  176. package/dist/stores.js +655 -141
  177. package/dist/stores.js.map +1 -1
  178. package/dist/testing/fake-fetch.d.ts +31 -0
  179. package/dist/testing/fake-fetch.d.ts.map +1 -0
  180. package/dist/testing/fake-fetch.js +66 -0
  181. package/dist/testing/fake-fetch.js.map +1 -0
  182. package/dist/testing/fake-model.d.ts +38 -0
  183. package/dist/testing/fake-model.d.ts.map +1 -0
  184. package/dist/testing/fake-model.js +62 -0
  185. package/dist/testing/fake-model.js.map +1 -0
  186. package/dist/testing/index.d.ts +7 -0
  187. package/dist/testing/index.d.ts.map +1 -0
  188. package/dist/testing/index.js +9 -0
  189. package/dist/testing/index.js.map +1 -0
  190. package/dist/testing/store-checks.d.ts +72 -0
  191. package/dist/testing/store-checks.d.ts.map +1 -0
  192. package/dist/testing/store-checks.js +619 -0
  193. package/dist/testing/store-checks.js.map +1 -0
  194. package/dist/tools.d.ts +47 -2
  195. package/dist/tools.d.ts.map +1 -1
  196. package/dist/tools.js +440 -71
  197. package/dist/tools.js.map +1 -1
  198. package/dist/types.d.ts +165 -14
  199. package/dist/types.d.ts.map +1 -1
  200. package/dist/whole-cost.d.ts +37 -0
  201. package/dist/whole-cost.d.ts.map +1 -0
  202. package/dist/whole-cost.js +46 -0
  203. package/dist/whole-cost.js.map +1 -0
  204. package/docs/README.md +21 -8
  205. package/docs/getting-started.md +18 -13
  206. package/docs/guides/anthropic.md +17 -10
  207. package/docs/guides/conversations.md +112 -47
  208. package/docs/guides/costs-and-limits.md +147 -42
  209. package/docs/guides/deployment.md +380 -86
  210. package/docs/guides/errors-and-reliability.md +317 -67
  211. package/docs/guides/explorer-model.md +4 -1
  212. package/docs/guides/openai-compatible.md +47 -7
  213. package/docs/guides/own-adapter-and-loop.md +60 -16
  214. package/docs/guides/pdfs.md +219 -36
  215. package/docs/guides/storage.md +676 -145
  216. package/docs/guides/testing.md +149 -129
  217. package/docs/guides/vertex-and-gemini.md +169 -57
  218. package/docs/guides/web-app.md +318 -80
  219. package/docs/how-it-works.md +155 -30
  220. package/docs/measurements.md +215 -13
  221. package/docs/publishing.md +185 -37
  222. package/docs/reference/anthropic.md +12 -7
  223. package/docs/reference/ask.md +415 -47
  224. package/docs/reference/errors-and-retries.md +194 -14
  225. package/docs/reference/events.md +77 -27
  226. package/docs/reference/gemini.md +252 -87
  227. package/docs/reference/library.md +886 -178
  228. package/docs/reference/node.md +659 -111
  229. package/docs/reference/openai.md +21 -10
  230. package/docs/reference/testing.md +311 -0
  231. package/docs/reference/tools.md +285 -30
  232. package/docs/security.md +404 -78
  233. package/docs/troubleshooting.md +151 -70
  234. package/docs/upgrading-0.10.md +472 -0
  235. package/docs/upgrading-0.9.md +890 -0
  236. package/package.json +16 -3
  237. package/src/access.ts +267 -0
  238. package/src/aggregate.ts +92 -14
  239. package/src/analyze.ts +2 -2
  240. package/src/answer-info.ts +45 -0
  241. package/src/anthropic/adapter.ts +40 -11
  242. package/src/ask.ts +866 -115
  243. package/src/cache.ts +20 -5
  244. package/src/citations.ts +294 -0
  245. package/src/encoding.ts +6 -4
  246. package/src/error-info.ts +290 -0
  247. package/src/errors.ts +131 -15
  248. package/src/events.ts +112 -24
  249. package/src/evidence.ts +35 -5
  250. package/src/extract.ts +56 -34
  251. package/src/gemini/adapter.ts +196 -43
  252. package/src/gemini/chat.ts +63 -78
  253. package/src/gemini/endpoints.ts +89 -16
  254. package/src/gemini/errors.ts +74 -11
  255. package/src/gemini/generate.ts +147 -57
  256. package/src/gemini/index.ts +4 -4
  257. package/src/http.ts +65 -4
  258. package/src/index.ts +13 -8
  259. package/src/ingest.ts +958 -0
  260. package/src/library.ts +711 -651
  261. package/src/map-reduce.ts +858 -70
  262. package/src/model.ts +113 -9
  263. package/src/node/handlers.ts +709 -221
  264. package/src/node/index.ts +14 -2
  265. package/src/node/ingest-child.ts +24 -6
  266. package/src/node/isolated.ts +11 -4
  267. package/src/node/originals.ts +78 -0
  268. package/src/node/spool.ts +379 -0
  269. package/src/node/sse.ts +9 -7
  270. package/src/openai/adapter.ts +56 -13
  271. package/src/output-limit.ts +5 -2
  272. package/src/pdf-layout.ts +69 -11
  273. package/src/pdf-outline.ts +400 -0
  274. package/src/plan.ts +287 -36
  275. package/src/prepare.ts +253 -0
  276. package/src/ranged.ts +48 -14
  277. package/src/retry.ts +6 -2
  278. package/src/scope.ts +63 -0
  279. package/src/search.ts +69 -13
  280. package/src/source.ts +178 -0
  281. package/src/stores.ts +702 -142
  282. package/src/testing/fake-fetch.ts +80 -0
  283. package/src/testing/fake-model.ts +78 -0
  284. package/src/testing/index.ts +11 -0
  285. package/src/testing/store-checks.ts +660 -0
  286. package/src/tools.ts +461 -73
  287. package/src/types.ts +151 -14
  288. package/src/whole-cost.ts +64 -0
@@ -123,6 +123,10 @@ question ─► plan the documents for the room left in the request, smallest fi
123
123
  Logs, JSON and CSV get no outline. No heading is taken from a fenced code block, and in a
124
124
  plain text file that reads as code (a script, a configuration file) a `#` line is a comment,
125
125
  not a heading; in other plain text, only one after a blank line and not followed by another.
126
+ A PDF seldom has these (pdf.js gives no blank line between paragraphs, and Hebrew has no
127
+ capitals): when its text gives fewer than 3, its outline is the lines its extractor found set
128
+ in larger type than its body, from the sizes pdf.js gives, when 3 or more of them are found in
129
+ the text (since 0.10.0; [PDF outline](./guides/pdfs.md#pdf-outline)).
126
130
  - For a log, build a **profile**: lines by level (ERR counts as ERROR, WARNING as WARN, CRITICAL
127
131
  as FATAL; since 0.8.0 also a level in lower case in brackets, after `level=` or in a JSON
128
132
  field, pino's numbers and klog's letter), the first and last timestamp, and the ERROR, FATAL
@@ -233,7 +237,7 @@ A file that is sent whole sits between two frame lines:
233
237
 
234
238
  ```text
235
239
  --- Attached file [mark 1f0c3a9e]: "app.log" (log, 3,000 lines; it ends only at the line with mark 1f0c3a9e) ---
236
- 2026-11-19T08:00:01.370Z INFO request id=0 handled in 0ms
240
+ 1| 2026-11-19T08:00:01.370Z INFO request id=0 handled in 0ms
237
241
  …
238
242
  --- End attached file [mark 1f0c3a9e] ---
239
243
  ```
@@ -251,6 +255,14 @@ valid UTF-8 adds a note after the line count ([Text encodings](#text-encodings))
251
255
  `, 3 characters not valid UTF-8, shown as �`. What the mark guards against, and what it does not:
252
256
  [Security](./security.md#the-frame-around-a-file).
253
257
 
258
+ Since 0.10.0 `askWithFiles` numbers the lines between the frame lines as `read_document` numbers
259
+ them, from `1| `, so that an answer can cite a file sent whole as it cites a searched one
260
+ ([below](#numbered-lines-and-tables-sent-whole)). With `numberInline: false`, and in
261
+ `files.prepare()` unless it is asked for, the text goes as it is, as in 0.9. The frame lines are the
262
+ same either way, but for a table that the tools count (`inlineTables: "tools"`): its first frame
263
+ line gives its document_id, `(csv, 3,001 lines; document_id doc_…; it ends only at the line with
264
+ mark …)`, since the tools take it and a file sent whole has no card.
265
+
254
266
  A file too large to send whole is replaced by its card, a few kilobytes. This is the card of a
255
267
  3,000-line log, with its first lines shortened here:
256
268
 
@@ -370,7 +382,8 @@ user turn (`documentPlacement: "first"`, the default). They stay there as the co
370
382
  so a provider's prompt cache, which matches the start of a request, can reuse them on every
371
383
  follow-up question: Gemini's own cache, and Claude's `cache_control`. `"last"` appends them to the
372
384
  latest user turn instead, where they move with every turn and are billed in full each time. A
373
- question with no searchable file and no viewable PDF is then one request, without tools.
385
+ question with no searchable file, no viewable PDF and no table sent whole that the tools count
386
+ ([below](#numbered-lines-and-tables-sent-whole)) is then one request, without tools.
374
387
 
375
388
  To see a plan and a budget without asking a model:
376
389
 
@@ -393,6 +406,47 @@ console.log(prepared.blocks.get(meta.id)); // the text or the card
393
406
  console.log(prepared.instruction); // the tool guide, or ""
394
407
  ```
395
408
 
409
+ ### Numbered lines and tables sent whole
410
+
411
+ New in 0.10.0. `askWithFiles` asks `prepare` for two things that 0.9 did not do, and that
412
+ `files.prepare()` does only when asked (`PrepareOptions.numberInline`, `inlineTables`):
413
+
414
+ - **Numbered lines** (`numberInline`, true by default). Every line of a file sent whole carries its
415
+ number, `12| `, as the tools show lines. The model can then cite it, "(report.docx L12)", and
416
+ `result.citations` checks the citation against the file's lines. The plan counts each such file
417
+ at its numbered size, about 1.2 tokens a digit of the numbers and 1.5 a line more: 8% to 16% more
418
+ tokens (15.5% for a CSV of 3,000 short rows, 9.4% for a service log, 8.4% for Hebrew prose). It
419
+ also measures the numbered text it reads, which can be larger (deeply indented lines), and plans
420
+ again when it is. So a file at the edge of `inlineTokens` may become a card. When no file is
421
+ searched, no tool guide asks for citations, so the system text gets one fixed line:
422
+ `Cite line numbers like (report.docx L12).` Its file name is an example, the same in every
423
+ question, so the line does not change the start of the requests from one question to the next.
424
+ - **Tables that the tools still count** (`inlineTables: "tools"`, the default). A file sent whole
425
+ whose rows `aggregate_table` reads gets the tools: a CSV or an XLSX workbook always, and a DOCX,
426
+ PPTX, PDF, HTML or Markdown file when its text has a table of at least 3 `| cell |` rows (a run
427
+ of lines that start and end with `|`, as `aggregate_table` reads a table, a `| --- |` separator
428
+ not counted). Before 0.10.0 such a file had no tools, so the
429
+ model counted its rows by eye: of 3,000 invoices sent whole, 750 late, Gemini Flash-Lite counted
430
+ 749 in one run of three, and added up the amounts of the 750 canceled ones wrong by millions in
431
+ all three (the 0.9.0 baseline of the evals). The question declares `search_document`,
432
+ `read_document` and `aggregate_table` for such files, never `get_document_overview` or
433
+ `analyze_whole_document` (which answers that a file sent whole is shown in full above, when a
434
+ searched file has it declared), and the system text gets the line "Files shown in full can still
435
+ be counted exactly: use aggregate_table for counts, sums and groups over their tables, and
436
+ search_document exact for matching lines. In a spreadsheet, give the Row number when asked which
437
+ row." Its frame line gives its document_id for the tools. The question then runs the
438
+ [tool loop](#the-loop-askwithfiles): one that needs no count is answered in its first request, as
439
+ before, with the tools declared; a count takes a request that calls `aggregate_table` and one that
440
+ answers from its result. When the tools are there only for such tables, two things stay as the one
441
+ request of 0.9: when not one tool turn fits the `limits`, the question is that request, without
442
+ the tools; and a reply with no call that a filter or OTHER ended with no text, or that was cut
443
+ before any text, ends the question, with no closing request that would send the tables again.
444
+
445
+ When no file is searched, the answering model runs that loop itself, even when the question has an
446
+ explorer ([An explorer model](#an-explorer-model)). The [evidence](#usage-and-evidence) lists each
447
+ file sent whole first. `inlineTables: "text"` with `numberInline: false` sends what 0.9 sent, byte
448
+ for byte.
449
+
396
450
  ## Token estimates
397
451
 
398
452
  `estimateTokens(text)` walks the text once and prices each kind of character, because the number
@@ -552,6 +606,18 @@ models), against half of
552
606
  out, the tool says so and the model answers from what it has. The looks of one turn run one after
553
607
  another, each with the room the one before it left.
554
608
 
609
+ The looks of all questions of a library take their turns too (new in 0.9.0). A look parses the
610
+ whole PDF on the one thread the questions share: six at once each took about four times as long,
611
+ and held 352 MB more than one. By default one look runs at a time (`maxConcurrentPageLooks`), and
612
+ the others wait in order, before their PDF is loaded, so a look that waits holds none of its bytes.
613
+ The memory check above is made once the turn comes. A look that waits longer than
614
+ `pageLookWaitMs` (30 s) is not run: the model reads that the server is busy and to answer from the
615
+ text, and the question gets a `page_looks_busy` notice. The other looks of that tool turn then do
616
+ not wait: they run only when a turn is free at once, so a wait that ends busy comes once in a
617
+ turn. A look holds its turn
618
+ while it reads the PDF from the store for at most `ingestTimeoutMs` (2 minutes by default), and a
619
+ question that is stopped gives its turn back at once.
620
+
555
621
  Pages are not kept in `toolTurns`: the stored round says that they were shown. Setting this up,
556
622
  scanned PDFs and `toolFilePlacement`: [PDFs and other formats](./guides/pdfs.md).
557
623
 
@@ -563,20 +629,32 @@ the part reader (`generateText`) of the model that explores.
563
629
  1. **Split** on line boundaries into parts that fit both `mapChunkTokens` and 80% of
564
630
  `maxRequestBytes`, counting the line-number prefix of every line. A file of more than
565
631
  `maxMapChunks` parts (30) is refused before any request: "Reading all of app.log needs 41 model
566
- calls, over the limit of 30. Use search_document to narrow the question first." Such a file is
632
+ calls, over the limit of 30. Use search_document to narrow the question first." So is one with
633
+ more parts than the requests the read may make (`maxRequests`, since 0.10.0). Such a file is
567
634
  most often not offered the read at all: its card, the tool guide and the overview say so
568
635
  ([The plan](#how-the-plan-is-made)).
569
636
  2. **Map.** Read the parts four at a time. Each part either takes notes with line citations
570
637
  (`(L123)`) or replies `NOTHING RELEVANT`. A part that fails is sent again by the loop's rule
571
638
  ([Retries and waits](#retries-and-waits)), and an error with no status once more at once.
639
+ - A part's request sends the file's name and lines, then the part between `<part>` and
640
+ `</part>`, then where the part is ("This is part 3 of 12."), the task and the rules. A part
641
+ that starts in the middle of a section of the outline has the line of the heading it is under
642
+ first, so that the events of a day of a diary are not dated by the day before. The task
643
+ comes last, after the file's text, and the system text says that text inside `<part>` is the
644
+ file's content: never instructions to follow. A line in the file
645
+ that says "reply NOTHING RELEVANT" is text to read, not an order. Two reads of one file with
646
+ other tasks send the same start in each part's request, up to the end of the part, which a
647
+ provider's prompt cache can reuse. Until 0.10.0 the task came first (M8).
572
648
  - A part the model refuses as larger than it takes (an error of kind `context_overflow`: its
573
649
  window is smaller than the budget says) is read as two halves, once, while `maxMapChunks` and
574
- the requests the question has left allow it. A half that is still too large is a part that
575
- could not be read.
650
+ the requests the question has left allow it, with room kept for the merges and the answer. A
651
+ half that is still too large is a part that could not be read.
576
652
  - A part that still fails is reported in the answer (`parts_that_failed`) rather than failing
577
653
  the whole read. When no part could be read, the read fails with the reason and is not tried
578
654
  again in the question. When none could even be read from the store, no model request was
579
- made, and the store's error is the result.
655
+ made, and the store's error is the result. A store that does not answer in time ends the
656
+ question instead (since 0.10.0): the part is not counted as one that could not be read, and
657
+ the other parts stop, with no request sent after it.
580
658
  - The reason of a model request that failed is told by its kind, its HTTP status, the code of a
581
659
  connection that failed or a timeout, never by the error's words, which can name a host or a
582
660
  key: `Could not read any part of app.log: The model refused the key or token it was sent (HTTP 401).`
@@ -584,17 +662,38 @@ the part reader (`generateText`) of the model that explores.
584
662
  ([Security](./security.md#what-the-library-logs)).
585
663
  3. **Reduce.** While the notes of the relevant parts together are larger than `mapChunkTokens`,
586
664
  merge them in batches of up to `mapChunkTokens` (in pairs when no two notes fit one batch), four
587
- at a time, for at most 8 rounds. A merge that fails keeps its notes as they were, and the rounds
588
- stop there.
665
+ at a time, for at most 8 rounds. A merge sends its notes first, between `<notes>` and
666
+ `</notes>`, and the task last. A merge that fails keeps its notes as they were, and the rounds
667
+ stop there. When the question limits its requests (`limits.requests`, which the loop shares out
668
+ as the read's `maxRequests`), the read counts them: a round that would leave no request for the
669
+ answer is not made, and the answer is written from the notes that fit one request, in the order
670
+ of the file, saying that the notes of the other parts are left out (`notes_left_out`). Until
671
+ 0.10.0 the merges went past the limit: a read of 27 parts given 32 requests made 40 (N12).
589
672
  4. **Answer.** Write one answer from the notes, flagging contradictions, gaps and parts that could
590
- not be read. When this last step fails, the notes are the answer, with `notes_only: true`: they
591
- were paid for.
673
+ not be read. When this last step fails, or no request is left for it, the notes are the answer,
674
+ with `notes_only: true`: they were paid for.
592
675
 
593
676
  The result holds `parts_read`, `parts_with_relevant_content`, `parts_that_failed`,
594
- `notes_cut_short`, `answer_cut_short`, `notes_only` and the `answer`. While it runs, the progress goes
595
- to `onActivity`: "Reading app.log: part 3 of 12…", and, with `onEvent`, comes as `tool.progress`
596
- events with the `callId` of the read, each part a `request.start` and `request.end` of role
597
- `"reader"`.
677
+ `notes_cut_short`, `notes_left_out`, `answer_cut_short`, `notes_only` and the `answer`. While it
678
+ runs, the progress goes to `onActivity`: "Reading app.log: part 3 of 12…", and, with `onEvent`, comes
679
+ as `tool.progress` events with the `callId` of the read, each part a `request.start` and
680
+ `request.end` of role `"reader"`.
681
+
682
+ **Items.** With `output: "items"` (new in 0.10.0, M9), the parts list what the task asks for, and no
683
+ model writes the count. Each part replies with one JSON object a line, an item each: its line, a
684
+ label from the call's `labels`, a value, and a quote of its line. Code reads the replies leniently,
685
+ keeps an item only when its quote is on its line (compared without case, Hebrew points, final
686
+ letters or direction marks), or on just one other line of its part, which it then takes, or near
687
+ its line (a few letters copied wrong, the same numbers), or near the one line of its part that
688
+ starts with the number it names (not a date or a time), which it then takes; counts the same item
689
+ once, and an item it moved to a line once with the item that named that line with its label;
690
+ and counts the items by label.
691
+ There is no merge and no answer of the read: one request a part, so a read of 5 parts makes 5
692
+ requests. A part whose list is cut at the output limit is read again in halves, two levels at
693
+ most, within the requests the question has left. The result gives `total_items`,
694
+ `counts_by_label`, the first 50 items, and `unverified_items` for those that were listed but not
695
+ found on or near their line ([Tools](./reference/tools.md#items-output-items)). Its evidence holds the lines
696
+ of its items, which an answer can cite.
598
697
 
599
698
  **Output limits.** Part notes and merged notes start at 4,096 output tokens, the answer at 8,192.
600
699
  When a reply reaches its limit, or a provider's filter stops it (Gemini `SAFETY` and the like,
@@ -628,7 +727,10 @@ once, in the core. `askGemini` is this loop with Gemini adapters ([below](#gemin
628
727
 
629
728
  A question goes like this:
630
729
 
631
- 1. Fit the budget to the models, and [plan the documents](#how-the-plan-is-made).
730
+ 1. Fit the budget to the models, and [plan the documents](#how-the-plan-is-made). Documents that
731
+ are missing are settled by `onMissingDocuments`: by default the question fails before any
732
+ request; with `"drop"` it is answered without them, with one line in the system instruction
733
+ that says how many files are no longer available.
632
734
  2. Send a request with the tools (`toolChoice: "auto"`) to the model that explores.
633
735
  3. A reply without tool calls ends the tool requests. Its text is the answer, unless it is empty,
634
736
  the prompt was blocked, or it comes from an explorer. A reply with calls is a turn: its calls run, each result gets
@@ -697,7 +799,13 @@ provider has answered, by the provider's own count ([Token estimates](#token-est
697
799
  all but the last two, then all but the last one, as far as needed. `steps` then holds "Older tool
698
800
  results were shortened to make room in the request". When any model of the question, the
699
801
  answering model or the explorer, may only grow its conversation (`capabilities.appendOnly`:
700
- Claude), nothing is replaced, for either model.
802
+ Claude), nothing is replaced during the question, for either model.
803
+ - **Before the first request** (new in 0.9.0), when the stored rounds of earlier questions make it
804
+ larger than the room it has in tokens, their results are replaced the same way, as far as
805
+ needed, before it is sent. Only the estimate of its tokens is checked, as after a refused
806
+ request: a request is not shortened for its bytes alone. Nothing of the question was sent yet, and a stored round has no thinking in it, so
807
+ this is done for an append-only model too. The request is what an overflow would have had sent
808
+ again ([below](#a-request-too-large-for-the-model)), without the refused request before it.
701
809
  - **No room left.** Calls that still cannot each get 1,500 characters (or their cap, when it is
702
810
  smaller) are answered "Not run: there is no room left in this conversation for another tool
703
811
  result. Answer now, from what the tools returned so far.", the last calls of the turn first, and
@@ -708,7 +816,9 @@ provider has answered, by the provider's own count ([Token estimates](#token-est
708
816
  A stand-in is a short result in place of one that was dropped to make room. It keeps which document
709
817
  it was about and what it showed, says `dropped: true`, and tells the model how to get it back. What
710
818
  each tool's stand-in keeps, and which results are too small to replace, is in
711
- [`stubResult`](./reference/ask.md#stubresultcall-result-hadfiles). The tool rounds a question
819
+ [`stubResult`](./reference/ask.md#stubresultcall-result-hadfiles). Since 0.9.0 a result is never
820
+ replaced by a stand-in as large as itself or larger: a search counted by group, or an
821
+ `aggregate_table` result, of a few short groups stays as it is. The tool rounds a question
712
822
  returns in `toolTurns` hold stand-ins for pages, since a file cannot be kept as JSON
713
823
  ([Conversations](./guides/conversations.md)).
714
824
 
@@ -796,7 +906,10 @@ end the question:
796
906
  and sends the request again. `steps` says "The request was larger than the model takes: older tool
797
907
  results were shortened, and it was sent again". That happens at most twice a question, and once
798
908
  for any one request. When any model of the question may only grow its conversation (Claude),
799
- nothing is shortened.
909
+ nothing is shortened. Since 0.9.0 the first request of a question is checked against the loop's
910
+ own estimate first, and the stored rounds of earlier questions are shortened before it is sent
911
+ ([making room](#room-in-the-request)): a history that grew past the window no longer costs a
912
+ refused request, and no longer fails a question on Claude.
800
913
  - **Plan again.** When it happens to the first requests of a question, before any tool call was
801
914
  answered or any text shown, the documents are planned again for a smaller window, once, as for a
802
915
  model that declares it. The window is the one the provider named, or seven tenths of the window
@@ -883,9 +996,13 @@ is sent to the answering model, and it must be answered in text:
883
996
  not made after a blocked prompt, which would only be blocked again.
884
997
  - **What.** The conversation, then a user message: `FINAL_ANSWER_REQUEST` after text tools,
885
998
  `FINAL_ANSWER_AFTER_PAGES` when the only tool offered was `view_pages` (every text was in the
886
- prompt), or `FINAL_ANSWER_WITHOUT_TOOLS` when no call was answered at all. For Gemini the request
887
- declares no tools; for an OpenAI-compatible endpoint and for Claude it keeps them and sets the
888
- tool choice to none.
999
+ prompt), or `FINAL_ANSWER_WITHOUT_TOOLS` when no call was answered at all. Since 0.10.0, after
1000
+ text tools in a question that also sent files whole, numbered or with tables the tools count, the
1001
+ message says to answer from those files too: "Stop using tools now. Answer my question using only
1002
+ the files shown in full and what the tools returned above, with line citations. …". In a chat with
1003
+ Gemini Flash-Lite told "only what the tools returned", two answers said that a fact of a file
1004
+ shown in full was not in the tool results. For Gemini the request declares no tools; for an
1005
+ OpenAI-compatible endpoint and for Claude it keeps them and sets the tool choice to none.
889
1006
  - **Its result.** `answered` is true when the reply has text and the prompt was not blocked. A
890
1007
  reply with no text is asked for once more ([Empty or broken turns](#empty-or-broken-turns)). When
891
1008
  even that has no text, or the provider blocked the prompt, `answered` is `false` (with
@@ -908,6 +1025,11 @@ explorer })`, where the two may be of different providers, or an `askGemini` end
908
1025
  - **The budget fits both models**: the smaller window, the larger `tokenScale`, and pages at the
909
1026
  larger `pageTokens`. `view_pages` needs both to take a file. `limits.toolTurns` counts the
910
1027
  explorer's requests and the answer's, so the explorer has one less.
1028
+ - **Not for tables sent whole alone** (since 0.10.0). When no file is searched and the tools are
1029
+ there for [tables sent whole](#numbered-lines-and-tables-sent-whole), the answering model runs
1030
+ the loop itself, and the explorer gets no request. A question that needs no count is then
1031
+ answered in one request; with the explorer, every such question would be two requests, each with
1032
+ every file sent whole, to two models that share no cache. `run.start` still names the explorer.
911
1033
 
912
1034
  ### Usage and evidence
913
1035
 
@@ -917,11 +1039,13 @@ explorer })`, where the two may be of different providers, or an `askGemini` end
917
1039
  still counts its requests. `turns` counts the chat requests alone, and `lastUsage` is the
918
1040
  provider's own usage object of the last chat response. Turning it into a cost:
919
1041
  [Costs and limits](./guides/costs-and-limits.md).
920
- - **Evidence** is read from the tool calls, in call order: for each call that ran, the document and
921
- the lines or pages it showed (merged into ranges). A search adds its query and mode, and an exact
922
- or regex search its `totalMatchingLines`. An overview shows the first 30 and last 20 lines. A
923
- whole-file read is marked `whole: true`, with its task as the query. Calls that failed or were
924
- refused, pointers and stand-ins add nothing.
1042
+ - **Evidence** lists first each file sent whole, in the order of its block (since 0.10.0): `{ tool:
1043
+ "inline", documentId, document, lines: [[1, lines]], whole: true }`, with no `callId`, as no tool
1044
+ call showed it. Then it is read from the tool calls, in call order: for each call that ran, the
1045
+ document and the lines or pages it showed (merged into ranges). A search adds its query and mode,
1046
+ and an exact or regex search its `totalMatchingLines`. An overview shows the first 30 and last 20
1047
+ lines. A whole-file read is marked `whole: true`, with its task as the query. Calls that failed or
1048
+ were refused, pointers and stand-ins add nothing.
925
1049
 
926
1050
  ### What your application sees
927
1051
 
@@ -948,7 +1072,7 @@ Where the events of a question come from:
948
1072
  | `retry` | the retry rule ([Retries and waits](#retries-and-waits)) | Before each wait, between the request's start and end. |
949
1073
  | `text` | the answering model's replies | As the text arrives with `streamText`; otherwise once each reply is in. The same text as `onText`. |
950
1074
  | `tool.start`, `tool.progress`, `tool.end` | the calls of a turn ([The calls of a turn](#the-calls-of-a-turn)) | A call starts when it runs, so starts and ends of one turn interleave; ends come in call order. `tool.progress` is the progress of a whole-file read. |
951
- | `notice` | the loop | What it did that is not a request or a call: `searching_instead`, `writing_answer`, `replanned`, `room_made`, `nudged`, `results_shortened`, `answer_again`, `calls_not_run`, and three that the callbacks never got: `budget_reached`, `no_room`, `blocked`. |
1075
+ | `notice` | the loop | What it did that is not a request or a call: `searching_instead`, `writing_answer`, `replanned`, `room_made`, `nudged`, `results_shortened`, `answer_again`, `calls_not_run`, and those that the callbacks never got: `budget_reached`, `no_room`, `blocked`, and, new in 0.9.0, `documents_missing`, `document_gone` and `page_looks_busy`. |
952
1076
  | `run.finish`, `run.error` | `askWithFiles` | Last, once. Nothing comes after them, not even a part read still running. |
953
1077
 
954
1078
  The events tell a model error by its kind and status, never in the provider's words, and carry no
@@ -1003,7 +1127,7 @@ What differs is in the adapters:
1003
1127
  | `tokenScale` | 1 | 1 by default (`tokenScale`) | 1.35 by default (`tokenScale`) |
1004
1128
  | Kept free in the window for the reply | nothing | nothing | `maxTokens`, 64,000 by default |
1005
1129
  | Request size declared | none, unless you set `maxRequestBytes` | none, unless you set `maxRequestBytes` | 32,000,000 bytes by default (`maxRequestBytes`) |
1006
- | Old results shortened for room | yes, unless Claude is the other model of the question | yes, unless Claude is the other model of the question | no: the conversation may only grow (`appendOnly`); with Claude as the answering model or the explorer, nothing is shortened for either |
1130
+ | Old results shortened for room | yes, unless Claude is the other model of the question | yes, unless Claude is the other model of the question | no: the conversation may only grow (`appendOnly`); with Claude as the answering model or the explorer, nothing is shortened for either during the question. The stored rounds of earlier questions are, before its first request, when they make it too large (since 0.9.0) |
1007
1131
  | Prompt cache | the provider's own | the provider's own | `cache_control` on each request: 5 minutes, `cache: "1h"`, or `false` for none |
1008
1132
  | Streams the chat | when the loop asks for the text as it is written (`streamText`: with `onText`, or in `askStream`) and the endpoint has a `streamUrl` | when the loop asks for the text as it is written, unless `stream: false` | always, unless `stream: false` |
1009
1133
  | A whole stream ends with | a chunk with a `finishReason` | a `finish_reason`, or `[DONE]` | a stop reason |
@@ -1037,8 +1161,9 @@ explorer (`explorerUrl`, which `explorerModel` of `geminiApi()` and `vertexAi()`
1037
1161
  second `gemini()` for it, called with the same headers, without streaming, with
1038
1162
  `explorerGenerationConfig` or else `generationConfig`. `maxToolTurns` and `maxToolCallsPerTurn` are
1039
1163
  the names that `limits.toolTurns` and `limits.callsPerTurn` had before 0.5.0; `limits` wins.
1040
- `contents` are converted to messages with `fromGeminiContents`. Everything above applies; what is
1041
- Gemini's own:
1164
+ `contents` are converted to messages with `fromGeminiContents`: since 0.9.0 the tool rounds that
1165
+ `geminiToolTurns` wrote come back as stored rounds, so pointers and stand-ins apply to them, and any
1166
+ other function part is sized by its JSON. Everything above applies; what is Gemini's own:
1042
1167
 
1043
1168
  - **The model's turns go back unchanged**, so Gemini 3 thought signatures stay intact. A signature
1044
1169
  belongs to the model that wrote it: with an explorer, the answering model gets the explorer's
@@ -7,7 +7,7 @@ has not.
7
7
 
8
8
  Each result is a measurement at one point in time, with the models named. It is not a guarantee.
9
9
  Another model, a later version of the same model, another provider or other files can give other
10
- results. Nothing was run again for this page but one record, which says so: each result is given
10
+ results. Nothing was run again for this page but two records, which say so: each result is given
11
11
  as it was recorded, with the release it was recorded for. Before you rely on a number, check it on your own files
12
12
  ([Measuring your own setup](#measuring-your-own-setup)).
13
13
 
@@ -18,8 +18,8 @@ as it was recorded, with the release it was recorded for. Before you rely on a n
18
18
  probe that reproduced a fault, and so does this page.
19
19
  - **Version** is the release a result was recorded for. 0.1.0 is of 2026-11-06, 0.2.0 and 0.3.0 of
20
20
  2026-11-10, 0.3.5 and 0.3.6 of 2026-11-11, 0.4.0 of 2026-11-12, and 0.4.1 and 0.5.0 of
21
- 2026-11-13. The checks of 0.6.0 are of November 2026. All live results are of
22
- November 2026.
21
+ 2026-11-13. The checks of 0.6.0 are of November 2026. The live results of 0.10.0, not released
22
+ yet, are of 2026-11-24. All live results are of November 2026.
23
23
  - **Main** is a result recorded on the code on `main` up to commit 5157e7f (2026-11-20), or on its
24
24
  branches, before the rest of 0.6.0 was written. "The 0.6 review" is the review of that code, of
25
25
  2026-11-20.
@@ -38,9 +38,9 @@ as it was recorded, with the release it was recorded for. Before you rely on a n
38
38
 
39
39
  | Provider | Live runs on record | Not run live |
40
40
  |---|---|---|
41
- | Gemini API: `askGemini`, `gemini()`, `geminiApi()` | From 0.1.0 to 0.5.0: large files, pages of PDFs, explorer pairs, follow-up questions | Gemini 2.5 with pages (`toolFilePlacement`) and in explorer pairs: it is closed to new users on the Gemini API |
42
- | Vertex AI: `vertexAi()` | 0.3.0: pages of PDFs, in the locations `global` and `eu`. 0.3.5: explorer pairs. Main (see above): a count, a repeated search, the error of a request too large, and in the 0.6 review a production log of 3 MB | |
43
- | OpenAI-compatible: `openAiCompatible()` | 0.5.0: Gemini's OpenAI layer only | Every other server: OpenAI, Azure OpenAI, DeepSeek, OpenRouter, vLLM, Ollama, LiteLLM, llama.cpp. The adapter is tested against fake servers. `pdfInput` was never run to an answer: Gemini's OpenAI layer refuses its `file` part (HTTP 400), it was not run against OpenAI itself, and it follows OpenAI's documented shape untested |
41
+ | Gemini API: `askGemini`, `gemini()`, `geminiApi()` | From 0.1.0 to 0.5.0: large files, pages of PDFs, explorer pairs, follow-up questions. 0.10.0: the prompt cache, thought signatures of earlier questions, and the eval's cases at pass^3 ([below](#0100-live-on-the-gemini-api)) | Gemini 2.5 with pages (`toolFilePlacement`) and in explorer pairs: it is closed to new users on the Gemini API |
42
+ | Vertex AI: `vertexAi()` | 0.3.0: pages of PDFs, in the locations `global` and `eu`. 0.3.5: explorer pairs. Main (see above): a count, a repeated search, the error of a request too large, and in the 0.6 review a production log of 3 MB | Everything of 0.10.0, among it thought signatures of earlier questions, Model Armor, `LANGUAGE` and labels |
43
+ | OpenAI-compatible: `openAiCompatible()` | 0.5.0: Gemini's OpenAI layer only. 0.10.0: a streamed tool call on Gemini's OpenAI layer | Every other server: OpenAI, Azure OpenAI, DeepSeek, OpenRouter, vLLM, Ollama, LiteLLM, llama.cpp. The adapter is tested against fake servers. `pdfInput` was never run to an answer: Gemini's OpenAI layer refuses its `file` part (HTTP 400), it was not run against OpenAI itself, and it follows OpenAI's documented shape untested |
44
44
  | Claude: `anthropic()` | None | The whole adapter. It is tested against the request and response shapes of the Messages API documentation |
45
45
 
46
46
  Also live on Gemini, with the record not saying whether on the Gemini API or on Vertex AI: Gemini
@@ -314,6 +314,11 @@ of three, and no search.
314
314
  follow-up that was sent the stored tool rounds of the first question and repeated its first search
315
315
  got a pointer to the earlier result, instead of a second run, and answered from that result.
316
316
 
317
+ **Stored rounds sent back as their calls (0.10.0, live on the Gemini API).** See
318
+ [the live session of 0.10.0](#the-live-session-on-the-gemini-api): on 3.8 Flash, in the one shape
319
+ tried, a follow-up whose rounds went back as their calls, as 0.9 and 0.10.0 send them, kept only
320
+ the system text and tools in the cache.
321
+
317
322
  The [Conversations guide](./guides/conversations.md) shows how to keep tool rounds.
318
323
 
319
324
  ## Usage and the size of a request
@@ -350,13 +355,48 @@ MB took over 600 MB. Since 0.4.0 every use of a document kept in memory asks the
350
355
  quotes, backslashes, tabs or many line breaks low: by 23% for a JSON-lines export and 31% for TSV.
351
356
  A read of quoted text came out at 42,514 characters against a cap of 24,000.
352
357
 
353
- **Memory and stalls of an ingest (main, November 2026, Node 24 on Windows, plain-text logs).**
354
- Peak memory above the uploaded bytes: about 175 MB for a log of 25 MB, 270 MB for 50 MB, and 470 MB
355
- for 95 MB. An ingest of the 95 MB log fitted in a worker thread of 256 MB. One exact search of the
356
- 95 MB log, read by range, took about 60 to 80 MB. Eight such searches at once took about 70 to 85
357
- MB, and about 220 MB with `cacheBytes` at 1 GB, which keeps the decoded pieces. An ingest held the
358
- event loop for about 0.8 to 1.5 seconds (25 MB) and 3 to 5 seconds (95 MB). Linux was not
359
- measured. [Deployment](./guides/deployment.md) turns these into sizing advice.
358
+ **Memory and stalls of an ingest (history: main before 0.6.0, November 2026, Node 24 on Windows,
359
+ plain-text logs).** Recorded on 2026-11-20, with the docs of #12, on the code of 0.5.0 and the fixes
360
+ after it (`main` above), before 0.6.0 made an ingest work in slices. The stalls are those of the
361
+ ingest of 0.5.0, in one block: 0.6.0 and later have none of seconds (the record after this one, and
362
+ the table of 0.6.0 below). Peak memory above the uploaded bytes: about 175 MB for a log of 25 MB,
363
+ 270 MB for 50 MB, and 470 MB for 95 MB. An ingest of the 95 MB log fitted in a worker thread of
364
+ 256 MB. One exact search of the 95 MB log, read by range, took about 60 to 80 MB. Eight such
365
+ searches at once took about 70 to 85 MB, and about 220 MB with `cacheBytes` at 1 GB, which keeps the
366
+ decoded pieces. An ingest held the event loop for about 0.8 to 1.5 seconds (25 MB) and 3 to 5
367
+ seconds (95 MB). Linux was not measured.
368
+
369
+ **Memory and stalls of an ingest, measured again (0.9.0 in development, 2026-11-23, Node 22.23 on
370
+ Linux, plain-text logs).** Logs of 25, 50 and 95 MB made by `serviceLog` of `llm-large-files/testing`
371
+ (about 88 ASCII characters a line), each sent to `files.ingest` over a `FileDocumentStore` in a
372
+ temporary folder, in a fresh process with Node's default heap, on the build of 86b9bfd. A laptop
373
+ (Intel Core i5-8250U, 4 cores and 8 threads, 8 GB) that ran other work too: the load average was 5
374
+ to 14. Peak memory is the kernel's high-water mark of the resident set, less the resident set once
375
+ the log was read into memory, so the uploaded bytes are not in it. A stall is the longest gap between
376
+ two beats of a 5 ms timer, as in the table of 0.6.0 below.
377
+
378
+ | Log | Peak above the uploaded bytes | Longest stall | Ingest took |
379
+ |---|---|---|---|
380
+ | 25 MB, 295,660 lines (5 runs) | 133 to 136 MB | 56 to 64 ms; 134 ms in one run at a load of 6 | 3.3 to 3.8 s; 6.8 s in that run |
381
+ | 50 MB, 591,315 lines (5 runs) | 194 to 206 MB | 126 to 307 ms, at a load of 13 to 14 | 6.2 to 15.3 s |
382
+ | 95 MB, 1,123,485 lines (5 runs) | 342 to 347 MB | 233 to 360 ms | 11.6 to 14.9 s |
383
+
384
+ Over a `MemoryDocumentStore` (2 runs each), the peaks were 78 to 81 MB, 123 MB and 204 to 206 MB,
385
+ with the stored text in them. Its longest stall for the 95 MB log was about 150 to 240 ms, the UTF-8
386
+ decoding below. The 95 MB log also fitted in a heap of 256 MB
387
+ (`--max-old-space-size=256`), and of 192, over a `FileDocumentStore`. The longest stalls are two
388
+ steps that run in one block, each taking about 2 to 4 ms for each MB of text on this machine:
389
+
390
+ - the decoding of the whole UTF-8 file when its reading starts (the same `TextDecoder` call alone
391
+ took 192 to 205 ms for the 95 MB log);
392
+ - over a `FileDocumentStore`, the writing of the text, which encodes it to UTF-8 in one call
393
+ (`Buffer.from` alone took 184 to 217 ms).
394
+
395
+ The other steps pause about every 12 ms (gaps of 40 to 70 ms on this busy machine). 0.6.0 decoded
396
+ the same way and measured 31 to 34 ms for a 99 MB log (below), on Windows with Node 24. The store
397
+ does not explain the difference, since the decoding is one block over either store: the machine
398
+ and its load do.
399
+ [Deployment](./guides/deployment.md) turns these into sizing advice.
360
400
 
361
401
  **Many uploads at once (0.8.2, November 2026, Node 22 on Linux, 8 cores).** 100 logs of 2 MB
362
402
  (190.7 MB, about 10% of the lines in Hebrew), read into memory first as the upload handler does,
@@ -802,6 +842,168 @@ as one string. Two runs each.
802
842
 
803
843
  [Security](./security.md) explains the limits that came of these measurements.
804
844
 
845
+ ## 0.10.0, live on the Gemini API
846
+
847
+ Released on 2026-11-25. Everything here ran on 2026-11-24 on the Gemini API (`geminiApi()`), with
848
+ `gemini-3.5-flash-lite` and `gemini-3.8-flash`, over synthetic files. Nothing ran on Vertex AI:
849
+ there was no project, so Model Armor, `LANGUAGE` and labels were not seen. The cached share of a
850
+ request is recorded here, never used as a gate. The release gate of 0.10.0 is the live gates of
851
+ packages P1 and T below, over the same requests: the eval replay matches each request of the
852
+ release to its recording byte for byte, keys and project IDs aside.
853
+
854
+ ### The live session on the Gemini API
855
+
856
+ On the code of 0.10.0 before packages P1 and T merged (commit bf13a4d), with stored rounds sent
857
+ as their calls. 212 requests: 3,831,750 input tokens reported, 2,352,245 of them cached, and 32,581
858
+ output tokens. A second check of every figure against the raw records corrected a few. Not
859
+ measured: streamed Gemini requests, `functionCallingMode: "VALIDATED"`, and a request for the
860
+ answer with mode AUTO.
861
+
862
+ **The prompt cache under `answerWithoutTools` "omit" and "mode_none".** Chats of 4 questions under
863
+ `"first"`, a Hebrew policy sent whole (a first user turn of about 44K tokens) and a searched Hebrew
864
+ CSV of 6,000 rows; 2 chats per model and mode, 10 s before each follow-up.
865
+
866
+ | Model | Mode | Follow-up's first request cached (mean, range) | Follow-up's closing request cached |
867
+ | --- | --- | --- | --- |
868
+ | gemini-3.5-flash-lite | omit | 93.9% (93.0-94.6) | 93.0% (91.7-94.3) |
869
+ | gemini-3.5-flash-lite | mode_none | 93.9% (93.1-94.5) | 93.0% (91.8-94.0) |
870
+ | gemini-3.8-flash | omit | 94.9% (94.8-94.9) | 94.8% (94.6-95.2) |
871
+ | gemini-3.8-flash | mode_none | 94.9% (94.8-95.0) | 94.8% (94.6-95.2) |
872
+
873
+ - The first question's requests: 0% cached in 8 of 8. A follow-up was cached up to about 2,100 to
874
+ 2,300 tokens short of the end of the first user turn: Google documents that a follow-up
875
+ processes the last 2,050 tokens of the previous request again.
876
+ - A request for the answer with no earlier one in the chat (a policy of about 12K tokens): 0%
877
+ cached in 8 of 8, under both modes. Under `"mode_none"` it cost 12,379 to 12,529 input tokens,
878
+ against 10,581 to 10,630 under `"omit"`. So `"omit"` stays the default.
879
+ - Requests sent 27 to 197 ms after a reply were 50% to 68% cached: no wait is needed before a
880
+ follow-up. The least size the cache takes was not found.
881
+
882
+ **Thought signatures of earlier questions.** The first question made one round of two calls at
883
+ once; the model's turn carried a signature on its first call (204 characters on Flash-Lite, 1,024
884
+ and 872 on 3.8 Flash). The second question sent it back three ways. Every request had status 200,
885
+ 12 of 12. On 3.8 Flash the signature was read and billed: 215 and 133 input tokens more for each
886
+ signed round, and 57 to 111 thought tokens against none with calls only. Whether the answers of
887
+ the second question changed was not checked.
888
+
889
+ | Signature sent | Result |
890
+ | --- | --- |
891
+ | As it came | 200 |
892
+ | From the first question of another chat, same model | 200 |
893
+ | From the other model | 200; on 3.8 Flash billed as no signature: most likely ignored |
894
+ | 8 base64 characters changed | 400 `Invalid thought signature.` |
895
+ | Random bytes of the same length, or cut to half | 400 `Corrupted thought signature.` |
896
+ | The current question's signature removed | 400 `Function call is missing a thought_signature in functionCall parts. …` |
897
+
898
+ The library makes each 400 a `GeminiRequestError` of kind `"invalid"`. The Gemini API refuses
899
+ damaged signatures, not reused ones. Not tried: a signature of another round, and base64 encoded
900
+ again on the way. No reply ended with `MISSING_THOUGHT_SIGNATURE`. 0.10.0 sends the rounds of
901
+ earlier questions as their calls, with no signature, as 0.9 did.
902
+
903
+ **Four checks of earlier figures.**
904
+
905
+ - **Token estimates:** `estimateTokens` against `countTokens` (the same on both models) was 1.122
906
+ for a service log (1.98 characters per token), 1.138 for a CSV of numbers (1.00) and 1.099 for
907
+ Hebrew prose (2.21): still above the provider's count. The record of 0.2.0 said 1.05 to 1.10.
908
+ - **A DOCX sent inline as a file** (3,279 bytes, a table of 4 by 3) was read right on both models,
909
+ the empty cell named, 4 of 4. Its content was not counted in `promptTokenCount`.
910
+ - **Gemini's OpenAI layer, a streamed tool call:** one chunk with the role and the whole call (an
911
+ ID, no `index`), then `finish_reason: "stop"`, then `[DONE]`. Through `openAiCompatible()` the
912
+ answer was right. On 3.8 Flash, `total_tokens` was about 46 more than the prompt and the output:
913
+ thinking that is billed and not reported.
914
+ - **The request for the answer:** 58 of 58 came back as text, with no tool call.
915
+
916
+ **Why calls only lost the cache on 3.8 Flash.** A follow-up run the same day (67 requests, 479,663
917
+ input tokens) explains a loss the session left open. The first question's second request sends
918
+ the model's turn back with its real signature, then the results. On 3.8 Flash, the first request
919
+ after it that does not extend its whole prompt kept only about the system text and tools in the
920
+ cache (2,343 to 2,362 tokens), in 10 of 10 trials. The same body hit at the usual level, 6 of 6,
921
+ when sent after the first request alone, or after one carrying Google's documented stand-in
922
+ signature. Each way of sending the rounds back as the first follow-up, in a chat of its own:
923
+
924
+ | Rounds sent back | Trials | Cached |
925
+ | --- | --- | --- |
926
+ | As their calls (0.9 and 0.10.0) | 9 | the system text and tools only: 33.7% at 7K tokens, 15.7% at 15K |
927
+ | As they were sent, signatures included | 3 | 69.5% at 7.1K, 85.7% at 15.3K, and one total miss at 6.4K |
928
+
929
+ So on the Gemini API, rounds sent back as they were cost no cache, and likely gain. A signed round
930
+ is billed in full on every later request that carries it. This is shown for one shape: one round
931
+ of two calls. Not tested: single calls, several rounds, a loop that ends with the request for the
932
+ answer, and Vertex AI. 0.10.0 still sends the rounds of earlier questions as their calls; sending
933
+ them as they were is planned for a later version.
934
+ [Conversations](./guides/conversations.md#what-toolturns-holds) has what the library sends.
935
+
936
+ ### Tables sent whole (P1's live gate)
937
+
938
+ The eval's 28 cases of package P1, three runs of each on both models (pass^3), at commit 64a4ec8:
939
+ tables sent whole with `search_document`, `read_document` and `aggregate_table`, and numbered
940
+ files sent whole. 12,160,431 input tokens in all.
941
+
942
+ | Gate | Bar | gemini-3.5-flash-lite | gemini-3.8-flash |
943
+ | --- | --- | --- | --- |
944
+ | Cases passed in every run | | 27 of 28 | 28 of 28 |
945
+ | Count questions answered right | 100% | 24 of 24 | 24 of 24 |
946
+ | Hebrew lookups answered right | at least 90% | 42 of 42 | 42 of 42 |
947
+ | Hebrew questions answered in Hebrew | every run | 75 of 75 | 75 of 75 |
948
+ | Citations inside what the tools showed | at least 90% | 100% | 100% |
949
+ | Answers with no citation recognized | at most 10% | 5% | 0% |
950
+ | Questions over a table with no count, in one request | at least 90% | 54% (21 of 39) | 97% (38 of 39) |
951
+ | Count questions over a table, requests at the median | at most 3 | 2 | 2 |
952
+ | Facts lost against 0.9.0 | none | 0 | 0 |
953
+
954
+ - **Cost against 0.9.0**, on the cases both ran: input tokens per run about 2.3 to 2.4 times;
955
+ median latency from 0.9 to 1.2 s on Flash-Lite, and from 4.6 to 5.4 s on 3.8 Flash. The cached
956
+ share was 76% on Flash-Lite and 65% on 3.8 Flash.
957
+ - **Flash-Lite looks rows up with a tool** when the table is shown in full: a lookup in a CSV or a
958
+ workbook takes a search or a read first, so 2 requests, each with the table. That makes it
959
+ exact: 0.9.0, by eye, got the invoice lookup wrong in 3 of 3 runs. A read of lines 1-5 of a CSV
960
+ of 3,000 rows it already had took 244,654 input tokens a question, against 122,208 on 3.8 Flash.
961
+ This is accepted as a limit of Flash-Lite, not tuned.
962
+ - **The one miss** was a lookup in English on Flash-Lite (orders-row, 2 of 3): a keywords search
963
+ gave a passage of 40 rows, and the answer took the amount from a row four lines up. 0.9.0 missed
964
+ it the same way.
965
+
966
+ ### Whole-file reads and items (package T)
967
+
968
+ **Whole-file reads, pass^3,** on the code of c1fbbb5, which adds the `whole_file` hint to a
969
+ `read_document` result cut short (992,188 input tokens):
970
+
971
+ | Case | gemini-3.5-flash-lite | gemini-3.8-flash |
972
+ | --- | --- | --- |
973
+ | contract-summary (a Hebrew contract read whole) | 3 of 3 | 3 of 3 |
974
+ | diary-timeline (a month of a shift diary, week by week) | 2 of 3 | 3 of 3 (it searched) |
975
+
976
+ - In Flash-Lite's failed run, two of the five part replies were `NOTHING RELEVANT`, and the
977
+ incidents of 11 and 19 October were lost.
978
+ - An A/B of that read on Flash-Lite, 8 reads with 0.10.0's prompts and 8 with 0.9.0's (860,961
979
+ input tokens): no part with an incident replied `NOTHING RELEVANT` on either (0 of 32 each), 3
980
+ parts of 40 did on 0.10.0 against 8 of 40 on 0.9.0, all on the part without one, and no date was
981
+ lost in the 16 reads. The live miss, about one run in three, is recorded as a limit of
982
+ Flash-Lite, the same as 0.9.0, not tuned.
983
+ - Lookups and counts over searched contracts, two runs each on both models: 16 of 16 passed, with
984
+ no whole read: the hint does not push them into reads.
985
+ - Measured, not gated: on cleaning-sanctions, a count of 37 sanctions, Flash-Lite answered 31 and
986
+ 35 from reads as an answer and never asked for `output: "items"` (0 of 3); 3.8 Flash read a
987
+ planted November diary whole in none of 3 runs and passed 1 of 3.
988
+
989
+ **Items reads** (`analyze_whole_document` with `output: "items"`), called on the tool set directly:
990
+ three reads of each file by each model in each round, parts of about 2,000 tokens. contract-1 has
991
+ 37 fines; cleaning-1 37 sanctions in four wordings. The gate on Flash-Lite: at least 95% of part
992
+ replies parse, and the totals are exact.
993
+
994
+ | Round | Flash-Lite replies parsed | Flash-Lite totals exact | 3.8 Flash replies parsed | 3.8 Flash totals exact |
995
+ | --- | --- | --- | --- | --- |
996
+ | 1, the first rules | 23 of 31 (74%) | 0 of 6 | 27 of 27 | 6 of 6 |
997
+ | 4, quotes of a few words | 27 of 27 | 4 of 6 | 15 of 15 | 3 of 3 |
998
+ | 5, the near check, a part with its heading | 27 of 27 | 3 of 6 | 27 of 27 | 6 of 6 |
999
+ | 6 (c1fbbb5), quotes of five to twelve words | 27 of 27 | 4 of 6: contract-1 37, 37, 37; cleaning-1 36, 24, 37 | 27 of 27 | 6 of 6 |
1000
+
1001
+ - Round 6 meets the gate on contract-1, the planted contract. cleaning-1 is not gated: in its run
1002
+ of 24, one part with 10 sanctions replied `NOTHING RELEVANT`.
1003
+ - A line planted in a part that tells the reader to reply `NOTHING RELEVANT` was not followed: the
1004
+ part's notes kept the incident in 6 of 6 reads, three on each model.
1005
+ - Package T's live calls came to 10,634,007 input tokens in all.
1006
+
805
1007
  ## Faults reproduced before a fix
806
1008
 
807
1009
  Numbers from probes and tests that showed a fault, not from live runs. Each is fixed in the version