openclaw - ✅(Solved) Fix [Bug]: lightContext not filtering workspace files (heartbeat + cron) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61395Fetched 2026-04-08 02:59:04
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
1
Author
Participants
Timeline (top)
cross-referenced ×2labeled ×2

Setting lightContext: true on both:

  1. agents.list[].heartbeat.lightContext
  2. agents.defaults.heartbeat.lightContext
  3. Cron job payload.lightContext

...has no effect. All workspace files (AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, MEMORY.md) are still injected into the system prompt.

Root Cause

Root Cause Analysis

Fix Action

Fixed

PR fix notes

PR #61441: fix(agents): honor light bootstrap context paths

Description (problem / solution / changelog)

Summary

  • forward lightweight bootstrap context mode/run kind through system-prompt composition
  • preserve bootstrap context mode/run kind through compaction runtime paths, including overflow recovery
  • add regressions covering lightweight heartbeat system-prompt resolution and lightweight compaction bootstrap resolution

Testing

  • attempted: pnpm test -- src/auto-reply/reply/commands-system-prompt.test.ts src/agents/pi-embedded-runner/compact.hooks.test.ts src/agents/pi-embedded-runner/compaction-runtime-context.test.ts
  • local dependency install was blocked by registry DNS failures in this environment (EAI_AGAIN), so tests were added but not executed here

Closes #61395

Changed files

  • docs/automation/cron-jobs.md (modified, +1/-0)
  • docs/cli/cron.md (modified, +2/-0)
  • src/agents/pi-embedded-runner/compact.hooks.harness.ts (modified, +4/-1)
  • src/agents/pi-embedded-runner/compact.hooks.test.ts (modified, +22/-0)
  • src/agents/pi-embedded-runner/compact.ts (modified, +4/-0)
  • src/agents/pi-embedded-runner/compaction-runtime-context.test.ts (modified, +4/-0)
  • src/agents/pi-embedded-runner/compaction-runtime-context.ts (modified, +6/-0)
  • src/agents/pi-embedded-runner/run.ts (modified, +2/-0)
  • src/agents/pi-embedded-runner/run/attempt.ts (modified, +4/-0)
  • src/auto-reply/reply/commands-system-prompt.test.ts (modified, +31/-5)
  • src/auto-reply/reply/commands-system-prompt.ts (modified, +2/-0)
  • src/cron/isolated-agent.direct-delivery-forum-topics.test.ts (modified, +42/-0)
  • src/cron/isolated-agent.skips-delivery-without-whatsapp-recipient-besteffortdeliver-true.test.ts (modified, +18/-0)
  • src/cron/isolated-agent/delivery-dispatch.ts (modified, +35/-4)

Code Example

{
  "systemPromptReport": {
    "systemPrompt": { "chars": 29707, "projectContextChars": 17460 },
    "injectedWorkspaceFiles": [
      { "name": "AGENTS.md", "injectedChars": 10543 },
      { "name": "SOUL.md", "injectedChars": 1664 },
      { "name": "TOOLS.md", "injectedChars": 850 },
      { "name": "IDENTITY.md", "injectedChars": 319 },
      { "name": "USER.md", "injectedChars": 3241 }
    ]
  }
}

---

{
  "agents": {
    "list": [{
      "id": "main",
      "heartbeat": {
        "lightContext": true,
        "isolatedSession": true,
        "model": "anthropic/claude-haiku-4-5"
      }
    }],
    "defaults": {
      "heartbeat": {
        "lightContext": true,
        "isolatedSession": true,
        "model": "anthropic/claude-haiku-4-5"
      }
    }
  }
}

---
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Issue Title

lightContext: true on heartbeat and cron payloads does not filter workspace files — full bootstrap context always injected

Version

OpenClaw 2026.4.2 (d74a122)

Description

Setting lightContext: true on both:

  1. agents.list[].heartbeat.lightContext
  2. agents.defaults.heartbeat.lightContext
  3. Cron job payload.lightContext

...has no effect. All workspace files (AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, MEMORY.md) are still injected into the system prompt.

Expected Behavior

  • Heartbeat with lightContext: Only HEARTBEAT.md should be injected (per applyContextModeFilter at pi-embedded-BYdcxQ5A.js:342)
  • Cron with lightContext: Zero workspace files should be injected (per pi-embedded-BYdcxQ5A.js:343)

Actual Behavior

All workspace files are injected regardless of lightContext setting. System prompt report shows 5+ files totaling ~17k chars of project context.

Root Cause Analysis

Heartbeat path (runtime-BXvktGYG.js)

  1. lightContext: true is correctly converted to bootstrapContextMode: "lightweight" (line 1152)
  2. Passed to getReplyFromConfig() as opts.bootstrapContextMode
  3. BUG: reply-BilMVRVo.js (getReplyFromConfig) never forwards bootstrapContextMode to the agent runner. The property is accepted but silently dropped.
  4. resolveBootstrapFilesForRun is called without contextMode, defaults to "full", injects everything.

