Repository navigation
Sessions: internal annotations and session config - #3061
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: a34472b The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
Contributor
🟡 agents import sizes: 1 entry point grew
Changed exports (1)
How this worksEach runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement. Compared |
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
3 times, most recently
from
November 23, 2026 19:46
3290786 to
a5bfe06
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 23, 2026 20:58
a5bfe06 to
f6c6de6
Compare
mattzcarey
marked this pull request as ready for review
November 23, 2026 21:00
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 23, 2026 22:27
f6c6de6 to
aa768d3
Compare
mattzcarey
marked this pull request as draft
November 23, 2026 22:30
mattzcarey
force-pushed
the
slim/sessions-read-model
branch
from
November 23, 2026 22:42
06e569f to
865f313
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 23, 2026 22:46
aa768d3 to
5da3de1
Compare
mattzcarey
changed the base branch from
slim/sessions-read-model
to
slim/sessions-tail
November 23, 2026 22:46
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 23, 2026 23:46
df9aea0 to
e8b47ff
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 23, 2026 23:47
635dfb9 to
fdc4d39
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 00:06
e8b47ff to
84f6ac5
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 00:06
fdc4d39 to
fca6adb
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 00:39
84f6ac5 to
96910de
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 00:39
fca6adb to
1000b2b
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 02:26
96910de to
b0dc972
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 02:26
1000b2b to
926d6f6
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 02:49
b0dc972 to
41e1733
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 02:50
926d6f6 to
d2abdcd
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 03:46
41e1733 to
8b9219c
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 03:47
d2abdcd to
43b8357
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 03:56
8b9219c to
49d02d1
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 03:56
43b8357 to
63cd4e6
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 04:12
49d02d1 to
e911b06
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 04:13
63cd4e6 to
8aa64c5
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 05:22
e911b06 to
6cec3e2
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 05:23
8aa64c5 to
3a8e1c0
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 05:51
6cec3e2 to
6c2d93c
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 05:52
3a8e1c0 to
f41c819
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 06:06
6c2d93c to
45a2146
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 06:06
f41c819 to
95e1b7f
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 06:20
45a2146 to
e2be7c8
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 06:20
95e1b7f to
92a8972
Compare
mattzcarey
force-pushed
the
slim/sessions-tail
branch
from
November 24, 2026 06:33
e2be7c8 to
993e0ee
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 06:34
92a8972 to
aab6f4b
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
2 times, most recently
from
November 24, 2026 10:23
b5944be to
ce27cd5
Compare
mattzcarey
marked this pull request as ready for review
November 24, 2026 10:23
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 10:46
ce27cd5 to
d4ed309
Compare
mattzcarey
force-pushed
the
slim/sessions-annotations
branch
from
November 24, 2026 10:56
d4ed309 to
a34472b
Compare
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.
Lands together with, or immediately under, context's #2773, which is the caller of these methods. It is held as a draft until then.
Sessions can now keep server-side data about a session's messages and the session itself, for Think's context records (#2773). It is internal only.
Sessiongets five@internalmethods:internal_annotations,internal_setAnnotation,internal_latestAnnotation,internal_configandinternal_setConfig. Nothing is exported and there is no user docs page.Context needs one small record per turn, such as the system prompt a turn was sent with. That record must stay out of the message JSON so a client cannot read or forge it, must follow the transcript tree, and must be found without walking the stored path:
cf_agents_session_annotations, one row per message and kind, created with the other Sessions tablesdeleteMessagesdrops the deleted messages' annotations, andclearMessagesdrops all of themcompact()oraddCompaction()) copies, for each kind, the newest annotation it hides onto the overlay's message id, including one set directly on an overlay it replaces. The read runs before the overlay's write transaction and the copy inside it, so whoever reads the visible path never looks below an overlayinternal_latestAnnotation(kind, leafId)returns the newest annotation among the messagesgetHistory({ leafId })returns, overlay messages included. It walks newest-first in batches, checks only the ids in each batch, and stops at the first hit: a record one row from the leaf costs a few rows read at 10,000 stored rows (a test pins under 50), and no id set is heldcf_agents_session_configtable;clearMessagesdeletes keys starting withtranscript:, and every other key outlives a clearCost, from perf's harness, base #3056 / head. Turns and connects are unchanged. Every start costs one more statement, the
CREATE TABLE IF NOT EXISTS, which reads 0 rows. The other extra rows read come from five existing startup probes that scan all ofsqlite_master(perf's finding 6), each now seeing one more schema row: think/startup-500 rows read 5,008 / 5,015, chat/startup-500 4,860 / 4,868, still about 1,000 below the release. A fresh agent writes 2 more rows, once, when it creates the table. A session that never annotates pays nothing on reads, and a compaction in such a session writes only its overlay row; tests pin both.Once a session has any annotation,
addCompactionandcompact()also look for annotations to carry onto the new overlay. That walk goes row by row from the overlay's end down to where the history continues, through rows already under older overlays, and reads about 4 more rows per row it passes. Measured by the gate on a deployment, the second compaction of a 100,000-row session read 600,158 rows with an annotation present, against 200,211 without. With #2773, every Think session with a context block has an annotation. A follow-up PR makes the walk jump over an older overlay the way the read path does, taking the value that overlay already carried.latestAnnotationreads 102 to 113 rows at 10,000 stored rows (rv-5, deployed). A cold start reads 6 more rows (the gate).An annotation an overlay carried stays on the overlay after the message it came from is deleted. The overlay's summary was written with that message in it, so the record still describes what the summary covers. The follow-up states this in the doc comment.
Tests ran:
src/tests/sessions/annotations.test.ts(new), the sessions suite, Think session and hydration, and AIChat persistence and clear.