A session file was written as if it were a chat: role and text, nothing
else. Reading it back kept "user" and "assistant" and dropped everything
else - and nearly every line of an agent transcript is an observation.
Measured on three real sessions: 21 of 1507 messages came back, 8 of 1356,
3 of 317. --resume then sent 1% of the conversation and the model had no
idea what it was continuing.
Three writers had to change with the loader:
- A turn that asked for tools wrote no line at all (agent.c only wrote
when ncalls == 0). It now goes out with its tool_calls, and each result
with the name of its tool and its call id; a provider rejects a tool
message without them.
- {"role":"user","text":""} came from the steer path and showed the model
a blank human turn it answered. sp_session_append_rec writes nothing
when text and calls are both empty.
- A record from the old format has no name and no call id. It is paired
with the next unanswered call of its pending assistant turn, or given a
synthetic one (recovered-N). Dropping it is what emptied every resume;
keeping it unpaired is what a provider answers with 400.
The same pass gives the core its own compactor (compact.c): a thread digest
- one line per dropped message, OPERATOR: 800 chars, assistant: 300, tool
result 160 - so the model keeps the story, not a count. lcm stays a plugin
that runs after it; sp_core_compactor() is the fallback only when no plugin
registered one, because running both eats the conversation before lcm sees
work to do.
Two bugs fell out of the same area:
- The plugin host was only built when a plugin was configured, so a
plugin-less run had no compactor at all: over max_bytes the turn was
refused instead of compacted (90 KB session, budget 8000, "nothing
sent").
- lcm walked *forward* past tool results at the tail boundary, which
silently shrank the tail: a turn with two results kept four messages
where keep_tail says six. Walking back to the assistant that carries
the call keeps six and no orphan.
And the .meta sidecar is shared now: the core rewrote it with only the keys
it knew, so anything a plugin put there was gone on the next open. It
carries unknown lines through (extra[8][160]), which is what lets a plugin
mark a session in the core's own file.
Tests: tests/test_corecompact.c (10 checks, no plugin), the resume cases in
tests/test_session.c, and the tail-size check in tests/test_compactor.c.
Each was seen red on the old code before it was green on the new.
Everything that was uncommitted in the shared tree, in one commit because the
changes are interleaved across the same files (lcm, engine, frontend, locales).
lcm: a continuation prompt is not the task. After /resume the newest user
message is "Continue with the task ...", and pinning it kept the keystroke
while the question it continues was cut away -- measured: a resumed session
woke up with the prompt, one tool call and its error, and no task at all. The
pin now skips the harness's own continuation prompts, so the real question is
pinned again. test_compactor drives it: with the skip disabled the task is
lost (red), with it the task comes back after the summary (green).
engine: /self-check and the exact tool-argument parse are in a1794fb; this
commit carries the tests for them (a failed tool observation must appear in
the self-check prompt; mcp_parse_exact rejects two objects in one string) and
the i18n keys the new code uses: cmd.script.*, main.no_profile, tg.busy,
tg.interview.running, ui.agent_busy in all three catalogues.
The rest is the in-flight work from the shared session: engine/frontend,
plugins, telegram/a2a, and their tests.
make check: all tests passed; check_i18n ok, 204 keys in 3 catalogues.
env=NAME=VALUE on a delegate line (repeatable) is set in the child right
before exec and beats what the parent exported, so two delegates can run
the same cli with two accounts. Remotely it goes in front as
`env 'NAME=VALUE'`, quoted like the rest. cli_env = NAME=VALUE does the
same for the main cli transport. A bad name is an error with the line.
Also in this commit, the work in progress from the tree: swarm and
provider state, the provider/scheduler/planner/tmux plugins, the ui test,
whose tmux session name is now per run so parallel runs do not collide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gateway entry point accepted an empty token and then polled with it; the
guard belongs there so a daemon that cannot listen says so instead of looking
alive.
Honest limit of this change: it is NOT the explanation for the running daemon.
That one had a token (resolved from the token file) and failed with 'curl: (35)
Recv failure: Connection reset by peer' thousands of times, and with the env
variable removed it now fails with 'curl failed (-1)' and stops - a different
error, not the missing token. The guard only catches the case where neither the
environment nor the file provide one.
What this commit does prove: with a config that has endpoint, model and
telegram_allow, the daemon starts, reports 'gateway listening (allow: 8300935)',
and stops on the failing poll instead of looping. What it does not prove: that a
valid token makes it work - that needs a real message.
Four things, three of them reported by the operator.
1. Rows are counted from the real line structure. The old arithmetic
(strlen/cols) assumed one long line; a model's reasoning is full of '\n', so
the true height was far larger than the estimate and the text painted over
the answer below it - 'it just goes anywhere on the screen'. text_rows() and
row_offset() split on newlines first, then wrap. entry_lines() now measures
the string that is actually drawn ('role: text'), which also fixes the last
character of an entry being cut off (a truncated code fence).
2. Tool calls are visible: the agent's tool_begin hook fires before each call,
the UI drains the list under its lock and writes 'werkzeug: run
{"command":"echo a"}' into the transcript; the one at the top of the live
area shows the call while it runs. The reasoning entry is inserted before
those lines, so the transcript reads du, denkt, werkzeug, modell.
3. The chat pane has a black background, and the status line sits between the
pane and the prompt, the way Hermes shows it.
4. i18n is complete: every remaining literal in ui.c, main.c and the plugins
goes through the catalogue, including widget texts and format strings.
sp_td() carries a compiled-in English default, so a missing catalogue can
never drop a printf placeholder. tools/check_i18n.py runs in make check and
fails when a key used in the code is missing from any catalogue, or when a
catalogue key is used nowhere.
Seventeen test binaries green.
Compaction is not a flag in the loop; it is a compactor registered by a
plugin and run on the main thread before every request, with the whole
conversation in hand. Returning 1 means changed, 0 nothing to do, -1 failed -
and a failure is counted, not fatal.
lcm: deterministic lossy compression. Over budget, it keeps the leading
system prompt and the last six messages and inserts one system message that
says how many messages went, of which roles, and quotes the head of the
oldest dropped turn. No second model, so a run stays reproducible and costs
nothing extra.
cps: continuous parallel compression. The worker thread decides what would go
from an index it got under a mutex (role, size, 64 bytes of head per message)
and never touches the conversation; the main thread splices the prepared plan
in one pass when the budget is hit. The sidebar line shows applied/prepared
counts or a ready plan, so the claim is visible.
The limit is in both files: they can decide which messages go, not summarise
their text, because the text is not the worker's to read.
Ten test binaries green; test_compactor drives both against their real .so
files, including that lcm leaves the system prompt first, inserts the [lcm]
record at index 1, keeps the tail verbatim, and that cps needs two calls
(prepare, then apply) to change anything.