feat: add pinnedFiles config for workspace files injected outside compaction DAG#214
Closed
liu51115 wants to merge 2 commits intoMartian-Engineering:mainfrom
Closed
feat: add pinnedFiles config for workspace files injected outside compaction DAG#214liu51115 wants to merge 2 commits intoMartian-Engineering:mainfrom
liu51115 wants to merge 2 commits intoMartian-Engineering:mainfrom
Conversation
e399998 to
a840f28
Compare
3476c94 to
d8e0bb4
Compare
Extends pinnedFiles with a Record<string, string[]> keyed by agent ID. Per-agent paths merge with global pinnedFiles (deduped) at resolution time. Unknown agent IDs get global-only paths. Backward compatible.
d8e0bb4 to
86a478b
Compare
Contributor
Author
|
Closing this — we found a cleaner approach on the OpenClaw side. Custom workspace bootstrap files can be injected via the OC bootstrap loader, which avoids the complexity of maintaining pinnedFiles across LCM rebases. Thanks for the review feedback. |
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
Adds a
pinnedFilesconfig option that injects workspace-relative files into every context assembly outside the compaction DAG. These files are always current (read from disk each turn), never summarized, and never evicted.Motivation
Long-running sessions lose procedural context as LCM compacts earlier turns into summaries. Critical files like fleet-wide rules or safety boundaries get compressed into vague references, causing behavioral drift. Agents need a way to keep certain workspace files permanently in context.
How it works
"pinnedFiles": ["FLEET.md", "BOUNDARIES.md"]inopenclaw.plugin.jsonresolvePinnedFiles()reads files from the agent's workspace directory on eachassemble()call<pinned_file path="...">tags, with token budget deducted before eviction runsagents.listfrom OpenClaw config to find the correct workspace path per agent, with~/.openclaw/workspace-{agentId}fallbackSecurity
resolve()+startsWith()ensures paths stay within workspace&,",<,>escaped in path attributes~/or bare~(no mid-string replacement)stat()check beforereadFile(), 100KB per-file limit, oversized files silently skippedChanges
src/db/config.ts:pinnedFiles: string[]field +toStrArrayparsingsrc/types.ts:resolveWorkspaceDir()onLcmDependenciesinterfacesrc/assembler.ts:PinnedFileEntrytype, Step 0 prepend + budget deductionsrc/engine.ts:resolvePinnedFiles()with disk I/O, path validation, size guardsrc/plugin/index.ts:resolveWorkspaceDir()implementation reading OpenClaw agent configopenclaw.plugin.json: Schema + UI hints forpinnedFilestest/pinned-files.test.ts: 7 new tests (injection, eviction immunity, budget, config parsing)All 403 tests passing.