I hit a very predictable failure mode in AI automation: I left the defaults alone for too long.
Background jobs accumulated too much context, some of them were still landing on expensive models, and a couple of nightly tasks started timing out. The fix was not dramatic. It was mostly configuration discipline.
This was not an OpenClaw bug. It was a bad operating posture.
What Broke
Four things were interacting badly.
1. Context was too loose
Long-lived sessions are useful right up until they turn into token furnaces.
In my case, background jobs were carrying more history than they needed. Bootstrap reads were too generous, total context was not capped tightly enough, pruning kicked in too late, and compaction was acting more like an emergency brake than a normal control mechanism.
2. Premium models were handling cheap work
Interactive chat is where I want the strongest model. Cron jobs are not.
Some background work was still landing on expensive models for tasks that were basically:
- read a small file
- append a short note
- run one shell script
- stay silent on success
That is not a model-quality issue. It is a routing issue.
3. Anthropic was a poor fit for this specific background path
For this setup, Anthropic ended up being the wrong place to run bloated unattended jobs.
There was OAuth friction, strict default limits, and the usual cost of discovering context mistakes on an expensive model. If a cron job arrives oversized, a premium provider is the most expensive place to learn that lesson.
I am not claiming Anthropic is universally bad. I am saying it was a poor fit for this background workload in this OpenClaw configuration.
4. Some cron prompts had become far too long
A cron prompt should be brutally specific.
If the job is “run this backup script and only alert on failure”, then the prompt should say exactly that. Long prompts do not just cost more. They also make the model improvise.
The Symptoms
The two jobs that exposed the problem were:
- Nightly Memory Log
- Nightly SQLite backup to Drive
Both had recent failures with timeouts or non-delivery. The common pattern was obvious:
- runs on
claude-sonnet-4-6 - more tokens than the task justified
- runtimes drifting into the timeout envelope
- delivery failures that were really execution failures upstream
That is the signature of an oversized workflow.
The Fix
The fix was a stack of small configuration changes.
1. Keep the premium model for interactive chat
I kept interactive conversations on openai/gpt-5.4.
That is where stronger judgement is worth paying for.
2. Move background work to cheaper models
I changed the default routing for background-style work to:
- primary:
google/gemini-2.5-flash - fallback:
anthropic/claude-haiku-4-5
Heartbeat and compaction work moved off the expensive path as well.
3. Tighten context controls in config
The important changes were concrete:
agents.defaults.bootstrapMaxChars = 8000agents.defaults.bootstrapTotalMaxChars = 30000agents.defaults.contextTokens = 32000agents.defaults.contextPruning.mode = "cache-ttl"- compaction model moved to
google/gemini-2.5-flash
Those limits matter because background jobs should not ingest broad workspace context by default.
4. Use lighter and more isolated execution for unattended jobs
For background work, I enabled lighter context handling and pushed the most failure-prone jobs toward isolated execution.
For the specific repaired jobs, the cron definitions now explicitly use:
sessionTarget: "isolated"delivery.mode: "none"payload.model: "google/gemini-2.5-flash"payload.lightContext: truepayload.timeoutSeconds: 180
That combination makes the job smaller, cheaper, and more predictable.
5. Rewrite the prompts to match the real task
This was the fastest win.
I rewrote the two failing jobs to be much leaner.
Nightly Memory Log
The rewritten job now:
- ensures today’s memory file exists
- appends only genuinely missing durable notes
- prefers today’s file, yesterday’s file, and a tiny scan of relevant modified files
- avoids large reads
- stays silent on success
Nightly SQLite backup to Drive
The rewritten backup job now:
- runs the backup shell script
- stays silent on success
- sends one short alert on failure
- avoids extra analysis and unrelated file inspection
A backup job is not a philosopher.
The Result
After patching the config and trimming the prompts:
- the failing nightly jobs completed successfully on manual rerun
- background work moved off the expensive path
- timeout risk dropped sharply
- token waste dropped
- the system became much less fragile
Practical Advice
If you are running OpenClaw, my advice is simple:
- Keep the strongest model for interactive work.
- Default cron and heartbeat work to cheaper models.
- Set explicit context limits.
- Use isolated runs for unattended jobs when possible.
- Shrink prompts until they match the task and nothing else.
Final Take
The root problem was not that one provider was bad or one model was weak. The root problem was letting unattended automation inherit premium defaults, oversized context, and bloated prompts.
Once I split interactive work from background work, tightened the context budget, and rewrote the worst cron jobs, the whole setup settled down.
That is the real trick with AI automation: not making it more clever, but making it more disciplined.