OpenClaw Cron lightContext bug: stop burning tokens on workspace injection
Problem statement: you configured your OpenClaw cron jobs with lightContext: true to minimize token usage,
but your token logs still show massive consumption. Each automated job is burning through 16,000 to 19,000+ tokens
even though you explicitly disabled workspace context injection. This is not a configuration error on your part.
It is a bug in the OpenClaw cron runtime where bootstrapContextMode and bootstrapContextRunKind
were not passed through to the context builder, causing all 5 workspace bootstrap files to be injected regardless of your lightContext setting.
- GitHub PR #60776 created on April 4, 2026, documents the root cause: cron jobs with lightContext enabled were still injecting all 5 workspace bootstrap files because critical context mode parameters were not propagated through the cron execution path.
- Before the fix, verified cron runs showed
injectedWorkspaceFiles: 5,projectContextChars: 12,304, andtotalTokensranging from 16k to 19k+ despite lightContext being explicitly set to true. - After the fix, a verified cron session confirmed
injectedWorkspaceFiles: [],projectContextChars: 0, andtotalTokens: 4,548, representing approximately 70-75% token reduction. - The bug specifically affected automated workflows, meaning that batch jobs, scheduled reports, and overnight automation were silently consuming far more tokens than necessary.
Why this token waste matters for automated workflows
Token waste in cron jobs is particularly pernicious because it compounds silently. Unlike interactive sessions where you can see the context buildup in real-time and make intentional decisions, cron jobs run unattended. If each job wastes 12,000 tokens on unnecessary workspace injection, and you run 10 jobs per hour, that is 120,000 wasted tokens per hour or 2.88 million wasted tokens per day. At typical API pricing, this can amount to hundreds of dollars per month in pure waste.
The lightContext setting exists specifically for this use case: automated workflows that do not need workspace context because they operate on fixed payloads or external data. When the setting does not work as advertised, you lose both the cost savings and the predictability that automation requires.
How to confirm you have the lightContext bug
- Check your cron configuration: verify that
lightContext: trueis set in your cron job definition. - Review session logs: look for
injectedWorkspaceFilesin your cron session output. If it shows 5 files instead of an empty array, the bug is active. - Check projectContextChars: a value around 12,304 characters indicates workspace bootstrap content is being injected despite lightContext.
- Compare totalTokens: if your cron jobs consistently use 16,000+ tokens even for simple prompts, you are likely affected.
- Verify with a fresh job: create a minimal cron job with lightContext and a trivial payload. If it still uses 15k+ tokens, the bug is confirmed.
Understanding the root cause
The bug occurs because the cron execution path did not pass two critical parameters to the context builder: bootstrapContextMode and bootstrapContextRunKind.
Without these parameters, the context builder defaulted to standard behavior, which includes injecting all workspace bootstrap files:
AGENTS.md, IDENTITY.md, SOUL.md, TOOLS.md, and MEMORY.md. These files collectively add approximately 12,000 characters to the context window.
What makes this bug particularly insidious is that the lightContext flag was being accepted and stored—it just was not being used.
Your configuration was technically correct, but the runtime did not honor it for the specific case of workspace bootstrap injection.
The fix: what changed
The fix in GitHub PR #60776 ensures that when lightContext is enabled for a cron job,
the bootstrapContextMode and bootstrapContextRunKind parameters are properly propagated through the execution chain.
This allows the context builder to skip workspace bootstrap file injection as intended.
After applying the fix, the same cron job that previously consumed 16,000+ tokens now uses approximately 4,500 tokens. The system prompt remains intact (around 11,000 characters), but the project context is completely empty, resulting in the lean token footprint that lightContext was designed to provide.
How to apply the fix
The fix is available in the OpenClaw upstream codebase. Apply it by upgrading to a version that includes the changes from PR #60776.
No configuration changes are required—your existing cron jobs with lightContext: true will automatically benefit from the reduced token usage.
- Check your current version: run
openclaw --versionto see your current installation. - Review release notes: look for mentions of PR #60776 or lightContext fixes in the changelog.
- Upgrade when available: use your standard upgrade procedure (npm, Docker pull, or binary replacement).
- Test with a single job: run one cron job with lightContext and verify the token reduction before rolling out broadly.
- Monitor token usage: compare your per-job token costs before and after the upgrade to confirm the fix is active.
Verifying the fix is working
After upgrading, you want concrete confirmation that workspace injection is now skipped. Here is how to verify:
- Check injectedWorkspaceFiles: should now be an empty array
[]instead of 5 files. - Verify projectContextChars: should be
0instead of approximately 12,304. - Confirm totalTokens reduction: expect around 4,500 tokens for typical jobs instead of 16,000+.
- Validate systemPrompt.chars: should remain around 11,000—this confirms the fix only affected workspace injection, not the core prompt.
- Run a before/after comparison: save a cron session log from before the upgrade and compare it to a new run to quantify your savings.
Fix once. Stop recurring cron token waste.
If this keeps coming back, you can move your existing setup to managed OpenClaw cloud hosting instead of rebuilding the same stack. Import your current instance, keep your context, and move onto a runtime with lower ops overhead.
- Import flow in ~1 minute
- Keep your current instance context
- Run with managed security and reliability defaults
If you would rather compare options first, review OpenClaw cloud hosting or see the best OpenClaw hosting options before deciding.
The patch discussion around PR #60776 includes concrete before-and-after cron session measurements rather than vague claims about efficiency.
Before the fix, a cron job with lightContext enabled still showed injectedWorkspaceFiles: 5, projectContextChars: 12,304,
and totalTokens in the 16,000 to 19,000+ range. After the fix, the same lightContext path produced injectedWorkspaceFiles: [],
projectContextChars: 0, and totalTokens: 4,548. That is the important operator signal: the bug had a measurable cost profile,
and the fix materially changed it.
When to use lightContext for cron jobs
Now that the bug is fixed, it is worth reviewing when lightContext is the right choice for your automated workflows:
- Fixed-payload jobs: cron jobs that process structured input (webhooks, API calls, scheduled reports) do not need workspace context.
- External data processing: jobs that fetch data from external APIs and format it do not benefit from workspace files.
- High-frequency automation: jobs running every minute or hour should use lightContext to avoid cumulative token waste.
- Simple notifications: alert and notification workflows typically do not require memory of past workspace state.
- Batch processing: jobs that iterate over predefined tasks can operate without workspace bootstrap overhead.
When NOT to use lightContext
Some cron jobs genuinely benefit from workspace context. Do not disable it if your job:
- References project-specific conventions defined in IDENTITY.md or AGENTS.md.
- Needs to recall past decisions stored in MEMORY.md.
- Relies on tool usage patterns documented in TOOLS.md.
- Operates as part of a broader workflow that assumes shared workspace context.
Related cron issues and troubleshooting
Token waste is not the only issue that can affect cron job reliability. If you are experiencing other cron problems, see OpenClaw cron enqueued but not running for lane stall issues, cron validation errors during job creation, or cron run timeout failures for execution delays. For a comprehensive overview of cron scheduling mechanics, see OpenClaw cron jobs guide.
Cost implications at scale
The 70-75% token reduction from fixing this bug has meaningful financial implications for teams running automated workflows at scale. Consider a scenario with 20 cron jobs running hourly: before the fix, this would consume approximately 320,000-380,000 tokens per hour. After the fix, the same workload uses approximately 90,000 tokens per hour. At typical API pricing, this saves tens to hundreds of dollars per month depending on your provider and model choices.
For teams evaluating self-hosted vs managed hosting, these kinds of upstream bugs represent the hidden operational cost of self-hosting. When you run OpenClaw yourself, you inherit every bug in every release until you patch or upgrade. Managed hosting providers can apply fixes at the infrastructure level, often before you even notice the issue.
Edge cases and migration notes
- Downgrade safety: if you must downgrade after applying the fix, your cron jobs will revert to the previous token-hungry behavior but will continue to function correctly.
- Mixed-version fleets: if you run multiple OpenClaw instances, upgrade them all to avoid inconsistent token usage across your cron fleet.
- Custom context builders: if you have custom skills or tools that inject additional context, the fix only affects the standard workspace bootstrap files—custom injection remains unchanged.
- Testing in staging: always validate the fix in a staging environment before applying to production, especially if you have complex cron dependencies.
Typical mistakes that delay resolution
- Blaming the LLM provider for high token costs when the issue is actually workspace injection in the OpenClaw runtime.
- Assuming lightContext is working without checking the actual session logs for injectedWorkspaceFiles.
- Trying to reduce token usage by shortening prompts when the bulk of the waste is from uncontrollable workspace bootstrap injection.
- Disabling cron jobs entirely to control costs instead of identifying and fixing the root cause.
- Creating complex workarounds like custom scripts to strip context, when the proper fix is to upgrade to a version with the bug resolved.
FAQ
Do I need to update my cron job configurations after upgrading?
No. The fix is in the OpenClaw runtime itself, not in configuration syntax. Your existing cron jobs with lightContext: true will automatically benefit
from reduced token usage after you upgrade to a version that includes PR #60776.
Will this fix affect my interactive sessions?
No. The fix specifically addresses the cron execution path. Interactive sessions were already correctly handling lightContext in most cases. The bug was isolated to how cron jobs propagated context mode parameters.
What if I cannot upgrade immediately?
Until you can upgrade, you have limited options. The bug is in the OpenClaw runtime, not in configuration, so there is no setting you can change to work around it. You can temporarily reduce cron frequency or simplify payloads to partially offset the token waste, but the only complete fix is upgrading to a patched version.
Does this affect all cron jobs or only those with lightContext enabled?
Only cron jobs with lightContext: true are affected. Jobs without lightContext enabled are intended to receive workspace bootstrap injection,
so their token usage is expected. The bug is that lightContext jobs were receiving the same injection as regular jobs despite being configured to skip it.
How can I track my token savings after the fix?
Compare the totalTokens field in your cron session logs before and after the upgrade. Calculate the difference per job, then multiply by your job frequency
to estimate monthly savings. For teams using OpenClaw Setup's managed hosting, token usage is tracked in the dashboard, making before/after comparisons straightforward.
Sources
- GitHub PR #60776: Fix lightContext not being respected for cron jobs (created 2026-04-04)
- OpenClaw repository: cron job implementation and context builder source
- OpenClaw cron jobs guide: how scheduling really works
- Before-fix cron session evidence from the patch discussion: injectedWorkspaceFiles: 5, projectContextChars: 12,304, totalTokens in the 16,000 to 19,000+ range
- After-fix cron session evidence from the patch discussion: injectedWorkspaceFiles: [], projectContextChars: 0, totalTokens: 4,548