mixdog 0.9.62 → 0.9.64

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 (403) hide show
  1. package/README.md +3 -0
  2. package/package.json +9 -2
  3. package/scripts/code-graph-description-contract.mjs +3 -3
  4. package/scripts/verify-release-assets.mjs +2 -2
  5. package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +11 -14
  6. package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +6 -6
  7. package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +2 -2
  8. package/src/runtime/agent/orchestrator/agent-trace-format.mjs +1 -0
  9. package/src/runtime/agent/orchestrator/config.mjs +19 -124
  10. package/src/runtime/agent/orchestrator/context/collect.mjs +6 -6
  11. package/src/runtime/agent/orchestrator/dispatch-persist.mjs +2 -2
  12. package/src/runtime/agent/orchestrator/internal-agents.mjs +2 -2
  13. package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +1 -1
  14. package/src/runtime/agent/orchestrator/mcp/client.mjs +4 -4
  15. package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +2 -2
  16. package/src/runtime/agent/orchestrator/providers/anthropic-betas.mjs +4 -4
  17. package/src/runtime/agent/orchestrator/providers/anthropic-effort.mjs +2 -2
  18. package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens.mjs +4 -4
  19. package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +333 -0
  20. package/src/runtime/agent/orchestrator/providers/anthropic-model-resolve.mjs +2 -2
  21. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +4 -4
  22. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +1 -1
  23. package/src/runtime/agent/orchestrator/providers/anthropic.mjs +3 -277
  24. package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +2 -2
  25. package/src/runtime/agent/orchestrator/providers/custom-tool-wire.mjs +1 -1
  26. package/src/runtime/agent/orchestrator/providers/gemini-cache.mjs +2 -2
  27. package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +6 -6
  28. package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +196 -0
  29. package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +460 -0
  30. package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +14 -593
  31. package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +1 -1
  32. package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +1 -1
  33. package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +1 -1
  34. package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +4 -4
  35. package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +2 -2
  36. package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +5 -280
  37. package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +357 -0
  38. package/src/runtime/agent/orchestrator/providers/openai-ws-headers.mjs +216 -0
  39. package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +2 -188
  40. package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +2 -2
  41. package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +2 -2
  42. package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +1 -1
  43. package/src/runtime/agent/orchestrator/providers/provider-catalog-cache.mjs +1 -1
  44. package/src/runtime/agent/orchestrator/providers/registry.mjs +1 -1
  45. package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +2 -2
  46. package/src/runtime/agent/orchestrator/providers/statusline-route-meta.mjs +1 -1
  47. package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.mjs +1 -1
  48. package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +3 -3
  49. package/src/runtime/agent/orchestrator/session/compact/budget.mjs +2 -2
  50. package/src/runtime/agent/orchestrator/session/compact/file-reattach.mjs +2 -2
  51. package/src/runtime/agent/orchestrator/session/compact/summary-schema.mjs +1 -1
  52. package/src/runtime/agent/orchestrator/session/compact/summary.mjs +1 -1
  53. package/src/runtime/agent/orchestrator/session/compact/text-utils.mjs +2 -2
  54. package/src/runtime/agent/orchestrator/session/context-utils.mjs +4 -4
  55. package/src/runtime/agent/orchestrator/session/loop/deferred-call-through.mjs +1 -1
  56. package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +17 -0
  57. package/src/runtime/agent/orchestrator/session/loop/steering.mjs +1 -1
  58. package/src/runtime/agent/orchestrator/session/loop/stored-tool-args.mjs +18 -26
  59. package/src/runtime/agent/orchestrator/session/loop/termination.mjs +1 -1
  60. package/src/runtime/agent/orchestrator/session/loop/tool-classify.mjs +3 -3
  61. package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +1 -0
  62. package/src/runtime/agent/orchestrator/session/manager/context-meta.mjs +1 -1
  63. package/src/runtime/agent/orchestrator/session/manager/delivered-completions.mjs +1 -1
  64. package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +1 -1
  65. package/src/runtime/agent/orchestrator/session/store/live-state.mjs +49 -0
  66. package/src/runtime/agent/orchestrator/session/store/load-cache.mjs +49 -0
  67. package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +260 -0
  68. package/src/runtime/agent/orchestrator/session/store/serialize.mjs +72 -0
  69. package/src/runtime/agent/orchestrator/session/store/summary-cache.mjs +163 -0
  70. package/src/runtime/agent/orchestrator/session/store/write-guards.mjs +1 -1
  71. package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +1 -1
  72. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +4 -1
  73. package/src/runtime/agent/orchestrator/session/store.mjs +9 -561
  74. package/src/runtime/agent/orchestrator/session/tool-envelope.mjs +1 -1
  75. package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +2 -2
  76. package/src/runtime/agent/orchestrator/stall-policy.mjs +11 -11
  77. package/src/runtime/agent/orchestrator/tools/bash-policy-scan.mjs +1 -1
  78. package/src/runtime/agent/orchestrator/tools/bash-session.mjs +2 -2
  79. package/src/runtime/agent/orchestrator/tools/builtin/advisory-lock.mjs +1 -1
  80. package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +2 -2
  81. package/src/runtime/agent/orchestrator/tools/builtin/atomic-write.mjs +1 -1
  82. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +2 -154
  83. package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +1 -1
  84. package/src/runtime/agent/orchestrator/tools/builtin/cwd-utils.mjs +1 -1
  85. package/src/runtime/agent/orchestrator/tools/builtin/fs-reachability.mjs +1 -1
  86. package/src/runtime/agent/orchestrator/tools/builtin/fuzzy-match.mjs +1 -1
  87. package/src/runtime/agent/orchestrator/tools/builtin/glob-walk.mjs +1 -1
  88. package/src/runtime/agent/orchestrator/tools/builtin/path-locks.mjs +1 -1
  89. package/src/runtime/agent/orchestrator/tools/builtin/path-utils.mjs +1 -1
  90. package/src/runtime/agent/orchestrator/tools/builtin/read-args.mjs +2 -2
  91. package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +2 -3
  92. package/src/runtime/agent/orchestrator/tools/builtin/read-image-resize.mjs +4 -4
  93. package/src/runtime/agent/orchestrator/tools/builtin/read-open.mjs +1 -1
  94. package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +1 -1
  95. package/src/runtime/agent/orchestrator/tools/builtin/rg-runner.mjs +2 -2
  96. package/src/runtime/agent/orchestrator/tools/builtin/search-path-diagnostics.mjs +5 -5
  97. package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +1 -1
  98. package/src/runtime/agent/orchestrator/tools/builtin/shell-job-paths.mjs +2 -2
  99. package/src/runtime/agent/orchestrator/tools/builtin/shell-job-process.mjs +2 -2
  100. package/src/runtime/agent/orchestrator/tools/builtin/shell-job-spawn.mjs +519 -0
  101. package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +5 -449
  102. package/src/runtime/agent/orchestrator/tools/builtin/snapshot-helpers.mjs +1 -1
  103. package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +212 -0
  104. package/src/runtime/agent/orchestrator/tools/builtin.mjs +1 -1
  105. package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +1 -7
  106. package/src/runtime/agent/orchestrator/tools/code-graph/disk-cache.mjs +9 -36
  107. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +15 -3
  108. package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +429 -0
  109. package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +2 -395
  110. package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +2 -2
  111. package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.mjs +1 -1
  112. package/src/runtime/agent/orchestrator/tools/code-graph/trusted-roots.mjs +1 -1
  113. package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +1 -1
  114. package/src/runtime/agent/orchestrator/tools/code-graph-state.mjs +3 -3
  115. package/src/runtime/agent/orchestrator/tools/mutation-planner.mjs +5 -5
  116. package/src/runtime/agent/orchestrator/tools/next-call-utils.mjs +1 -1
  117. package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +1 -1
  118. package/src/runtime/agent/orchestrator/tools/patch/matcher.mjs +7 -7
  119. package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +72 -9
  120. package/src/runtime/agent/orchestrator/tools/patch/parsing.mjs +4 -4
  121. package/src/runtime/agent/orchestrator/tools/patch/paths.mjs +1 -1
  122. package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +1 -1
  123. package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +4 -4
  124. package/src/runtime/agent/orchestrator/tools/patch.mjs +1 -1
  125. package/src/runtime/agent/orchestrator/tools/result-compression.mjs +3 -3
  126. package/src/runtime/agent/orchestrator/tools/shell-command.mjs +2 -444
  127. package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +505 -0
  128. package/src/runtime/agent/orchestrator/tools/shell-exec-policy.mjs +2 -2
  129. package/src/runtime/agent/orchestrator/tools/shell-snapshot.mjs +1 -1
  130. package/src/runtime/channels/lib/backend-dispatch.mjs +20 -5
  131. package/src/runtime/channels/lib/scheduler.mjs +1 -1
  132. package/src/runtime/channels/lib/telegram-format.mjs +1 -1
  133. package/src/runtime/channels/lib/voice-runtime-fetcher.mjs +4 -4
  134. package/src/runtime/channels/tool-defs.mjs +2 -3
  135. package/src/runtime/memory/index.mjs +1 -5
  136. package/src/runtime/memory/lib/core-memory-candidates.mjs +357 -0
  137. package/src/runtime/memory/lib/core-memory-store.mjs +7 -357
  138. package/src/runtime/memory/lib/cycle-signatures.mjs +1 -1
  139. package/src/runtime/memory/lib/embedding-model-config.mjs +1 -1
  140. package/src/runtime/memory/lib/embedding-provider.mjs +1 -5
  141. package/src/runtime/memory/lib/embedding-worker.mjs +1 -5
  142. package/src/runtime/memory/lib/ko-morph.mjs +2 -2
  143. package/src/runtime/memory/lib/memory-config-flags.mjs +2 -5
  144. package/src/runtime/memory/lib/memory-cycle-requests.mjs +3 -7
  145. package/src/runtime/memory/lib/memory-cycle1.mjs +4 -8
  146. package/src/runtime/memory/lib/memory-cycle2-gate.mjs +1 -1
  147. package/src/runtime/memory/lib/memory-cycle2-mutations.mjs +1 -1
  148. package/src/runtime/memory/lib/memory-cycle2-shared.mjs +2 -5
  149. package/src/runtime/memory/lib/memory-cycle3.mjs +1 -5
  150. package/src/runtime/memory/lib/memory-embed.mjs +2 -6
  151. package/src/runtime/memory/lib/memory-log.mjs +8 -0
  152. package/src/runtime/memory/lib/memory-ops-policy.mjs +4 -8
  153. package/src/runtime/memory/lib/memory-recall-scope-filter.mjs +1 -1
  154. package/src/runtime/memory/lib/memory-recall-store.mjs +2 -193
  155. package/src/runtime/memory/lib/memory-score.mjs +1 -1
  156. package/src/runtime/memory/lib/memory-text-utils.mjs +2 -2
  157. package/src/runtime/memory/lib/memory.mjs +2 -6
  158. package/src/runtime/memory/lib/pg/adapter.mjs +2 -6
  159. package/src/runtime/memory/lib/pg/process.mjs +1 -5
  160. package/src/runtime/memory/lib/pg/supervisor.mjs +1 -5
  161. package/src/runtime/memory/lib/recall-format.mjs +2 -2
  162. package/src/runtime/memory/lib/recall-scoring.mjs +195 -0
  163. package/src/runtime/memory/lib/runtime-fetcher.mjs +1 -5
  164. package/src/runtime/memory/lib/trace-store.mjs +2 -6
  165. package/src/runtime/search/lib/http-fetch.mjs +6 -6
  166. package/src/runtime/search/lib/web-tools.mjs +2 -2
  167. package/src/runtime/shared/buffered-appender.mjs +1 -1
  168. package/src/runtime/shared/child-guardian.mjs +1 -1
  169. package/src/runtime/shared/child-spawn-gate.mjs +1 -1
  170. package/src/runtime/shared/config.mjs +4 -4
  171. package/src/runtime/shared/launcher-control.mjs +9 -10
  172. package/src/runtime/shared/llm/index.mjs +5 -20
  173. package/src/runtime/shared/markdown-frontmatter.mjs +1 -1
  174. package/src/runtime/shared/memory-snapshot.mjs +4 -4
  175. package/src/runtime/shared/pristine-execution.mjs +1 -1
  176. package/src/runtime/shared/process-lifecycle.mjs +0 -1
  177. package/src/runtime/shared/process-shutdown.mjs +1 -1
  178. package/src/runtime/shared/resource-admission.mjs +2 -2
  179. package/src/runtime/shared/schedule-session-run.mjs +1 -1
  180. package/src/runtime/shared/schedules-db.mjs +1 -1
  181. package/src/runtime/shared/service-discovery.mjs +2 -2
  182. package/src/runtime/shared/staged-update.mjs +6 -6
  183. package/src/runtime/shared/tool-execution-contract.mjs +1 -1
  184. package/src/runtime/shared/tool-primitives.mjs +1 -1
  185. package/src/runtime/shared/tool-surface.mjs +2 -2
  186. package/src/runtime/shared/update-checker.mjs +1 -1
  187. package/src/runtime/shared/user-cwd.mjs +3 -3
  188. package/src/runtime/shared/user-data-guard.mjs +4 -4
  189. package/src/runtime/shared/workspace-router.mjs +5 -5
  190. package/src/session-runtime/config-helpers.mjs +2 -3
  191. package/src/session-runtime/config-lifecycle.mjs +1 -1
  192. package/src/session-runtime/hitch-profile.mjs +1 -1
  193. package/src/session-runtime/lifecycle-api.mjs +6 -4
  194. package/src/session-runtime/model-recency.mjs +5 -5
  195. package/src/session-runtime/plugin-mcp.mjs +1 -1
  196. package/src/session-runtime/provider-request-snapshot.mjs +338 -0
  197. package/src/session-runtime/session-text.mjs +4 -4
  198. package/src/session-runtime/tool-catalog-schema.mjs +197 -0
  199. package/src/session-runtime/tool-catalog.mjs +6 -483
  200. package/src/session-runtime/tool-defs.mjs +1 -1
  201. package/src/standalone/agent-task-status.mjs +1 -1
  202. package/src/standalone/agent-tool/helpers.mjs +2 -2
  203. package/src/standalone/channel-admin.mjs +4 -4
  204. package/src/standalone/explore-tool.mjs +3 -3
  205. package/src/standalone/hook-bus/config.mjs +1 -1
  206. package/src/standalone/hook-bus/constants.mjs +1 -1
  207. package/src/standalone/hook-bus/rules.mjs +1 -1
  208. package/src/standalone/projects.mjs +1 -1
  209. package/src/standalone/provider-admin.mjs +2 -2
  210. package/src/tui/app/app-format.mjs +2 -2
  211. package/src/tui/app/clipboard.mjs +3 -3
  212. package/src/tui/app/input-parsers.mjs +1 -1
  213. package/src/tui/app/text-layout.mjs +1 -1
  214. package/src/tui/app/transcript-row-estimate.mjs +360 -0
  215. package/src/tui/app/transcript-window.mjs +5 -347
  216. package/src/tui/app/use-mouse-input.mjs +1 -1
  217. package/src/tui/app/use-prompt-handlers.mjs +1 -1
  218. package/src/tui/components/tool-execution/surface-detail.mjs +9 -9
  219. package/src/tui/components/tool-execution/text-format.mjs +2 -2
  220. package/src/tui/components/tool-output-format.mjs +7 -7
  221. package/src/tui/display-width.mjs +4 -4
  222. package/src/tui/dist/index.mjs +63 -97
  223. package/src/tui/engine/agent-envelope.mjs +5 -5
  224. package/src/tui/engine/notification-plan.mjs +1 -1
  225. package/src/tui/engine/queue-helpers.mjs +3 -3
  226. package/src/tui/engine/render-timing.mjs +4 -5
  227. package/src/tui/engine/session-api-ext.mjs +3 -3
  228. package/src/tui/engine/tool-result-status.mjs +5 -5
  229. package/src/tui/engine/tool-result-text.mjs +1 -1
  230. package/src/tui/engine/transcript-spill.mjs +585 -0
  231. package/src/tui/engine/tui-steering-persist.mjs +1 -1
  232. package/src/tui/engine.mjs +2 -474
  233. package/src/tui/lib/voice-setup.mjs +1 -1
  234. package/src/tui/markdown/format-token.mjs +1 -1
  235. package/src/tui/markdown/render-ansi.mjs +1 -1
  236. package/src/tui/markdown/table-layout.mjs +4 -4
  237. package/src/tui/paste-attachments.mjs +1 -1
  238. package/src/tui/prompt-history-store.mjs +3 -3
  239. package/src/tui/statusline-ansi-bridge.mjs +2 -2
  240. package/src/tui/theme.mjs +1 -1
  241. package/src/tui/transcript-tool-failures.mjs +2 -2
  242. package/src/ui/ansi.mjs +0 -9
  243. package/src/ui/statusline-format.mjs +2 -4
  244. package/scripts/_bench-cwc.json +0 -20
  245. package/scripts/_jitter-fuzz.jsx +0 -42
  246. package/scripts/_jitter-fuzz2.jsx +0 -30
  247. package/scripts/_jitter-probe.jsx +0 -35
  248. package/scripts/_jp2.jsx +0 -16
  249. package/scripts/_smoke_wd.mjs +0 -7
  250. package/scripts/abort-recovery-test.mjs +0 -175
  251. package/scripts/agent-dispatch-abort-compose-test.mjs +0 -31
  252. package/scripts/agent-live-arg-guard-smoke.mjs +0 -20
  253. package/scripts/agent-live-path-suffix-smoke.mjs +0 -34
  254. package/scripts/agent-live-toolcall-args-smoke.mjs +0 -45
  255. package/scripts/agent-loop-policy-test.mjs +0 -37
  256. package/scripts/agent-model-liveness-test.mjs +0 -763
  257. package/scripts/agent-parallel-smoke.mjs +0 -435
  258. package/scripts/agent-route-batch-test.mjs +0 -40
  259. package/scripts/agent-tag-reuse-smoke.mjs +0 -441
  260. package/scripts/agent-terminal-reap-test.mjs +0 -252
  261. package/scripts/agent-trace-io-test.mjs +0 -133
  262. package/scripts/ansi-color-capability-test.mjs +0 -90
  263. package/scripts/anthropic-admission-retry-integration-test.mjs +0 -119
  264. package/scripts/anthropic-maxtokens-test.mjs +0 -119
  265. package/scripts/anthropic-oauth-refresh-race-test.mjs +0 -397
  266. package/scripts/anthropic-transport-policy-test.mjs +0 -726
  267. package/scripts/apply-patch-edit-smoke.mjs +0 -71
  268. package/scripts/arg-guard-test.mjs +0 -93
  269. package/scripts/async-notify-settlement-test.mjs +0 -99
  270. package/scripts/atomic-lock-tryonce-test.mjs +0 -125
  271. package/scripts/background-task-meta-smoke.mjs +0 -38
  272. package/scripts/bench-run.mjs +0 -508
  273. package/scripts/boot-smoke.mjs +0 -137
  274. package/scripts/build-runtime-windows.ps1 +0 -242
  275. package/scripts/channel-daemon-smoke.mjs +0 -1103
  276. package/scripts/code-graph-aggregate-cwd-test.mjs +0 -158
  277. package/scripts/code-graph-disk-hit-test.mjs +0 -290
  278. package/scripts/code-graph-dispatch-test.mjs +0 -96
  279. package/scripts/code-graph-root-federation-test.mjs +0 -273
  280. package/scripts/compact-active-turn-test.mjs +0 -68
  281. package/scripts/compact-file-reattach-test.mjs +0 -88
  282. package/scripts/compact-pressure-test.mjs +0 -788
  283. package/scripts/compact-prior-context-flatten-test.mjs +0 -252
  284. package/scripts/compact-recall-digest-test.mjs +0 -57
  285. package/scripts/compact-smoke.mjs +0 -1017
  286. package/scripts/compact-trigger-migration-smoke.mjs +0 -261
  287. package/scripts/compacted-placeholder-scrub-test.mjs +0 -63
  288. package/scripts/context-mcp-metering-test.mjs +0 -1406
  289. package/scripts/debounced-skills-async-save-test.mjs +0 -57
  290. package/scripts/deferred-tool-loading-test.mjs +0 -250
  291. package/scripts/desktop-session-bridge-test.mjs +0 -1013
  292. package/scripts/dispatch-persist-recovery-test.mjs +0 -141
  293. package/scripts/embedding-worker-exit-test.mjs +0 -76
  294. package/scripts/execution-completion-dedup-test.mjs +0 -205
  295. package/scripts/execution-pending-resume-kick-test.mjs +0 -151
  296. package/scripts/execution-resume-esc-integration-test.mjs +0 -176
  297. package/scripts/explore-bench-tmp.mjs +0 -36
  298. package/scripts/explore-bench.mjs +0 -248
  299. package/scripts/explore-prompt-policy-test.mjs +0 -256
  300. package/scripts/explore-timeout-cancel-test.mjs +0 -345
  301. package/scripts/find-fuzzy-hidden-test.mjs +0 -267
  302. package/scripts/forwarder-rebind-tail-test.mjs +0 -67
  303. package/scripts/freevar-smoke.mjs +0 -98
  304. package/scripts/gemini-provider-test.mjs +0 -1448
  305. package/scripts/generate-oc-icons.mjs +0 -11
  306. package/scripts/grok-oauth-refresh-race-test.mjs +0 -273
  307. package/scripts/headless-pristine-execution-test.mjs +0 -614
  308. package/scripts/hook-bus-test.mjs +0 -552
  309. package/scripts/ingest-pure-conversation-smoke.mjs +0 -175
  310. package/scripts/internal-comms-bench-test.mjs +0 -226
  311. package/scripts/internal-comms-bench.mjs +0 -853
  312. package/scripts/internal-comms-smoke.mjs +0 -277
  313. package/scripts/internal-tools-normalization-test.mjs +0 -62
  314. package/scripts/interrupted-turn-history-test.mjs +0 -399
  315. package/scripts/lead-workflow-smoke.mjs +0 -592
  316. package/scripts/lifecycle-api-test.mjs +0 -137
  317. package/scripts/live-share-test.mjs +0 -148
  318. package/scripts/live-worker-smoke.mjs +0 -333
  319. package/scripts/log-writer-guard-smoke.mjs +0 -131
  320. package/scripts/maintenance-default-routes-test.mjs +0 -164
  321. package/scripts/max-output-recovery-persist-test.mjs +0 -81
  322. package/scripts/max-output-recovery-test.mjs +0 -368
  323. package/scripts/mcp-client-normalization-test.mjs +0 -45
  324. package/scripts/mcp-grace-deferred-test.mjs +0 -225
  325. package/scripts/memory-core-input-test.mjs +0 -167
  326. package/scripts/memory-cycle-routing-test.mjs +0 -111
  327. package/scripts/memory-meta-concurrency-test.mjs +0 -20
  328. package/scripts/memory-pg-recovery-test.mjs +0 -59
  329. package/scripts/memory-rule-contract-test.mjs +0 -93
  330. package/scripts/model-list-sanitize-test.mjs +0 -37
  331. package/scripts/mouse-tracking-restore-smoke.mjs +0 -107
  332. package/scripts/native-edit-wire-test.mjs +0 -152
  333. package/scripts/notify-completion-mirror-test.mjs +0 -73
  334. package/scripts/openai-oauth-refresh-race-test.mjs +0 -120
  335. package/scripts/openai-oauth-ws-1006-retry-test.mjs +0 -954
  336. package/scripts/openai-ws-early-settle-test.mjs +0 -216
  337. package/scripts/output-style-bench.mjs +0 -292
  338. package/scripts/output-style-smoke.mjs +0 -145
  339. package/scripts/parent-abort-link-test.mjs +0 -90
  340. package/scripts/patch-binary-cache-test.mjs +0 -181
  341. package/scripts/path-suffix-test.mjs +0 -57
  342. package/scripts/pending-completion-drop-test.mjs +0 -239
  343. package/scripts/pending-messages-lock-nonblocking-test.mjs +0 -62
  344. package/scripts/pretool-ask-runtime-test.mjs +0 -54
  345. package/scripts/process-lifecycle-test.mjs +0 -461
  346. package/scripts/prompt-immediate-render-test.mjs +0 -89
  347. package/scripts/prompt-input-parity-test.mjs +0 -145
  348. package/scripts/provider-admission-scheduler-test.mjs +0 -681
  349. package/scripts/provider-contract-test.mjs +0 -632
  350. package/scripts/provider-stream-stall-test.mjs +0 -276
  351. package/scripts/provider-toolcall-test.mjs +0 -3063
  352. package/scripts/reactive-compact-persist-smoke.mjs +0 -203
  353. package/scripts/recall-bench.mjs +0 -359
  354. package/scripts/resource-admission-test.mjs +0 -792
  355. package/scripts/result-classification-test.mjs +0 -75
  356. package/scripts/rg-runner-test.mjs +0 -240
  357. package/scripts/routing-corpus-test.mjs +0 -349
  358. package/scripts/sanitize-tool-pairs-test.mjs +0 -260
  359. package/scripts/session-bench-cache-break-test.mjs +0 -102
  360. package/scripts/session-bench.mjs +0 -1708
  361. package/scripts/session-context-bench.mjs +0 -344
  362. package/scripts/session-heartbeat-lifecycle-test.mjs +0 -68
  363. package/scripts/session-ingest-compaction-smoke.mjs +0 -279
  364. package/scripts/session-ingest-smoke.mjs +0 -177
  365. package/scripts/session-orphan-sweep-test.mjs +0 -109
  366. package/scripts/set-effort-config-test.mjs +0 -41
  367. package/scripts/shell-failure-diagnostics-test.mjs +0 -280
  368. package/scripts/shell-hardening-test.mjs +0 -209
  369. package/scripts/shell-jobs-windows-hide-test.mjs +0 -164
  370. package/scripts/ship-mode-test.mjs +0 -98
  371. package/scripts/smoke-loop-failure-summary-test.mjs +0 -38
  372. package/scripts/smoke-loop-failure-summary.mjs +0 -16
  373. package/scripts/smoke-loop-report.mjs +0 -221
  374. package/scripts/smoke-loop.mjs +0 -202
  375. package/scripts/smoke-runtime-negative.ps1 +0 -106
  376. package/scripts/statusline-quota-hysteresis-test.mjs +0 -62
  377. package/scripts/steering-drain-buckets-test.mjs +0 -467
  378. package/scripts/steering-fold-provenance-test.mjs +0 -71
  379. package/scripts/streaming-tail-window-test.mjs +0 -175
  380. package/scripts/submit-commandbusy-race-test.mjs +0 -257
  381. package/scripts/task-bench.mjs +0 -205
  382. package/scripts/terminal-bench-isolation-guards-test.mjs +0 -102
  383. package/scripts/termio-input-smoke.mjs +0 -199
  384. package/scripts/tool-result-hook-test.mjs +0 -48
  385. package/scripts/tool-smoke.mjs +0 -2453
  386. package/scripts/tool-tui-presentation-test.mjs +0 -286
  387. package/scripts/toolcall-args-test.mjs +0 -239
  388. package/scripts/tui-ambiguous-width-test.mjs +0 -113
  389. package/scripts/tui-background-failure-smoke.mjs +0 -73
  390. package/scripts/tui-perf-run.ps1 +0 -26
  391. package/scripts/tui-render-smoke.mjs +0 -90
  392. package/scripts/tui-runtime-load-bench-entry.jsx +0 -608
  393. package/scripts/tui-runtime-load-bench.mjs +0 -50
  394. package/scripts/tui-store-frame-batch-test.mjs +0 -99
  395. package/scripts/tui-transcript-jitter-harness-entry.jsx +0 -383
  396. package/scripts/tui-transcript-perf-test.mjs +0 -934
  397. package/scripts/usage-metrics-epoch-smoke.mjs +0 -114
  398. package/scripts/verify-release-assets-test.mjs +0 -281
  399. package/scripts/web-fetch-routing-test.mjs +0 -158
  400. package/scripts/webhook-smoke.mjs +0 -201
  401. package/scripts/windows-hide-spawn-options-test.mjs +0 -19
  402. package/scripts/worker-notify-rejection-test.mjs +0 -51
  403. package/scripts/write-backpressure-test.mjs +0 -147
