jihuayu measured a 45 MiB chat going through 0.1.41's fetch: each step
(withSystem, fitted, normalizeToolChoice, attend, the model, systemKey)
parsed the whole body again, 6 parses a request, and normalizeToolChoice
wrote it out whole even for an unchanged "auto". Bun's RSS reached 618-751
MiB for 4 serial requests where passing the body through took 270.
prepared parses a request once. Each step makes its own change to that one
object, in the same order (systemOn, fitTools, toolChoiceOn; unsignedOn
for Messages). attend, the model and the system key read the same object,
and a refused system prompt moves on it (systemAsUserOn). The body is
written out once, only when a step changed it. The parsed chat is let go
before the request is sent. A body a step throws on goes through the steps
one by one, as before. The string-level helpers stay as wrappers.
What was run, on this tree:
- mote, the reporter's benchmark (no network, fetch stubbed, 4 x 45.3 MiB,
peak RSS sampled every 5ms): 0.1.41 7 parses/request, 1087.5 MiB parsed,
peak RSS 1096 / 979 MiB. This change: 2 parses/request (the request and
the stub's SSE reply), 181.3 MiB parsed, peak 682 / 680 MiB. The bodies
sent have the same SHA-256 in both.
- HOME=$(mktemp -d) bun test packages/workbuddy on mote: 189 pass, 0 fail.
bun scripts/check.mjs workbuddy: ok.
- oneparse.test.mjs (new): 17 chat shapes, invalid JSON and bytes come out
the same as the steps one by one made them, with the same tool names; an
unchanged chat goes byte for byte; the loader parses a 2 MiB chat once.
Broken by hand: every request sent through the step-by-step fallback,
the loader test FAILs (5 parses, want 1). An unchanged "auto" counted as
a change, the byte-for-byte test FAILs.
- Real account (WorkBuddy AI, free-only on, sandbox HOME, this Mac):
deepseek-v4.1-flash, a 373-byte chat and a 205,595-byte chat with a
developer message, max_completion_tokens and a dotted tool name, through
0.1.41 and this change: 200 "OK" on all four; no sign-in refreshed.
npm has 0.1.41, so 0.1.42 is free.
Reported-by: jihuayu