Python: Bound harness file memory with quotas and retention - #8970
Open
quifox (quifox) wants to merge 3 commits into
Open
quifox (quifox) wants to merge 3 commits into
quifox (quifox) wants to merge 3 commits into
Conversation
Add opt-in quotas, shared retention management, and server-owned cleanup with request lifetime protection. Preserve SDK defaults and cover limits, TTL transitions, concurrent operations, interruptions, and hosted streams.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Managed description cleanup, disabled-TTL deletion recovery, quota error handling, and synchronous accounting need correction.
Review effort: Balanced
Findings: 4
Open (5)
Legacy oversized descriptions bypass quota error handling · New Synchronous tree scans block the event loop during writes · New Disabled retention prevents cleanup of records marked deleting · New Overwrites retain stale descriptions when description is omitted · New Quota error reports outdated requested capacity · New
What changed in this PR
Adds bounded file-memory storage and experimental retention management to the Python SDK and hosted claw sample.
Changes:
- Adds per-file, file-count, root, and shared quotas.
- Adds TTL retention, GC, locking, repair, and request protection.
- Configures hosted defaults and extensive lifecycle tests.
| File | Description |
|---|---|
python/uv.lock |
Locks the new filelock dependency. |
python/packages/core/pyproject.toml |
Declares filelock. |
python/packages/core/AGENTS.md |
Documents quotas and retention. |
python/packages/core/agent_framework/__init__.py |
Exports the retention manager. |
python/packages/core/agent_framework/__init__.pyi |
Types the new export. |
_harness/_file_store_limits.py |
Implements quota validation and accounting. |
_harness/_file_access.py |
Enforces built-in store limits. |
_harness/_file_memory.py |
Integrates managed retention operations. |
_harness/_file_memory_retention.py |
Implements retention, GC, and shared quotas. |
claw_step04_production_ready/agent.py |
Accepts managed memory providers. |
claw_step04_production_ready/hosted.py |
Configures quotas and request protection. |
claw_step04_production_ready/README.md |
Documents hosted capacity and retention. |
test_harness_file_store_limits.py |
Tests store quotas. |
test_harness_file_memory.py |
Tests quota failure behavior. |
test_harness_file_memory_retention.py |
Tests retention and recovery. |
test_harness_hosted_memory_lifetime.py |
Tests hosted stream protection. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Complete confirmed deletions while TTL is disabled, clear omitted descriptions on overwrite, and report list/quota errors consistently. Move filesystem accounting and lifecycle I/O off the event loop while retaining coordination through cancellation. Cover legacy limits, shared descriptions, deletion recovery, quota diagnostics, and request cancellation with regression tests.
Preserve the 1.20.0 release metadata and updated msgspec bounds while retaining the filelock dependency used by managed retention. Verify the merged lockfile and rerun core validation with the resolved dependencies.
This branch was successfully deployed
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.


Motivation & Context
The hosted claw sample persists file memory without capacity or lifecycle controls. Repeated authorized writes and abandoned scopes can exhaust shared disk space. This change adds opt-in SDK limits and explicit retention management, and configures finite limits in the hosted sample.
Description & Review Guide
Related Issue
Fixes #8900
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.