Skip to content

server: /train examples carry their tools, and a message can be context without being trained - #22

Merged
joelteply merged 1 commit into
feat/props-weight-residencyfrom
continuum/train-a-turn-as-context
Sep 27, 2026
Merged

joelteply merged 1 commit into
feat/props-weight-residencyfrom
continuum/train-a-turn-as-context

Conversation

@joelteply

Copy link
Copy Markdown

Card ad107e18 in continuum: a training example is the turn the model actually lived.

  • tools on an example. It is passed to the chat template exactly as serving passes it, so the trained prompt has the tool block the model was served with.
  • "train": false on a message. It keeps an assistant turn as context: rendered, never located as a span, no loss. The key is removed before the template sees the message. A non-boolean value is refused.

Smoke on the M5 (qwen2.5-0.5b, Metal, -ngl all), one example with history, an earlier reply, a tool call and tools:

earlier reply rendered tokens trainable tokens
train: false 193 25
trained 193 33

A string value is refused with examples[0].messages[2].train must be a boolean.

The continuum side sends lived calls this way in continuum#4445.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…xt without being trained

A lived turn is a served conversation: a system prompt, history that includes
the model's own earlier replies, the tools it was offered, and one reply that
is the lesson. /train could not express that. Every assistant turn in a
messages example was trained, and no tools reached the template, so the
rendered prompt lacked the tool block the model was served with.

- "tools" on an example is passed to the chat template exactly as serving
  passes it (common_chat_tools_parse_oaicompat).
- "train": false on a message keeps it as context: it renders, it is not
  located as a span, and it carries no loss. The key is read and removed
  before the template sees the message. A non-boolean value is refused.

Smoke on the M5 (qwen2.5-0.5b, Metal, -ngl all): one example with history,
an earlier reply and a tool call. 193 tokens both ways; 25 trainable with the
earlier reply marked train:false, 33 with it trained; a string value refused
as examples[0].messages[2].train must be a boolean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit to CambrianTech/continuum that referenced this pull request Sep 27, 2026
…onversation, with only her reply trained

A lived call reaches /train as the conversation she was served: the system
prompt, every served message, and her reply with its reasoning_content and
tool calls. Her earlier replies in that history carry "train": false, so
they are context and not trained again. The tools she was offered ride on the
example, so the prompt renders with its tool block. Other examples still go
as {prompt, completion}.

The OpenAI tool mapping moves to request_body::openai_tools, one mapping for
serving and for the trainer.

Needs CambrianTech/llama.cpp#22 on the engine for the train flag and tools.
An older engine renders the history reply as trained and ignores the tools.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Author

APPROVED at a1cf473 (Cormac). I read the code and did not build it; your M5 smoke (25 vs 33 trainable, and the string refused) is the run it rests on.

  • train:false is read, validated as a boolean and erased before the template sees the message. An untrained assistant turn is skipped for span location, so it stays context. If every assistant turn is train:false, the example still refuses as "no assistant turn to learn", which is right.
  • The tools thread through all three renders (full, pre, upto), so spans are located against the same prompt serving framed. A malformed tool throws inside the render try, so it becomes a named 400.

Non-blocking: a "tools" value that is present but not an array is silently treated as no tools. The example then renders without its tool block, trains against a prompt the model never saw, and nothing says so. Refusing it by name, as train does, would match the rest of the validation.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply added a commit to CambrianTech/continuum that referenced this pull request Sep 27, 2026
…d example carries its call (card ad107e18) (#4445)

* feat(training): a staged turn holds the calls she lived, and a settled example carries its call (card ad107e18)

A card-linked turn staged only its stimulus and an acted chain, so what reached
a bucket was a re-derivation of the turn, not the turn. Now:

- Every generation receipt carries the prompt capture cursor it was recorded
  under: the link from an example back to its trace (Kimi's provenance rule).
- When a turn stages, every served call is read back from the capture (the
  exact request the engine was served, her exact response with reasoning and
  tool calls) and held on the staged row, because the capture rotates within
  hours and a card can settle days later. Each four-act restage reads only the
  new calls. A turn with any call that cannot be read back holds no lived
  record and says why (training.credit.lived_unavailable), never a partial one.
- A card that settles PASS submits one example per lived call, each carrying
  its call whole (TrainingExample.lived) with the flat prompt/completion kept
  as a projection for trainers that take text.
- Once the destination accepts the transfer, the row drops its copy of the
  calls and keeps the receipts, so settled rows stay small.
- One decoder of a schema-4 capture (prompt_capture::decode) now serves both
  the replay command and the lifter.

Not in this slice, named on the card: the correction-aware lift, thread
pointers across turns, and the selection weights Kimi asked for (loops,
announcements, predictions about peers); the engine trainer rendering
TrainingExample.lived through the served chat template (#4443).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(training): name the submit boundary on the lived examples' serialization

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(training): the engine trainer's test example carries lived: None (rebase onto #4443)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* feat(training): the engine trainer sends a lived call as its served conversation, with only her reply trained

A lived call reaches /train as the conversation she was served: the system
prompt, every served message, and her reply with its reasoning_content and
tool calls. Her earlier replies in that history carry "train": false, so
they are context and not trained again. The tools she was offered ride on the
example, so the prompt renders with its tool block. Other examples still go
as {prompt, completion}.

The OpenAI tool mapping moves to request_body::openai_tools, one mapping for
serving and for the trainer.

Needs CambrianTech/llama.cpp#22 on the engine for the train flag and tools.
An older engine renders the history reply as trained and ignores the tools.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(training): a lived call's history is framed by the same wire_messages serving uses (Cormac on #4445)

engine_example mapped history as role plus content_text(). Serving keeps
tool_calls on her assistant turns and splits ToolResult into role:tool
messages bound by tool_call_id, so every call after her first act trained
against a history she never saw.

format_messages is split: wire_messages is the config-free mapping (system
prompt, tool calls, tool results, image gating), and format_messages adds the
gateway's /no_think switch on top. The trainer frames the history with
wire_messages, marks each assistant turn train:false, and builds her reply's
tool calls with the same wire_tool_call. The test history now carries an act
and its result, and asserts both reach /train as serving sent them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(training): the trainer closes a history that ends in her own turn, as serving does (Cormac on #4445)

Serving runs close_trailing_assistant after framing, so a self-tick history
ending in her turn got a [continuation] user message before her reply. The
trainer skipped it and rendered two assistant turns in a row. It now calls it
after wire_messages; the test asserts no two assistant turns are adjacent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* fix(training): the receipt carries the COMPLETED capture entry's cursor, the one that holds her response

The test caught a real defect: a finished call is a NEW capture entry, and
the cursor the receipt took (lease.cursor(), the submission's) reads back
as the request with no response. Every production read would have named the
turn unavailable.

PromptCaptureSink::terminal and CaptureLease::finish now return the
completed entry's cursor, and the faculty finishes the lease before building
the receipt, so with_capture records that cursor. The test asserts the
submission cursor alone reads as a hole and the completed one reads whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

* chore(protocol): ts-rs bindings for LivedCall and TrainingExample.lived

TrainingExample.ts is CI's regenerated diff verbatim; LivedCall.ts follows the
generator's form for the new type (imports sorted, field docs as emitted).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@joelteply
joelteply merged commit c3f8d20 into feat/props-weight-residency Sep 27, 2026
6 of 25 checks passed
joelteply added a commit that referenced this pull request Sep 27, 2026
…ormed-tools

server: /train refuses a "tools" that is not an array (Cormac on #22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant