Skip to content

server: forget one conversation's kept states (POST /v1/imprint/forget) - #3226

Open
ashhart wants to merge 4 commits into
mainfrom
lead/imprint-forget-one
Open

ashhart wants to merge 4 commits into
mainfrom
lead/imprint-forget-one

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026

Copy link
Copy Markdown
Owner

POST /v1/imprint/forget forgets one conversation's kept prompt states and leaves every other conversation's.

What changed

  • The body is the conversation as a chat completion body. The server renders and keys it exactly as that conversation's next request is keyed for resuming: the same render, the request's cache key (images by their content), and on families that key images by frame, the framed first word.
  • It drops, in RAM and on disk, each kept state whose tokens are a prefix of that key or continue it (a later turn's).
  • States other conversations build on stay: shared system-prompt cuts, a prefix another kept conversation continues, a branch point, and the states --learn keeps for shared prefixes.
  • On disk it removes only states the store's own index names, inside its own folder, with the blocks no other state names; no path comes from the request. Saves still being written land and are indexed first, so another conversation's write in flight is not cancelled.
  • It answers found, states, ram_bytes, disk_states, disk_bytes, shared_states, disk, ram_tokens, disk_tokens and waited_seconds. An unknown conversation answers found: false and drops nothing. DELETE /v1/imprint with no body is unchanged.

Who may call it: the request cancel route's rule, through the same helper. With API keys, a full or [admin] key, checked again by the route. Without keys, only a direct loopback socket (IPv4-mapped included) carrying none of Forwarded, X-Forwarded-For, X-Forwarded-Host, X-Real-IP, Via, CF-Connecting-IP, True-Client-IP. Everyone else gets 403 loopback_only.

Why replies in flight and other conversations are unchanged: the drop uses the prompt cache flush's hold: it runs on the engine thread only once no request is in flight, and new requests wait in the queue meanwhile. A running reply finishes exactly as it would have. A forget also cancels background warm passes in flight and keeps replies running at the time from starting one, so nothing puts a forgotten state back; the flush gets the same guard. The named conversation's next turn prefills cold with the same tokens; other conversations keep their own states and still resume.

Tests (host): the named conversation leaves RAM and disk while another's and a shared cut stay; an unknown name drops nothing; naming a prefix drops later turns; a prefix another conversation continues stays until that one is forgotten too; a write in flight lands first; the bodiless forget is unchanged; the next turn starts cold with the same tokens and the other conversation resumes; a turn in flight ends unchanged before the drop; a framed image conversation is named by its framed key; the keyless loopback and proxy rules, the route's admin-scope check, 501 and the --idle-unload 503, and warm-pass cancellation. New step test-imprint-forget-host; test-server-cpu, test-prompt-cache-host, test-key-scopes-host, test-server-security, test-prompt-cache-flush-host and test-frame-cache-identity-host pass.

Stacked on #3210 (prompt cache flush), which is stacked on #3193 (cancel a request by id).

A served check is still owed: two conversations resuming; forget one; its next turn cold with the same token_sha256; the other still resuming; an unseen conversation found: false; a proxied keyless call 403; DELETE /v1/imprint unchanged.

Fixes #3197

  • Synthena (Ash's Agent)

@ashhart
ashhart force-pushed the lead/imprint-forget-one branch from 7081167 to 1fb8223 Compare November 14, 2026 01:00
@ashhart
ashhart force-pushed the lead/imprint-forget-one branch 4 times, most recently from 4cef9ed to 5b56693 Compare November 21, 2026 11:00
@ashhart
ashhart force-pushed the lead/imprint-forget-one branch 2 times, most recently from 930a2c1 to ef5481c Compare November 21, 2026 17:26
POST /v1/imprint/forget takes a chat body, renders and keys it as that conversation's next request would be (an
image's rows by its content, and on a framed family the frame in the first word, as the host's lookups key it), and
drops the conversation's own kept states in RAM and on disk: each state whose tokens are a prefix of that key or
continue it. A state another conversation builds on stays: one kept at a shared cut, a prefix another kept state
continues, or a branch point (the store's own rule for a conversation's states). On disk only the states the store's
index names are removed, with the blocks no other state names; saves the I/O thread is writing land and are indexed
first, so another conversation's write in flight is not cancelled with them. The answer says what went, what stayed
because others use it and where the conversation would still resume; found is false for one never kept.
DELETE /v1/imprint keeps its meaning.

The drop rides the flush's hold: it runs on the engine thread once no request is in flight, while the lane host, a
family's round planner and Flash Next's serial host admit nothing new, so a reply running then ends unchanged, the
states it keeps go too, and the conversation's next turn prefills cold with the same tokens. A forget or flush also
cancels the warm passes in flight and keeps replies running at the time from starting one, so no background prefill
puts a forgotten state back. A wait that runs out withdraws it untaken, and an engine without the shared store
answers 501 at once.

Who may forget is the request cancel route's rule (cancel_ids.allowed): with API keys a full or [admin] key, checked
again by the route; without keys only a loopback socket that no proxy header relayed.

Fixes #3197
A prompt list builds one openai.Run per prompt; after the imprint forget
counter joined Run, its literal had no forgets value and the server stopped
compiling. Each run now takes the counter as the request began, as a
single chat or completion does.
@ashhart
ashhart force-pushed the lead/imprint-forget-one branch from ef5481c to 46b0bcb Compare November 22, 2026 00:45

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forget one conversation's saved states and keep the rest

1 participant