Repository navigation
feat(core): API-managed per-session context entries - #34941
Merged
Merged
Conversation
Add a session_context_entry table and a SessionContextEntry service whose load(sessionID) produces one SystemContext source per stored entry, keyed api/<key>. Entries ride the existing belief lifecycle: changes narrate as chronological System updates, deletions announce through the stored removal text, and compaction folds accumulated updates into the rebaselined prompt. String values render verbatim inside a tagged block; other JSON pretty-prints.
Expose GET/PUT/DELETE /api/session/:sessionID/context-entry[/:key] behind the session location middleware. Clients supply a slash-free key; the server derives the api/<key> SystemContext namespace by construction. Regenerates the client surfaces.
This was referenced Jul 2, 2026
This was referenced Jul 19, 2026
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #34918. Follow-up to #34917.
Allows API clients to attach durable, per-session context that rides the system context belief model.
What
session_context_entrytable (session_id,key, JSONvalue; composite PK, cascade delete)SessionContextEntryservice:list/put/removeplusload(sessionID), which emits oneSystemContextsource per entry keyedapi/<key>loadSystemContextin the runner now takes the session ID and composes entries as the sixth producerGET /api/session/:sessionID/context-entry— listPUT /api/session/:sessionID/context-entry/:key— upsert{ value: Json }DELETE /api/session/:sessionID/context-entry/:key[a-z0-9][a-z0-9._-]*); the server derives theapi/*SystemContext namespace by construction, keepingcore/*reserved for built-inspackages/clientand plugin effect API surfacesRendering
Server-owned phrasing, no client-supplied text. String values render verbatim inside a
<context key="...">block (the common case: prose instructions); other JSON pretty-prints. Because entries flow through the reconcile/checkpoint lifecycle:PUTa changed value → chronological System update at the next turn boundaryDELETE→ removal announcement via the stored removal textTesting
session-runner.test.ts: baseline render, update narration, removal announcement, list/remove semanticssdk-nextembedded testmigration --checkfresh