sync: preserve knowledge base vectors and refine context accounting - #126
Merged
Conversation
Knowledge base collections are no longer dropped implicitly. When the stored dense vector dimension cannot be read, or differs from the current embedding model, the collection is preserved and the operation aborts with an explicit error so an operator can verify the embedding configuration and re-index on purpose. Previously a transient Milvus outage was enough to silently wipe every indexed vector. Context usage accounting moves tool definitions out of the "tools" bucket. Tool schemas are part of the fixed instruction surface sent on every request, not evidence that the model executed a tool, so they are now counted with the system prompt. The snapshot schema is bumped to context-usage.v2 and the frontend rejects v1 snapshots to avoid mixing the two accounting rules. Also included: sandbox provider event-loop affinity, a single size limit for all sandbox file transfers, sandbox myspace directories created as the sandbox runtime user, streaming selection and scroll fixes, and partial answer retention when a chat run is cancelled.
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.
Community edition sync derived from the upstream development tree.
Knowledge base collections are never dropped implicitly
get_or_create_collectionused to drop and recreate the collection whenever thestored dense vector dimension could not be read or did not match the current
embedding model. A transient Milvus outage was therefore enough to silently
delete every indexed vector.
The collection is now preserved in all three cases — unreadable schema, missing
dimmetadata, and a genuine dimension mismatch — and the operation aborts withan explicit error so an operator can verify the embedding configuration and
re-index deliberately. Four regression tests cover the new behaviour.
Tool definitions are accounted for as system tokens
Tool schemas are sent on every request as part of the fixed instruction surface;
they are not evidence that the model executed a tool. Counting them in the
toolsbucket inflated the tool share of the context panel. They now belong tothe
systembucket in both the measured and the post-compaction estimatedsnapshot.
The snapshot schema is bumped to
context-usage.v2, and the frontend parserrejects
v1snapshots so old and new accounting rules are never mixed in onepanel.
Also included
rebuilds caused by cross-loop calls.
SANDBOX_ARTIFACT_MAX_BYTESbecomes the single size limit for every sandboxfile transfer, including
/myspacewrite-back.myspacedirectories are created as the sandbox runtime user, soagents can write into them.
is no longer forced back to the bottom.
Verification
Generated with
scripts/build_ce.py; brand, LICENSE, required-runtime-file andbinary-allowlist gates all pass. Backend tests for the touched areas pass
upstream.