@@ -1,788 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { createRequire } from 'node:module';
4
- import {
5
- estimateMessagesTokens,
6
- estimateRequestReserveTokens,
7
- estimateToolSchemaTokens,
8
- estimateTokens,
9
- IMAGE_VISUAL_TOKEN_ALLOWANCE,
10
- providerTokenCalibration,
11
- summarizeContextMessages,
12
- } from '../src/runtime/agent/orchestrator/session/context-utils.mjs';
13
- import { createContextStatus } from '../src/session-runtime/context-status.mjs';
14
- import {
15
- compactionTelemetryPressureTokens,
16
- recordProviderContextBaseline,
17
- resolveCompactionPressureTokens,
18
- rememberCompactTelemetry,
19
- compactTargetBudget,
20
- resolveWorkerCompactPolicy,
21
- shouldCompactForSession,
22
- } from '../src/runtime/agent/orchestrator/session/loop/compact-policy.mjs';
23
- import { initialCompactionConfig } from '../src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs';
24
- import { resolveSessionCompactionPolicy } from '../src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs';
25
- import { sendWithRecovery } from '../src/runtime/agent/orchestrator/session/send-with-recovery.mjs';
26
- import { recallFastTrackCompactMessages } from '../src/runtime/agent/orchestrator/session/compact/engine.mjs';
27
- import { _combineUsageWithWarmup } from '../src/runtime/agent/orchestrator/providers/openai-ws-events.mjs';
28
- import { applyAskTerminalUsageTotals } from '../src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs';
29
-
30
- function policyFor(session) {
31
- return resolveWorkerCompactPolicy(session, []);
32
- }
33
-
34
- test('Lead/main auto-compaction uses an independent configurable early buffer', () => {
35
- const leadPolicy = policyFor({ contextWindow: 100_000, compaction: {} });
36
- assert.equal(leadPolicy.triggerTokens, 95_000);
37
- assert.equal(leadPolicy.bufferTokens, 5_000);
38
- assert.equal(leadPolicy.bufferRatio, 0.05);
39
-
40
- const noReserve = { ...leadPolicy, reserveTokens: 0 };
41
- assert.equal(shouldCompactForSession(94_999, noReserve), false);
42
- assert.equal(shouldCompactForSession(95_000, noReserve), true);
43
-
44
- const agentPolicy = policyFor({ owner: 'agent', contextWindow: 100_000, compaction: {} });
45
- assert.equal(agentPolicy.triggerTokens, 90_000, 'agent default 10% headroom must remain unchanged');
46
- assert.equal(agentPolicy.bufferTokens, 10_000);
47
- assert.equal(agentPolicy.bufferRatio, 0.1);
48
-
49
- const configured = policyFor({ contextWindow: 100_000, compaction: { mainBufferPercent: 15 } });
50
- assert.equal(configured.triggerTokens, 85_000);
51
- assert.equal(configured.bufferTokens, 15_000);
52
- assert.equal(configured.bufferRatio, 0.15);
53
-
54
- const oldEnv = {
55
- tokens: process.env.MIXDOG_MAIN_COMPACT_BUFFER_TOKENS,
56
- percent: process.env.MIXDOG_MAIN_COMPACT_BUFFER_PERCENT,
57
- ratio: process.env.MIXDOG_MAIN_COMPACT_BUFFER_RATIO,
58
- };
59
- try {
60
- process.env.MIXDOG_MAIN_COMPACT_BUFFER_PERCENT = '20';
61
- const envConfigured = policyFor({ contextWindow: 100_000, compaction: {} });
62
- assert.equal(envConfigured.triggerTokens, 80_000);
63
- assert.equal(envConfigured.bufferTokens, 20_000);
64
- assert.equal(envConfigured.bufferRatio, 0.2);
65
-
66
- delete process.env.MIXDOG_MAIN_COMPACT_BUFFER_PERCENT;
67
- process.env.MIXDOG_MAIN_COMPACT_BUFFER_RATIO = '0.1';
68
- const envRatioConfigured = policyFor({ contextWindow: 100_000, compaction: {} });
69
- assert.equal(envRatioConfigured.bufferTokens, 10_000, 'env ratio must configure the main buffer');
70
-
71
- process.env.MIXDOG_MAIN_COMPACT_BUFFER_TOKENS = '10000';
72
- process.env.MIXDOG_MAIN_COMPACT_BUFFER_RATIO = '0.1';
73
- const envTokenConfigured = policyFor({ contextWindow: 100_000, compaction: {} });
74
- assert.equal(envTokenConfigured.bufferTokens, 10_000, 'env tokens must beat env percent/ratio');
75
- assert.equal(envTokenConfigured.triggerTokens, 90_000);
76
-
77
- const configBeatsEnv = policyFor({
78
- contextWindow: 100_000,
79
- compaction: { mainBufferRatio: 0.15 },
80
- });
81
- assert.equal(configBeatsEnv.bufferTokens, 15_000, 'config ratio must beat all env units');
82
-
83
- const configTokenWins = policyFor({
84
- contextWindow: 100_000,
85
- compaction: { mainBufferTokens: 12_000, mainBufferPercent: 15, mainBufferRatio: 0.1 },
86
- });
87
- assert.equal(configTokenWins.bufferTokens, 12_000, 'config tokens must beat config percent/ratio');
88
-
89
- const clamped = policyFor({
90
- contextWindow: 100_000,
91
- compaction: { mainBufferPercent: 250, mainBufferRatio: 0.1 },
92
- });
93
- assert.equal(clamped.bufferTokens, 25_000, 'buffer percent must cap at the configured 25% maximum');
94
- } finally {
95
- for (const [name, value] of Object.entries({
96
- MIXDOG_MAIN_COMPACT_BUFFER_TOKENS: oldEnv.tokens,
97
- MIXDOG_MAIN_COMPACT_BUFFER_PERCENT: oldEnv.percent,
98
- MIXDOG_MAIN_COMPACT_BUFFER_RATIO: oldEnv.ratio,
99
- })) {
100
- if (value === undefined) delete process.env[name];
101
- else process.env[name] = value;
102
- }
103
- }
104
- });
105
-
106
- test('fresh session compaction config preserves main buffer fields', () => {
107
- const config = initialCompactionConfig({
108
- mainBufferTokens: 12_000,
109
- mainBufferPercent: 15,
110
- mainBufferRatio: 0.2,
111
- mainBufferFraction: 0.1,
112
- }, { compactBoundaryTokens: 80_000 });
113
- assert.equal(config.mainBufferTokens, 12_000);
114
- assert.equal(config.mainBufferPercent, 15);
115
- assert.equal(config.mainBufferRatio, 0.2);
116
- assert.equal(config.mainBufferFraction, 0.1);
117
- assert.equal(config.boundaryTokens, 80_000);
118
- });
119
-
120
- test('small main boundary leaves a margin above the post-compact target', () => {
121
- const session = {
122
- contextWindow: 8_000,
123
- compaction: { reservedTokens: 2_000 },
124
- tools: [],
125
- messages: [],
126
- };
127
- const policy = policyFor(session);
128
- const target = compactTargetBudget(policy);
129
- assert.ok(policy.triggerTokens > target,
130
- `trigger ${policy.triggerTokens} must exceed post-compact target ${target}`);
131
- assert.equal(shouldCompactForSession(target - policy.reserveTokens, policy), false,
132
- 'reaching the post-compact target must not immediately re-trigger compaction');
133
- const { contextStatus } = createContextStatus({
134
- getSession: () => session,
135
- getRoute: () => ({ provider: 'openai', model: 'test-model' }),
136
- getCurrentCwd: () => '',
137
- getMode: () => 'default',
138
- });
139
- const statusCompact = contextStatus().compaction;
140
- assert.equal(statusCompact.triggerTokens, policy.triggerTokens);
141
- assert.equal(statusCompact.bufferTokens, policy.bufferTokens);
142
- assert.equal(statusCompact.bufferRatio, policy.bufferRatio);
143
- const manualPolicy = resolveSessionCompactionPolicy(session);
144
- assert.equal(manualPolicy.triggerTokens, policy.triggerTokens);
145
- assert.equal(compactTargetBudget(manualPolicy), target);
146
- });
147
-
148
- test('degenerate main budgets use a documented single-shot fallback', () => {
149
- const reserveAtTrigger = {
150
- contextWindow: 100_000,
151
- // Explicit sub-boundary limit fixes the trigger at 90k while reserve
152
- // remains below the context boundary.
153
- autoCompactTokenLimit: 90_000,
154
- compaction: { reservedTokens: 91_000 },
155
- tools: [],
156
- };
157
- const reserveAtTriggerPolicy = policyFor(reserveAtTrigger);
158
- assert.equal(reserveAtTriggerPolicy.singleShot, true,
159
- 'reserve at/above the actual trigger must be single-shot even below the boundary');
160
- assert.equal(compactTargetBudget(reserveAtTriggerPolicy), reserveAtTriggerPolicy.boundaryTokens,
161
- 'automatic single-shot keeps the legacy target budget');
162
- assert.equal(compactTargetBudget({ ...reserveAtTriggerPolicy, force: true }), reserveAtTriggerPolicy.boundaryTokens,
163
- 'forced manual compaction must retain the viable legacy target budget');
164
-
165
- const overReserved = {
166
- contextWindow: 8_000,
167
- compaction: { reservedTokens: 20_000 },
168
- tools: [],
169
- };
170
- const overReservedPolicy = policyFor(overReserved);
171
- assert.equal(overReservedPolicy.singleShot, true);
172
- assert.equal(compactTargetBudget(overReservedPolicy), 8_000,
173
- 'reserve at or above the boundary must retain the legacy bounded target');
174
- assert.equal(shouldCompactForSession(0, overReservedPolicy, { sessionRef: overReserved }), true);
175
- rememberCompactTelemetry(overReserved, overReservedPolicy, { stage: 'compacting' });
176
- assert.equal(shouldCompactForSession(0, overReservedPolicy, { sessionRef: overReserved }), false,
177
- 'single-shot fallback must suppress automatic repeats');
178
-
179
- const oneToken = { contextWindow: 1, compaction: {}, tools: [] };
180
- const oneTokenPolicy = policyFor(oneToken);
181
- assert.equal(oneTokenPolicy.reserveTokens, 0,
182
- 'an empty request has no synthetic fixed reserve');
183
- assert.equal(oneTokenPolicy.singleShot, false,
184
- 'the one-token boundary alone does not require a single-shot fallback');
185
- assert.equal(oneTokenPolicy.triggerTokens, 1);
186
- assert.equal(compactTargetBudget(oneTokenPolicy), 1);
187
-
188
- // The reactive retry is explicitly bounded by send-with-recovery's
189
- // contextOverflowRetryUsed flag: forceReactive may admit this one retry
190
- // after the consumed one-shot, but no second retry is scheduled.
191
- assert.equal(shouldCompactForSession(0, reserveAtTriggerPolicy, {
192
- sessionRef: { compaction: { singleShotConsumed: true } },
193
- forceReactive: true,
194
- }), true, 'the one bounded reactive retry remains available after one-shot consumption');
195
- });
196
-
197
- test('a one-shot overflow receives only one reactive compact retry', async () => {
198
- const overflow = new Error('context length exceeded');
199
- const ctx = {
200
- provider: { send: async () => { throw overflow; } },
201
- messages: [{ role: 'user', content: 'overflowing prompt' }],
202
- model: 'test-model',
203
- sendTools: [],
204
- tools: [],
205
- opts: {},
206
- sessionId: 'single-shot-reactive-test',
207
- sessionRef: {
208
- contextWindow: 100_000,
209
- autoCompactTokenLimit: 90_000,
210
- compaction: { reservedTokens: 91_000 },
211
- },
212
- nextIteration: 1,
213
- };
214
- assert.deepEqual(await sendWithRecovery({
215
- ...ctx,
216
- contextOverflowRetryUsed: false,
217
- }), { action: 'retry' });
218
- await assert.rejects(
219
- sendWithRecovery({ ...ctx, contextOverflowRetryUsed: true }),
220
- err => err?.code === 'AGENT_CONTEXT_OVERFLOW',
221
- 'a second overflow after the reactive compact must surface instead of retrying again',
222
- );
223
- });
224
-
225
- test('image payload bytes do not inflate live gauge or fallback compaction estimates', () => {
226
- const text = 'Please describe the attached image.';
227
- const imageData = 'A'.repeat(400_000);
228
- const imagePart = { type: 'image', data: imageData, mimeType: 'image/png' };
229
- const messages = [{
230
- role: 'user',
231
- content: [{ type: 'text', text }, imagePart],
232
- }];
233
- const plainTextEstimate = estimateTokens(text) + 4;
234
- const fallbackEstimate = estimateMessagesTokens(messages);
235
- const summaryEstimate = summarizeContextMessages(messages).estimatedTokens;
236
-
237
- assert.equal(estimateMessagesTokens([{ role: 'user', content: text }]), plainTextEstimate,
238
- 'ordinary string estimates must remain unchanged');
239
- assert.equal(fallbackEstimate, plainTextEstimate + IMAGE_VISUAL_TOKEN_ALLOWANCE,
240
- 'fallback compaction estimate must count text plus a visual image allowance');
241
- const largerPayloadEstimate = estimateMessagesTokens([{
242
- role: 'user',
243
- content: [{ type: 'text', text }, { ...imagePart, data: imageData.repeat(2) }],
244
- }]);
245
- assert.equal(largerPayloadEstimate, fallbackEstimate,
246
- 'raw image byte length must not affect the visual allowance');
247
- assert.equal(summaryEstimate, fallbackEstimate,
248
- 'display and fallback compaction must share the image-aware message estimate');
249
-
250
- const session = {
251
- id: 'image-context-test',
252
- provider: 'openai',
253
- contextWindow: 100_000,
254
- rawContextWindow: 100_000,
255
- compactBoundaryTokens: 100_000,
256
- messages: [],
257
- liveTurnMessages: messages,
258
- tools: [],
259
- compaction: {},
260
- };
261
- const { contextStatus } = createContextStatus({
262
- getSession: () => session,
263
- getRoute: () => ({ provider: 'openai', model: 'test-model' }),
264
- getCurrentCwd: () => '',
265
- getMode: () => 'default',
266
- });
267
- const status = contextStatus();
268
- assert.ok(status.usedTokens < status.compaction.triggerTokens,
269
- `image-aware live gauge must remain below compaction threshold, got ${status.usedTokens}`);
270
- assert.ok(status.usedTokens < status.contextWindow,
271
- `raw base64 must not pin the live gauge at 100%, got ${status.usedTokens}/${status.contextWindow}`);
272
- assert.equal(status.compaction.bufferRatio, 0.05,
273
- 'context status buffer ratio must match the shared compaction policy');
274
-
275
- recordProviderContextBaseline(session, messages, { inputTokens: 70_000, outputTokens: 0 });
276
- const policy = { ...policyFor(session), reserveTokens: 0 };
277
- assert.equal(
278
- shouldCompactForSession(fallbackEstimate, policy, { messages, sessionRef: session }),
279
- false,
280
- 'provider-backed pressure below threshold must remain below threshold',
281
- );
282
- assert.equal(imagePart.data, imageData,
283
- 'estimating live context must not sanitize or remove image content');
284
- });
285
-
286
- test('token estimates match the real o200k BPE tokenizer at the default multiplier', () => {
287
- const requireForTest = createRequire(import.meta.url);
288
- const { Tiktoken } = requireForTest('tiktoken/lite');
289
- const o200k = requireForTest('tiktoken/encoders/o200k_base.json');
290
- const enc = new Tiktoken(o200k.bpe_ranks, o200k.special_tokens, o200k.pat_str);
291
- try {
292
- for (const text of [
293
- 'A1b2C3d4E5f6G7h8'.repeat(100),
294
- '%7B%22path%22%3A%22very%2Flong%2Fencoded%2Fvalue%22%7D'.repeat(40),
295
- JSON.stringify({ rows: Array.from({ length: 100 }, (_, i) => ({ id: i, value: `item_${i}_abcdef` })) }),
296
- Array.from({ length: 200 }, (_, i) => `{"i":${i}}`).join('\n'),
297
- 'plain english prose with ordinary words that merge well. '.repeat(50),
298
- '한국어 컨텍스트 추정 정확도 검증 문장입니다. '.repeat(30),
299
- '😀🚀🔥✅'.repeat(50),
300
- ]) {
301
- assert.equal(estimateTokens(text), enc.encode(text, undefined, []).length,
302
- 'estimateTokens must equal the real o200k token count');
303
- }
304
- // Repeat call exercises the hash-keyed LRU for long strings — the
305
- // cached count must be identical to the fresh encode.
306
- const longText = 'cached long payload '.repeat(200);
307
- assert.equal(estimateTokens(longText), estimateTokens(longText),
308
- 'cached long-string counts must be stable');
309
- } finally {
310
- enc.free();
311
- }
312
- });
313
-
314
- test('assistantBlocks and reasoningItems count provider-visible data but not image bytes', () => {
315
- const base = { role: 'assistant', content: '' };
316
- const assistantBlocks = [
317
- { type: 'text', text: 'native assistant replay' },
318
- { type: 'tool_use', id: 'call_native', name: 'read', input: '{"path":"x"}' },
319
- { type: 'image', data: 'Z'.repeat(300_000), mimeType: 'image/png' },
320
- ];
321
- const reasoningItems = [{ type: 'reasoning', encrypted_content: 'enc_'.repeat(2_000) }];
322
- const estimated = estimateMessagesTokens([{ ...base, assistantBlocks, reasoningItems }]);
323
- const noNativeReplay = estimateMessagesTokens([base]);
324
- assert.ok(estimated > noNativeReplay + IMAGE_VISUAL_TOKEN_ALLOWANCE,
325
- 'native assistant blocks and opaque reasoning must contribute tokens');
326
- assert.equal(
327
- estimateMessagesTokens([{ ...base, assistantBlocks: assistantBlocks.map(block => (
328
- block.type === 'image' ? { ...block, data: 'Z'.repeat(600_000) } : block
329
- )), reasoningItems }]),
330
- estimated,
331
- 'native replay image bytes must not be tokenized',
332
- );
333
- });
334
-
335
- test('image allowance handles identity, detail, dimensions, and multiple accepted forms', () => {
336
- const low = { type: 'image_url', image_url: { url: 'https://example.test/a.png', detail: 'low' } };
337
- const tiled = {
338
- type: 'input_image',
339
- image_url: { url: 'https://example.test/b.png', detail: 'high' },
340
- dimensions: { width: 2_048, height: 1_024 },
341
- };
342
- const inline = { inlineData: { data: 'A'.repeat(1_000), mimeType: 'image/png' }, width: 512, height: 512 };
343
- const lowEstimate = estimateMessagesTokens([{ role: 'user', content: [low] }]);
344
- const tiledEstimate = estimateMessagesTokens([{ role: 'user', content: [tiled] }]);
345
- const multiEstimate = estimateMessagesTokens([{ role: 'user', content: [low, tiled, inline] }]);
346
- assert.ok(tiledEstimate > lowEstimate, 'high-detail multi-tile image must reserve more than low detail');
347
- assert.ok(lowEstimate >= IMAGE_VISUAL_TOKEN_ALLOWANCE + 4,
348
- 'unverified low-detail metadata must not reduce the conservative image fallback');
349
- const unverifiedSmallDimensions = estimateMessagesTokens([{
350
- role: 'user',
351
- content: [{ type: 'image', data: 'A'.repeat(1_000), width: 1, height: 1, detail: 'low' }],
352
- }]);
353
- assert.ok(unverifiedSmallDimensions >= IMAGE_VISUAL_TOKEN_ALLOWANCE + 4,
354
- 'unverified tiny dimensions must not reduce the conservative image fallback');
355
- assert.ok(multiEstimate > tiledEstimate + lowEstimate, 'every accepted image form must add visual allowance');
356
-
357
- const session = { provider: 'openai', model: 'm', tools: [], contextWindow: 100_000, compaction: {} };
358
- const messages = [{ role: 'user', content: [{ type: 'image', data: 'A'.repeat(1_000), mimeType: 'image/png' }] }];
359
- const policy = policyFor(session);
360
- recordProviderContextBaseline(session, messages, { inputTokens: 80_000 }, { sendTools: [] });
361
- messages[0].content[0].data = 'B'.repeat(1_000);
362
- assert.equal(
363
- resolveCompactionPressureTokens(estimateMessagesTokens(messages), policy, { messages, sessionRef: session }),
364
- estimateMessagesTokens(messages) + policy.reserveTokens,
365
- 'same-size image replacement must invalidate the measured prefix',
366
- );
367
- });
368
-
369
- test('tool reserve and status cache detect nested schema mutation', () => {
370
- const tools = [{ name: 'read', parameters: { type: 'object', properties: { path: { type: 'string' } } } }];
371
- const beforeSchema = estimateToolSchemaTokens(tools);
372
- const beforeReserve = estimateRequestReserveTokens(tools);
373
- tools[0].parameters.properties.path.description = 'dense_nested_schema_description_'.repeat(200);
374
- assert.ok(estimateToolSchemaTokens(tools) > beforeSchema);
375
- assert.ok(estimateRequestReserveTokens(tools) > beforeReserve);
376
-
377
- const session = { id: 'tool-cache', contextWindow: 100_000, messages: [{ role: 'user', content: 'x' }], tools, compaction: {} };
378
- const { contextStatus } = createContextStatus({
379
- getSession: () => session,
380
- getRoute: () => ({ provider: 'openai', model: 'm' }),
381
- getCurrentCwd: () => '',
382
- getMode: () => 'default',
383
- });
384
- const statusBefore = contextStatus();
385
- tools[0].parameters.properties.path.description += 'more_'.repeat(500);
386
- const statusAfter = contextStatus();
387
- assert.notEqual(statusAfter, statusBefore);
388
- assert.ok(statusAfter.request.toolSchemaTokens > statusBefore.request.toolSchemaTokens);
389
- });
390
-
391
- test('native replay fingerprint detects encrypted reasoning and provider metadata mutation', () => {
392
- const message = {
393
- role: 'assistant',
394
- content: '',
395
- reasoningItems: [{ type: 'reasoning', encrypted_content: 'short' }],
396
- assistantBlocks: [{ type: 'tool_use', id: 'c1', name: 'read', input: { path: 'a' }, cache_control: { type: 'ephemeral' } }],
397
- providerMetadata: { gemini: { thoughtParts: [{ text: 'short', thoughtSignature: 'sig' }] } },
398
- };
399
- const messages = [message];
400
- const first = summarizeContextMessages(messages).estimatedTokens;
401
- message.reasoningItems[0].encrypted_content = 'encrypted_'.repeat(1_000);
402
- const second = summarizeContextMessages(messages).estimatedTokens;
403
- assert.ok(second > first, 'in-place encrypted_content mutation must invalidate the message memo');
404
- message.assistantBlocks[0].cache_control.mode = 'metadata_'.repeat(1_000);
405
- const third = summarizeContextMessages(messages).estimatedTokens;
406
- assert.ok(third > second, 'in-place assistant-block metadata mutation must invalidate the message memo');
407
- message.providerMetadata.gemini.thoughtParts[0].text = 'gemini_private_thought_'.repeat(1_000);
408
- const fourth = summarizeContextMessages(messages).estimatedTokens;
409
- assert.ok(fourth > third, 'in-place Gemini replay metadata mutation must invalidate the message memo');
410
- });
411
-
412
- test('recall compaction preserves provider-scoped Gemini replay metadata on the live tail', () => {
413
- const providerMetadata = {
414
- gemini: {
415
- textParts: [{ text: 'signed answer', thoughtSignature: 'sig-tail' }],
416
- },
417
- };
418
- const result = recallFastTrackCompactMessages([
419
- { role: 'user', content: `old request ${'x'.repeat(20_000)}` },
420
- { role: 'assistant', content: `old answer ${'y'.repeat(20_000)}` },
421
- { role: 'user', content: 'recent request' },
422
- { role: 'assistant', content: 'signed answer', providerMetadata },
423
- ], 8_000, {
424
- force: true,
425
- recallText: 'Older history summary.',
426
- recallTailMaxUsers: 1,
427
- recallTailTokenCap: 4_000,
428
- });
429
- const tail = result.messages.find((message) => message?.content === 'signed answer');
430
- assert.deepEqual(tail?.providerMetadata, providerMetadata);
431
- });
432
-
433
- test('recall tail cap drops oversized replay metadata instead of raising the budget', () => {
434
- const result = recallFastTrackCompactMessages([
435
- { role: 'user', content: `old request ${'x'.repeat(20_000)}` },
436
- { role: 'assistant', content: `old answer ${'y'.repeat(20_000)}` },
437
- { role: 'user', content: 'recent request' },
438
- {
439
- role: 'assistant',
440
- content: 'recent answer',
441
- providerMetadata: {
442
- gemini: {
443
- thoughtParts: [{
444
- text: 'private_'.repeat(20_000),
445
- thoughtSignature: 'sig',
446
- }],
447
- },
448
- },
449
- },
450
- ], 8_000, {
451
- force: true,
452
- recallText: 'Older history summary.',
453
- recallTailMaxUsers: 1,
454
- recallTailTokenCap: 200,
455
- });
456
- assert.ok(result.diagnostics.tailTokens <= 200, `tail tokens ${result.diagnostics.tailTokens}`);
457
- const recent = result.messages.find((message) => message?.content === 'recent answer');
458
- assert.equal(recent?.providerMetadata, undefined);
459
- });
460
-
461
- test('provider baseline pressure includes only the configured extra reserve', () => {
462
- const session = { provider: 'openai', model: 'm', tools: [], contextWindow: 100_000, compaction: {} };
463
- const messages = [{ role: 'user', content: 'baseline' }];
464
- recordProviderContextBaseline(session, messages, { inputTokens: 80_000, outputTokens: 0 });
465
- const policy = { ...policyFor(session), reserveTokens: 7_512, requestReserveTokens: 512, configuredReserveTokens: 7_000 };
466
- assert.equal(resolveCompactionPressureTokens(1, policy, { messages, sessionRef: session }), 87_000);
467
- });
468
-
469
- test('context status uses the automatic compaction pressure numerator and trigger', () => {
470
- const session = {
471
- id: 'status-pressure',
472
- provider: 'openai',
473
- model: 'm',
474
- tools: [],
475
- contextWindow: 100_000,
476
- messages: [{ role: 'user', content: 'small local estimate' }],
477
- compaction: {},
478
- };
479
- recordProviderContextBaseline(session, session.messages, {
480
- inputTokens: 80_000,
481
- outputTokens: 2_000,
482
- });
483
- const policy = policyFor(session);
484
- const expectedPressure = resolveCompactionPressureTokens(
485
- estimateMessagesTokens(session.messages),
486
- policy,
487
- { messages: session.messages, sessionRef: session },
488
- );
489
- const { contextStatus } = createContextStatus({
490
- getSession: () => session,
491
- getRoute: () => ({ provider: 'openai', model: 'm' }),
492
- getCurrentCwd: () => '',
493
- getMode: () => 'default',
494
- });
495
-
496
- const status = contextStatus();
497
- assert.equal(status.usedTokens, expectedPressure);
498
- assert.equal(status.currentEstimatedTokens, expectedPressure);
499
- assert.equal(status.compaction.triggerTokens, policy.triggerTokens);
500
- assert.equal(
501
- shouldCompactForSession(estimateMessagesTokens(session.messages), policy, {
502
- messages: session.messages,
503
- sessionRef: session,
504
- }),
505
- status.usedTokens >= status.compaction.triggerTokens,
506
- );
507
- });
508
-
509
- test('provider baselines fingerprint actual sendTools and reject provider, model, tool-schema, and prefix changes', () => {
510
- const make = () => ({
511
- provider: 'openai',
512
- model: 'm1',
513
- tools: [{ name: 'read', parameters: { type: 'object' } }],
514
- contextWindow: 100_000,
515
- compaction: {},
516
- });
517
- const fallbackForMutation = (mutate) => {
518
- const session = make();
519
- const messages = [{ role: 'user', content: 'original prefix' }];
520
- recordProviderContextBaseline(session, messages, { inputTokens: 80_000, outputTokens: 0 }, { sendTools: session.tools });
521
- mutate(session, messages);
522
- const policy = { ...resolveWorkerCompactPolicy(session, session.tools), reserveTokens: 0 };
523
- return {
524
- pressure: resolveCompactionPressureTokens(estimateMessagesTokens(messages), policy, { messages, sessionRef: session }),
525
- // The estimate fallback includes provider billing calibration, so
526
- // compare against the same pressure computation without a baseline.
527
- fallback: resolveCompactionPressureTokens(estimateMessagesTokens(messages), policy, { messages, sessionRef: null }),
528
- };
529
- };
530
- for (const mutate of [
531
- session => { session.provider = 'anthropic'; },
532
- session => { session.model = 'm2'; },
533
- session => { session.tools[0].parameters.properties = { path: { type: 'string' } }; },
534
- (_session, messages) => { messages[0].content = 'mutated earlier prefix'; },
535
- ]) {
536
- const result = fallbackForMutation(mutate);
537
- assert.equal(result.pressure, result.fallback);
538
- }
539
- const session = make();
540
- const messages = [{ role: 'user', content: 'forced tool request' }];
541
- const actualSendTools = [session.tools[0]];
542
- const matchingPolicy = resolveWorkerCompactPolicy(session, actualSendTools);
543
- recordProviderContextBaseline(session, messages, { inputTokens: 80_000 }, { sendTools: actualSendTools });
544
- session.tools = [{ name: 'different-session-tool', parameters: { type: 'object' } }];
545
- assert.equal(
546
- resolveCompactionPressureTokens(1, matchingPolicy, { messages, sessionRef: session }),
547
- 80_000,
548
- 'baseline must remain aligned to actual sendTools rather than mutable sessionRef.tools',
549
- );
550
- const changedSendPolicy = resolveWorkerCompactPolicy(session, session.tools);
551
- assert.notEqual(
552
- resolveCompactionPressureTokens(1, changedSendPolicy, { messages, sessionRef: session }),
553
- 80_000,
554
- 'a different next-send schema must invalidate the baseline',
555
- );
556
- });
557
-
558
- test('context status cache notices mutation of an earlier message', () => {
559
- const session = {
560
- id: 'status-mutation',
561
- contextWindow: 100_000,
562
- messages: [{ role: 'user', content: 'short' }, { role: 'assistant', content: 'tail' }],
563
- tools: [],
564
- compaction: {},
565
- };
566
- const { contextStatus } = createContextStatus({
567
- getSession: () => session,
568
- getRoute: () => ({ provider: 'openai', model: 'm' }),
569
- getCurrentCwd: () => '',
570
- getMode: () => 'default',
571
- });
572
- const before = contextStatus();
573
- session.messages[0].content = 'dense_earlier_message_'.repeat(1_000);
574
- const after = contextStatus();
575
- assert.notEqual(after, before);
576
- assert.ok(after.usedTokens > before.usedTokens);
577
- });
578
-
579
- test('provider callback usage counts assistant output once and estimates only later tool results', () => {
580
- const session = { provider: 'anthropic', contextWindow: 100_000, compaction: {} };
581
- const policy = { ...policyFor(session), reserveTokens: 0 };
582
- const messages = [{ role: 'user', content: 'production-shaped tool request' }];
583
- const onProviderUsage = d => recordProviderContextBaseline(session, messages, {
584
- inputTokens: d.deltaInput,
585
- outputTokens: d.deltaOutput,
586
- promptTokens: d.deltaPrompt,
587
- cachedTokens: d.deltaCachedRead,
588
- cacheWriteTokens: d.deltaCacheWrite,
589
- }, { boundary: 'request' });
590
- assert.equal(onProviderUsage({
591
- source: 'provider_send',
592
- deltaInput: 5_000,
593
- deltaOutput: 800,
594
- deltaPrompt: 0,
595
- deltaCachedRead: 88_000,
596
- deltaCacheWrite: 1_000,
597
- }), true);
598
- messages.push({
599
- role: 'assistant',
600
- content: 'Calling the requested tool.',
601
- reasoningItems: [{ type: 'reasoning', encrypted_content: 'opaque-provider-reasoning' }],
602
- toolCalls: [{ id: 'call_1', name: 'read', arguments: '{"path":"large.txt"}' }],
603
- });
604
- const laterToolResult = { role: 'tool', toolCallId: 'call_1', content: 'x'.repeat(4_000) };
605
- messages.push(laterToolResult);
606
-
607
- const wholeEstimate = estimateMessagesTokens(messages);
608
- assert.ok(wholeEstimate < policy.triggerTokens, 'fixture must reproduce local estimator undercount');
609
- const pressure = compactionTelemetryPressureTokens(wholeEstimate, policy, { messages, sessionRef: session });
610
- const expectedPressure = 94_800
611
- + Math.round(estimateMessagesTokens([laterToolResult]) * providerTokenCalibration('anthropic'));
612
- assert.equal(pressure, expectedPressure, 'assistant output/reasoning must stay in actual usage, not be estimated again');
613
- assert.ok(pressure >= 95_000, `actual usage plus later tool growth should cross trigger, got ${pressure}`);
614
- assert.equal(shouldCompactForSession(wholeEstimate, policy, {
615
- messages,
616
- sessionRef: session,
617
- pressureTokens: pressure,
618
- }), true);
619
- });
620
-
621
- test('thinking-only continuation without assistant replay excludes provider output and estimates the nudge', () => {
622
- const session = { provider: 'anthropic', contextWindow: 100_000, compaction: {} };
623
- const policy = { ...policyFor(session), reserveTokens: 0 };
624
- const messages = [{ role: 'user', content: 'request that returns thinking but no replayable assistant message' }];
625
- recordProviderContextBaseline(session, messages, {
626
- inputTokens: 5_000,
627
- outputTokens: 2_000,
628
- cachedTokens: 68_000,
629
- cacheWriteTokens: 1_000,
630
- }, { boundary: 'request' });
631
- const nudge = {
632
- role: 'user',
633
- content: '[mixdog-runtime] Previous response was empty. Continue with a final answer or tool call.',
634
- };
635
- messages.push(nudge);
636
-
637
- const wholeEstimate = estimateMessagesTokens(messages);
638
- const pressure = compactionTelemetryPressureTokens(wholeEstimate, policy, { messages, sessionRef: session });
639
- const expectedPressure = 74_000
640
- + Math.round(estimateMessagesTokens([nudge]) * providerTokenCalibration('anthropic'));
641
- assert.equal(pressure, expectedPressure, 'unreplayed output must be removed while the later nudge is estimated');
642
- assert.equal(shouldCompactForSession(wholeEstimate, policy, {
643
- messages,
644
- sessionRef: session,
645
- pressureTokens: pressure,
646
- }), false, 'unreplayed thinking output must not cause an early compact');
647
- });
648
-
649
- test('OpenAI OAuth WS warmup remains billed but does not double the main context footprint', async () => {
650
- const main = {
651
- inputTokens: 167_635,
652
- outputTokens: 611,
653
- cachedTokens: 160_000,
654
- promptTokens: 167_635,
655
- raw: {},
656
- };
657
- const usage = _combineUsageWithWarmup(main, main, { separateMainContext: true });
658
- assert.equal(usage.inputTokens, 335_270, 'billing usage must retain warmup plus main input');
659
- const { initProviders, getProvider } = await import('../src/runtime/agent/orchestrator/providers/registry.mjs');
660
- const { createSession, askSession, getSession, closeSession } = await import('../src/runtime/agent/orchestrator/session/manager.mjs');
661
- await initProviders({ 'openai-oauth': { enabled: true } });
662
- const provider = getProvider('openai-oauth');
663
- const originalSend = provider.send;
664
- const compactEvents = [];
665
- let regressionSessionId = '';
666
- provider.send = async () => ({ content: 'done', usage });
667
- try {
668
- const session = createSession({
669
- provider: 'openai-oauth',
670
- model: 'warmup-context-regression',
671
- owner: 'test',
672
- tools: [],
673
- cwd: process.cwd(),
674
- skipAgentRules: true,
675
- skipSkills: true,
676
- compaction: { auto: true },
677
- });
678
- regressionSessionId = session.id;
679
- session.contextWindow = 272_000;
680
- session.rawContextWindow = 272_000;
681
- await askSession(session.id, 'large OAuth WebSocket request', null, null, process.cwd(), null, {
682
- onCompactEvent: event => compactEvents.push(event),
683
- });
684
-
685
- const persisted = getSession(session.id);
686
- const policy = { ...policyFor(persisted), reserveTokens: 0 };
687
- const messageTokens = estimateMessagesTokens(persisted.messages);
688
- const pressure = resolveCompactionPressureTokens(messageTokens, policy, {
689
- messages: persisted.messages,
690
- sessionRef: persisted,
691
- });
692
- assert.equal(persisted.totalInputTokens, 335_270, 'incremental lifetime totals must retain warmup billing');
693
- assert.equal(persisted.lastContextTokens, 167_635, 'incremental context snapshot must exclude warmup');
694
- assert.equal(persisted.contextPressureBaselineTokens, 168_246, 'stored baseline must use main request usage');
695
- assert.equal(pressure, 168_246, 'resolved pressure must use the stored baseline without transcript growth');
696
- assert.equal(policy.triggerTokens, 258_400, 'fixture trigger must match the reported premature-compaction threshold');
697
- assert.equal(shouldCompactForSession(messageTokens, policy, {
698
- messages: persisted.messages,
699
- sessionRef: persisted,
700
- pressureTokens: pressure,
701
- }), false, 'main-request pressure must not trigger compaction');
702
- assert.equal(compactEvents.length, 0, 'warmup must not cause an auto-compaction');
703
- } finally {
704
- if (regressionSessionId) {
705
- closeSession(regressionSessionId, 'warmup-context-regression-cleanup', { tombstone: true });
706
- }
707
- provider.send = originalSend;
708
- }
709
- });
710
-
711
- test('warmup-only OpenAI OAuth WS usage stays billable but invalidates context usage', () => {
712
- const warmup = { inputTokens: 167_635, outputTokens: 611, cachedTokens: 160_000, promptTokens: 167_635 };
713
- const usage = _combineUsageWithWarmup(null, warmup, { separateMainContext: true });
714
- const session = { provider: 'openai-oauth', contextPressureBaselineTokens: 99_000 };
715
- assert.equal(usage.mainUsageAvailable, false);
716
- assert.equal(recordProviderContextBaseline(session, [], usage), false);
717
- assert.equal(session.contextPressureBaselineTokens, null, 'warmup-only usage must not remain a provider baseline');
718
- applyAskTerminalUsageTotals(session, { usage, lastTurnUsage: usage });
719
- assert.equal(session.totalInputTokens, 167_635, 'warmup-only usage remains billable');
720
- assert.equal(session.lastContextTokens, null, 'warmup-only usage has no main-request context snapshot');
721
- });
722
-
723
- test('xAI warmup remains billable while main usage alone drives context pressure', () => {
724
- const actual = { inputTokens: 20, outputTokens: 2, cachedTokens: 5, promptTokens: 20, raw: { provider: 'xai', cost_in_usd_ticks: 200 } };
725
- const warmup = { inputTokens: 10, outputTokens: 1, cachedTokens: 3, promptTokens: 10, raw: { phase: 'warmup', cost_in_usd_ticks: 100 } };
726
- const usage = _combineUsageWithWarmup(actual, warmup, { separateMainContext: true });
727
- assert.deepEqual(usage, {
728
- ...actual,
729
- inputTokens: 30,
730
- outputTokens: 3,
731
- cachedTokens: 8,
732
- promptTokens: 30,
733
- warmupInputTokens: 10,
734
- warmupCachedTokens: 3,
735
- warmupOutputTokens: 1,
736
- warmupPromptTokens: 10,
737
- warmupCacheWriteTokens: 0,
738
- raw: {
739
- provider: 'xai',
740
- cost_in_usd_ticks: 300,
741
- warmup_usage: { phase: 'warmup', cost_in_usd_ticks: 100 },
742
- },
743
- mainInputTokens: 20,
744
- mainOutputTokens: 2,
745
- mainCachedTokens: 5,
746
- mainPromptTokens: 20,
747
- mainCacheWriteTokens: 0,
748
- mainUsageAvailable: true,
749
- });
750
- const session = { provider: 'xai', contextPressureBaselineTokens: null };
751
- assert.equal(recordProviderContextBaseline(session, [], usage), true);
752
- applyAskTerminalUsageTotals(session, { usage, lastTurnUsage: usage });
753
- assert.equal(session.totalInputTokens, 30, 'lifetime total includes xAI warmup');
754
- assert.equal(session.lastContextTokens, 20, 'context snapshot excludes xAI warmup');
755
- });
756
-
757
- test('successful compact invalidates stale usage and cannot immediately compact again', () => {
758
- const session = { provider: 'openai', contextWindow: 100_000, compaction: {} };
759
- const policy = { ...policyFor(session), reserveTokens: 0 };
760
- const before = [{ role: 'user', content: 'old context' }];
761
- recordProviderContextBaseline(session, before, { inputTokens: 99_000, outputTokens: 500 });
762
- assert.equal(shouldCompactForSession(estimateMessagesTokens(before), policy, {
763
- messages: before,
764
- sessionRef: session,
765
- }), true);
766
-
767
- rememberCompactTelemetry(session, policy, {
768
- compactChanged: true,
769
- beforeTokens: 99_500,
770
- afterTokens: 20,
771
- pressureTokens: 99_500,
772
- });
773
- const compacted = [{ role: 'user', content: 'short summary' }];
774
- const compactedEstimate = estimateMessagesTokens(compacted);
775
- assert.equal(session.contextPressureBaselineTokens, null);
776
- assert.equal(session.lastContextTokensStaleAfterCompact, true);
777
- assert.equal(shouldCompactForSession(compactedEstimate, policy, {
778
- messages: compacted,
779
- sessionRef: session,
780
- }), false, 'stale pre-compact usage must not trigger a consecutive compact');
781
-
782
- recordProviderContextBaseline(session, compacted, { inputTokens: 10_000, outputTokens: 100 });
783
- assert.equal(session.lastContextTokensStaleAfterCompact, false);
784
- assert.equal(shouldCompactForSession(compactedEstimate, policy, {
785
- messages: compacted,
786
- sessionRef: session,
787
- }), false, 'fresh post-compact usage may be reused safely');
788
- });