Skip to content

feat: add WORKING.md as opt-in bootstrap file for working memory#46367

Closed
Br1an67 wants to merge 1 commit intoopenclaw:mainfrom
Br1an67:fix/9386
Closed

feat: add WORKING.md as opt-in bootstrap file for working memory#46367
Br1an67 wants to merge 1 commit intoopenclaw:mainfrom
Br1an67:fix/9386

Conversation

@Br1an67
Copy link
Copy Markdown
Contributor

@Br1an67 Br1an67 commented Mar 14, 2026

Summary

Add WORKING.md to the workspace bootstrap file system, enabling persistent working memory that survives context compaction.

Problem

After session compaction, agents lose all active task state, decisions in progress, and working context. The only memory files (MEMORY.md) are designed for long-term facts, not session-scoped working state. Agents have no reliable way to maintain context across compaction boundaries for long-horizon tasks.

Solution

Add DEFAULT_WORKING_FILENAME (WORKING.md) as an opt-in bootstrap file:

  • Added constant and type to WorkspaceBootstrapFileName union
  • Added to VALID_BOOTSTRAP_NAMES for runtime validation
  • loadWorkspaceBootstrapFiles() includes it when present (opt-in, like MEMORY.md)
  • Excluded from MINIMAL_BOOTSTRAP_ALLOWLIST (subagent/cron sessions don't receive it)

When users create WORKING.md in their workspace, it is automatically injected into every session — including post-compaction sessions — giving agents persistent working memory.

Non-breaking

  • Workspaces without WORKING.md are completely unaffected
  • No template is seeded automatically; users create it when they want working memory
  • No changes to the workspace setup wizard

Validation

pnpm exec vitest run src/agents/workspace.test.ts  # 17/17 passed (+2 new)

Fixes #9386

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Mar 14, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 14, 2026

Greptile Summary

This PR adds WORKING.md as an opt-in bootstrap file for persistent working memory across context compaction boundaries. The implementation is clean, non-breaking, and consistent with the existing MEMORY.md pattern — it only loads when the file is present, and correctly excludes the file from MINIMAL_BOOTSTRAP_ALLOWLIST so subagent and cron sessions are not affected.

The one gap is in test coverage: the filterBootstrapFilesForSession test suite does not include WORKING.md in its mockFiles fixture nor assert that it is absent from subagent/cron session results, leaving the "excluded from subagent sessions" invariant unvalidated despite the PR description calling it out explicitly.

Confidence Score: 4/5

  • Safe to merge — implementation is correct and non-breaking; only a test coverage gap exists.
  • The implementation correctly adds WORKING.md as an opt-in bootstrap file, keeps it out of the subagent/cron allowlist, and follows existing patterns. The score is 4 rather than 5 because the filtering invariant (WORKING.md excluded from subagent sessions) — explicitly highlighted in the PR description as a design goal — is not covered by any test, making it a regression risk for future changes.
  • src/agents/workspace.test.ts — the filterBootstrapFilesForSession tests need WORKING.md added to mockFiles and an assertion in expectSubagentAllowedBootstrapNames.

Comments Outside Diff (1)

  1. src/agents/workspace.test.ts, line 251-280 (link)

    Missing test coverage for WORKING.md subagent filtering

    The PR description explicitly states that WORKING.md is "Excluded from MINIMAL_BOOTSTRAP_ALLOWLIST (subagent/cron sessions don't receive it)" — but this invariant is never tested.

    Two gaps exist:

    1. mockFiles in the filterBootstrapFilesForSession describe block doesn't include a WORKING.md entry, so no filter test ever exercises this file.
    2. expectSubagentAllowedBootstrapNames checks that HEARTBEAT.md, BOOTSTRAP.md, and MEMORY.md are absent, but never asserts expect(names).not.toContain("WORKING.md").

    If DEFAULT_WORKING_FILENAME is accidentally added to MINIMAL_BOOTSTRAP_ALLOWLIST in a future change, no test would catch it. Suggested fix:

    And in expectSubagentAllowedBootstrapNames (line 70-72), add:

      expect(names).not.toContain("WORKING.md");
    
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/workspace.test.ts
Line: 251-280

Comment:
**Missing test coverage for WORKING.md subagent filtering**

The PR description explicitly states that `WORKING.md` is "Excluded from `MINIMAL_BOOTSTRAP_ALLOWLIST` (subagent/cron sessions don't receive it)" — but this invariant is never tested.

Two gaps exist:

1. `mockFiles` in the `filterBootstrapFilesForSession` describe block doesn't include a `WORKING.md` entry, so no filter test ever exercises this file.
2. `expectSubagentAllowedBootstrapNames` checks that `HEARTBEAT.md`, `BOOTSTRAP.md`, and `MEMORY.md` are absent, but never asserts `expect(names).not.toContain("WORKING.md")`.

If `DEFAULT_WORKING_FILENAME` is accidentally added to `MINIMAL_BOOTSTRAP_ALLOWLIST` in a future change, no test would catch it. Suggested fix:

```suggestion
  const mockFiles: WorkspaceBootstrapFile[] = [
    { name: "AGENTS.md", path: "/w/AGENTS.md", content: "", missing: false },
    { name: "SOUL.md", path: "/w/SOUL.md", content: "", missing: false },
    { name: "TOOLS.md", path: "/w/TOOLS.md", content: "", missing: false },
    { name: "IDENTITY.md", path: "/w/IDENTITY.md", content: "", missing: false },
    { name: "USER.md", path: "/w/USER.md", content: "", missing: false },
    { name: "HEARTBEAT.md", path: "/w/HEARTBEAT.md", content: "", missing: false },
    { name: "BOOTSTRAP.md", path: "/w/BOOTSTRAP.md", content: "", missing: false },
    { name: "MEMORY.md", path: "/w/MEMORY.md", content: "", missing: false },
    { name: "WORKING.md", path: "/w/WORKING.md", content: "active task", missing: false },
  ];
```

And in `expectSubagentAllowedBootstrapNames` (line 70-72), add:
```
  expect(names).not.toContain("WORKING.md");
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: 924da07

 openclaw#9386)

Add DEFAULT_WORKING_FILENAME (WORKING.md) to the workspace bootstrap
system. When users create a WORKING.md in their workspace, it is
automatically injected into every session — including post-compaction
sessions — giving agents persistent working memory across context
compactions.

This is fully opt-in: workspaces without WORKING.md are unaffected.
WORKING.md is excluded from the minimal bootstrap allowlist, so
subagent and cron sessions do not receive it.

Co-authored-by: Copilot <[email protected]>
@Br1an67
Copy link
Copy Markdown
Contributor Author

Br1an67 commented Mar 17, 2026

Closing to manage active PR count. Will reopen when slot is available.

@Br1an67 Br1an67 closed this Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Working Memory for Long-Horizon Agent Tasks - local user-space, markdown solution

1 participant