feat(workflow): add ContextAssembler and IncrementalSaver optional interfaces#2
Merged
Merged
Conversation
…terfaces Introduce two optional interfaces for MemorySession without changing the existing contract: - ContextAssembler: when implemented, Runtime calls Assemble(ctx, req) instead of Load(ctx), allowing custom context assembly (RAG, summarization, sliding window). Returned messages do NOT include req.Message; the runtime appends it uniformly. - IncrementalSaver: when implemented, Runtime calls Append(ctx, newMsgs) instead of Save(ctx, allMsgs), enabling efficient incremental persistence. Both interfaces are detected via type assertion at runtime, keeping MemorySession simple and all existing implementations unaffected. Made-with: Cursor
Made-with: Cursor
This was referenced May 12, 2026
lIang70
added a commit
that referenced
this pull request
May 21, 2026
Harden lease-recycle recovery under scope lock, transient retry with RetryAt/Attempt persistence, and require Scope/RuntimeID for drain and stats so workers cannot claim or observe cross-tenant queue state. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
ContextAssemblerinterface: when aMemorySessionimplements it, Runtime callsAssemble(ctx, req)instead ofLoad(ctx)duringprepareBoard, allowing custom context assembly (RAG, summarization, sliding window, etc.). The returned messages do NOT includereq.Message; the runtime appends it uniformly.IncrementalSaverinterface: when implemented, Runtime callsAppend(ctx, newMsgs)with only the newly produced messages instead ofSave(ctx, allMsgs), enabling efficient incremental persistence for database-backed stores.MemorySessioninterface itself remains unchanged, and all existing implementations require no modifications.Changed files
sdk/workflow/memory.goContextAssemblerandIncrementalSaverinterface definitionssdk/workflow/run.goprepareBoardprefersAssemble;finishRunprefersAppendsdk/workflow/run_integration_test.goTest plan
TestRuntime_ContextAssembler— verify Assemble is called, req is passed in, req.Message is appended by RuntimeTestRuntime_IncrementalSaver— verify Append receives only the new messagesTestRuntime_ContextAssembler_And_IncrementalSaver— verify both interfaces work in combination