π fix(agentDocuments): add progressive disclosure PolicyLoad mode#13571
π fix(agentDocuments): add progressive disclosure PolicyLoad mode#13571nekomeowww merged 2 commits intocanaryfrom
Conversation
Add PolicyLoad.PROGRESSIVE that injects only document title and description as a lightweight file index instead of full content. New documents default to this mode, reducing token usage for agents with many/large documents. Fixes LOBE-6702 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #13571 +/- ##
========================================
Coverage 66.64% 66.64%
========================================
Files 1997 1997
Lines 165699 165726 +27
Branches 16847 16098 -749
========================================
+ Hits 110428 110455 +27
Misses 55147 55147
Partials 124 124
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
|
π Assigning reviewers for this PR. This PR adds a cc @nekomeowww @tjx666 β could you take a look? The changes affect agent document injection logic and database policy models. |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71fc2c4ba5
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| agentId, | ||
| createdAt, | ||
| policyLoad: PolicyLoad.ALWAYS, | ||
| policyLoad: PolicyLoad.PROGRESSIVE, |
There was a problem hiding this comment.
Persist progressive loadMode for newly created documents
Setting policyLoad to PROGRESSIVE here without also recording policy.context.loadMode = 'progressive' creates an inconsistency with composeToolPolicyUpdate: when updateLoadRule is later called without rule.mode (the current API shape), it falls back to 'always' and silently flips these docs back to full-content autoload. In practice, any load-rule edit on a newly created doc can disable the progressive behavior and reintroduce higher token usage.
Useful? React with πΒ / π.
β¦ule updates composeToolPolicyUpdate used to fallback to 'always' when rule.mode was omitted, silently flipping progressive docs back to full-content autoload. Now it preserves the existing policyLoad when no explicit mode is provided. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
π» Change Type
π Related Issue
Fixes LOBE-6702
π Description of Change
Add a new
PolicyLoad.PROGRESSIVEmode for agent document prompt injection. Instead of injecting full document content into the prompt (which is costly for many/large documents), progressive mode injects only a lightweight index showing each document's title and description.Key changes:
PolicyLoad.PROGRESSIVE = 'progressive'enum value<agent_documents_index>block with title + description per entryPROGRESSIVEinstead ofALWAYSβ reducing token usage out of the boxreadDocumenttool (on-demand)ALWAYSdocuments are unaffected (backward compatible)Files changed (11):
packages/agent-templates/src/types.tsβ enum additionpackages/context-engine/.../shared.tsβ progressive index formatting incombineDocumentspackages/database/.../permission.tsβ allow PROGRESSIVE in auto-load gatepackages/database/.../agentDocument.tsβ default policyLoad β PROGRESSIVEpackages/database/.../policy.tsβ supportmode: 'progressive'in tool policy compositionpackages/database/.../types.tsβ add 'progressive' to ToolUpdateLoadRule.modesrc/services/agentDocument.tsβ pass description + policyLoad to contextsrc/server/.../RuntimeExecutors.tsβ same for server-side mappingπ§ͺ How to Test
π Additional Information
No database migration needed β
policy_loadisvarchar(30)and accepts the new'progressive'string value. The Drizzle schema.default()is left unchanged to avoid migration; only the application-level default increate()is updated.π€ Generated with Claude Code