Cron path (gateway-cli-CWpalJNJ.js)

  1. lightContext is correctly converted to bootstrapContextMode: "lightweight" (line 5156)
  2. bootstrapContextRunKind: "cron" is also set (line 5157)
  3. These ARE passed to the agent runner (pi-embedded-BYdcxQ5A.js:37582-37583)
  4. resolveBootstrapContextForRun at line 37573 receives them correctly
  5. However, systemPromptReport from actual runs shows 5 files injected — suggesting either:
    • A different code path is used for the initial system prompt (line 31027 does NOT pass contextMode/runKind)
    • Or applyBootstrapHookOverrides is re-adding files after filtering

Evidence

Session entry for cron run with lightContext: true:

{
  "systemPromptReport": {
    "systemPrompt": { "chars": 29707, "projectContextChars": 17460 },
    "injectedWorkspaceFiles": [
      { "name": "AGENTS.md", "injectedChars": 10543 },
      { "name": "SOUL.md", "injectedChars": 1664 },
      { "name": "TOOLS.md", "injectedChars": 850 },
      { "name": "IDENTITY.md", "injectedChars": 319 },
      { "name": "USER.md", "injectedChars": 3241 }
    ]
  }
}

Impact

  • Heartbeat runs cost ~$0.07/run on Haiku instead of ~$0.01
  • At 48 runs/day: ~$3.40/day wasted on unnecessary context
  • Cron jobs that should be lightweight still inject full workspace context

Config

{
  "agents": {
    "list": [{
      "id": "main",
      "heartbeat": {
        "lightContext": true,
        "isolatedSession": true,
        "model": "anthropic/claude-haiku-4-5"
      }
    }],
    "defaults": {
      "heartbeat": {
        "lightContext": true,
        "isolatedSession": true,
        "model": "anthropic/claude-haiku-4-5"
      }
    }
  }
}

Steps to reproduce

Setting lightContext: true on both:

  1. agents.list[].heartbeat.lightContext
  2. agents.defaults.heartbeat.lightContext
  3. Cron job payload.lightContext

...has no effect. All workspace files (AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, MEMORY.md) are still injected into the system prompt.

Expected behavior

  • Heartbeat with lightContext: Only HEARTBEAT.md should be injected (per applyContextModeFilter at pi-embedded-BYdcxQ5A.js:342)
  • Cron with lightContext: Zero workspace files should be injected (per pi-embedded-BYdcxQ5A.js:343)

Actual behavior

All workspace files are injected regardless of lightContext setting. System prompt report shows 5+ files totaling ~17k chars of project context.

OpenClaw version

OpenClaw 2026.4.2 (d74a122)

Operating system

macOS Tahoe 26.2

Install method

No response

Model

Anthropic (claude-haiku-4-5 for heartbeat/cron, claude-opus-4-6 for main)

Provider / routing chain

webchat → gateway → agent:main (dmScope: main)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The lightContext: true setting is not being properly forwarded to the agent runner, causing all workspace files to be injected into the system prompt instead of the expected filtered context.

Guidance

  • Verify that the bootstrapContextMode is being correctly set to "lightweight" in both the heartbeat and cron job configurations.
  • Check the getReplyFromConfig function in reply-BilMVRVo.js to ensure that it is forwarding the bootstrapContextMode property to the agent runner.
  • Investigate the applyBootstrapHookOverrides function to determine if it is re-adding files after filtering.
  • Test the resolveBootstrapFilesForRun and resolveBootstrapContextForRun functions to ensure they are working as expected with the lightContext: true setting.

Example

No code snippet is provided as the issue is related to the internal workings of the OpenClaw system and requires a deeper understanding of the codebase.

Notes

The issue seems to be related to the forwarding of the bootstrapContextMode property to the agent runner. The getReplyFromConfig function in reply-BilMVRVo.js is suspected to be the cause of the issue. Further investigation is needed to determine the root cause and implement a fix.

Recommendation

Apply a workaround by modifying the getReplyFromConfig function to properly forward the bootstrapContextMode property to the agent runner. This will ensure that the lightContext: true setting is respected and only the expected files are injected into the system prompt.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

  • Heartbeat with lightContext: Only HEARTBEAT.md should be injected (per applyContextModeFilter at pi-embedded-BYdcxQ5A.js:342)
  • Cron with lightContext: Zero workspace files should be injected (per pi-embedded-BYdcxQ5A.js:343)

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: lightContext not filtering workspace files (heartbeat + cron) [1 pull requests, 1 participants]