feat(context-offloader): auto-namespace unified Storage under offloader - #3258
Conversation
When a unified Storage is passed to ContextOffloader, keys are now auto-scoped under 'offloader/' to prevent collisions with other constructs sharing the same Storage (e.g. session manager uses 'session/'). Pre-namespaced storage is respected as-is. LocalFileStorage passed directly is also auto-routed through the agent's sandbox via forSandbox, matching the legacy FileStorage behavior.
|
Issue (cross-SDK parity): This introduces the Suggestion: Either mirror this behavior (and the |
|
Assessment: Comment (a few things to confirm before merge) Auto-scoping unified storage under Review themes
Nice touch keeping pre-namespaced storage untouched via the |
- Use exact toEqual assertions in auto-namespacing tests - Route eviction deletes through per-agent sandbox storage - Document forSandbox contract for sandbox routing - Document single-level namespace limitation on LocalFileStorage
|
Re-review (updated commits) Thanks for the quick turnaround — the new commits address the substantive feedback from the last round:
One item from the last review is still open and non-blocking:
Assessment: Approve once the cross-SDK parity item is either resolved or explicitly tracked. The code changes themselves look good to merge. |
… on namespaced views Two bugs fixed from TS PR strands-agents#3258: 1. Eviction now uses _storage_for_agent(agent) so deletes route through the agent's sandbox instead of bypassing it. 2. LocalFileStorage.namespace() returns _NamespacedLocalFileStorage which preserves for_sandbox, so pre-namespaced storage still binds to the sandbox correctly.
Replace /\/+/g and /\/+$/ regex patterns in normalizeKey, normalizePrefix, LocalFileStorage, and S3Storage with split/filter/join string operations to avoid polynomial backtracking on uncontrolled input.
Description
When a unified Storage is passed to ContextOffloader, keys are now auto-scoped under 'offloader/' to prevent collisions with other constructs sharing the same Storage (e.g. session manager uses 'session/'). Pre-namespaced storage is respected as-is.
LocalFileStorage passed directly is also auto-routed through the agent's sandbox via forSandbox, matching the legacy FileStorage behavior.
Related Issues
Documentation PR
Type of Change
Bug fix
New feature
Breaking change
Documentation update
Other (please describe):
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.