f2eb56c6bbde1300dddc402861b59cd4e45e0215
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4ca64c21b2 |
gateway: a conversation's tail is made in a slice of its size, so -race counts one copy (#4004)
TestTailOfReadsInPlace was red in both Race jobs at
|
||
|
|
56d26f0bba |
gateway: a conversation's list is looked at where it sits in the body, not copied (#4004)
gjson.GetBytes copies the value it finds. For "input" or "messages" that is the conversation, so tailOf, the effort, deferred-tools and refs-only checks, Cline's images, Codex's images, the compaction lookups and the title digest each copied a 44 MiB Codex turn once per request to look at it. getIn reads it in place (gjson.Get over the body's bytes). None of the nine sites changes the body while a result is held, and none keeps a string past the request: Codex's image jobs read url.Str and write a new buffer, the compaction encs are lookups, the title keeps a digest. Together with the masked-record copy, a 44 MiB Responses turn sent on as Chat allocates ~89 MB less (1,068 to 1,005 MB over the turn) and runs fewer GCs. Peak live heap is unchanged (282 MB at GOGC=10 with gctrace, before and after): the body, the parsed request and the outgoing Chat body are what is held at the peak. This is less allocation and GC CPU, not a lower RSS peak. TestTailOfReadsInPlace: a 4 MiB conversation's last 64 items come back right, allocating under the tail plus a quarter of the body. Red with GetBytes put back (5,480,048 bytes for a 1.3 MB tail of a 4.1 MB body). Run (mote-run at aa8ded04e, both commits, on |
||
|
|
de281760e2 |
gateway: a conversation going round one tool call with the same result is answered by magpie after 8 turns (audie on Discord)
audie on Discord: on 10-21 Codex Desktop, routed to WorkBuddy's deepseek-v4-pro, ran the same read-code tool call 308 times between 13:24 and 13:52 (316 requests, 212.65 credits). That evening it did it 340 more times between 19:58 and 20:22 (343 requests, 324.52 credits). loopGuard only catches a loop inside one streamed reply. Here every reply was a short, valid call. The loop runs across turns, so it shows in the request's own history. stoppedToolLoop (internal/gateway/tool_loop.go) runs in serveAgent after the session is recorded and before hooks, middleware and routing. It also runs in the Codex backend's passthrough on Codex's own ChatGPT sign-in. It needs the last 8 turns to be the same exchange: - the same calls: name plus arguments, key order ignored, call ids ignored; - answered with the same results: text, error flag and images, with Codex's "Wall time", "Chunk ID" and "duration_seconds" taken out (runNoise); - with nothing else said on the user's side. When it finds one, it answers the turn in the agent's own protocol, streamed or whole (Responses, Chat, Anthropic, Gemini through relayStatus), with a notice that names the call. Nothing goes upstream, and no prompt, base_instructions or identity text sent to a vendor changes. A different result, or any word from the user, starts the count again. The notice is a turn without calls, so the user's next message carries on. The check keeps no state, so it is per conversation, and a retried request doesn't count twice. The turn is recorded the way Codex's title turns are. sentNowhere's body becomes answeredHere (from-protocol aware): the Routing trace shows "Tool loop stopped", and a usage row has provider magpie, rejected, the conversation's session and native session, and an error starting "tool loop:". So Usage and Sessions both show why. Cost: a body with fewer than 8 tool results isn't parsed (a bytes.Count). For a longer one, only the newest 64 items are parsed, found with gjson (tailOf). For a 1.5MB Codex turn that is 1.1ms and 2.5MB, against 30ms and 20MB for a full parse (BenchmarkToolLoopCheck). There is no new setting. Settings › Models › Replies › Stop looping replies (noLoopGuard, on by default) turns this off together with the reply guard, and the notice says so. The GUI sub-text is unchanged. docs/subsystems/gateway-routing.md has a bullet on it. Run at this commit (vet/build/race at parent bf2e067ef; the full suite after the rebase onto |