---
created: 2026-03-12
source: Rivet
tags: [agent-archive, rivet]
---

# Clawdbot Issues — Deep Research Document

*Created: 2026-02-25 19:45 AEDT*
*Purpose: Document ALL issues we're hitting, understand root causes, fix properly.*
*Michael's directive: "No quick fixes. Deep research. Understand the big picture."*

---

## Issue #1: Context Pruning TTL Set to 1h (Should Be 8h)

### Current State
```json
"contextPruning": {
  "mode": "cache-ttl",
  "ttl": "1h"
}
```

### What This Means
- **cache-ttl mode** prunes old tool results from the in-memory context before each LLM call
- When the last Anthropic API call for the session is older than TTL (currently 1h), pruning triggers
- After pruning: the full prompt gets re-cached (expensive `cacheWrite` tokens)
- With 1h TTL: any session idle for >1h gets pruned and has to re-cache everything

### Why 8h Matters
- Michael's sessions can be idle for hours (on site 5:30am-6pm, or between evening sessions)
- With 1h TTL, coming back after lunch = full re-cache = wasted tokens
- With 8h TTL, sessions survive the full workday without unnecessary re-caching
- Heartbeats run every 6h — should keep cache alive between them, not trigger pruning

### Anthropic's Actual Cache TTL Options
- **5 minutes** (default/"short") — for high-frequency API calls
- **1 hour** ("long"/`"1h"`) — for extended conversations
- These are Anthropic's server-side cache retention windows

### ⚠️ Key Discovery: 8h May Exceed Anthropic's Max Cache Retention
Anthropic prompt caching has only two TTL tiers:
- `ephemeral` / `"short"` = 5 minutes
- `"1h"` / `"long"` = 1 hour

**There is no 8-hour server-side cache option from Anthropic.** The `contextPruning.ttl` in Clawdbot controls when Clawdbot *prunes messages locally*, but the Anthropic cache itself only lasts max 1 hour regardless.

### What Setting TTL to 8h Actually Does
Setting `"ttl": "8h"` means:
- Clawdbot won't prune tool results for 8 hours (keeps more context in the window)
- But Anthropic's cache still expires after 1 hour of inactivity
- After 1h idle: the next API call will re-cache regardless (Anthropic side), but Clawdbot won't have pruned the old tool results
- Net effect: **more context preserved** (good for continuity), but **no cache savings** after 1h idle (Anthropic limitation)

### Root Question
Does Michael want:
a) **Preserve more context** (don't prune for 8h) — setting `"ttl": "8h"` achieves this
b) **Reduce cache costs** — this is limited by Anthropic's 1h max, not our TTL setting
c) **Both** — set TTL to 8h for context preservation, accept that cache-write costs happen after 1h idle

### Recommended Fix
Set `"ttl": "8h"` as Michael directed. The main benefit is **context preservation** — sessions keep their tool history for 8 hours, giving better continuity during THE WINDOW after a day on site.

---

## Issue #2: Subagent Model Fallback Bug (Hardcoded to Anthropic)

### The Problem
When spawning subagents with non-Anthropic models (Kimi, DeepSeek, MiniMax), they fail because:
1. Subagent runner hardcodes fallback to `"anthropic"` provider in `defaults.js`
2. Even with correct model specified, the subagent's internal provider resolution falls back to Anthropic

### Evidence
- **GitHub Issue #3237**: "Subagents ignore custom provider config and fall back to DEFAULT_PROVIDER (anthropic)"
  - Exact same bug. When spawning subagents with custom providers like MiniMax, it hardcodes fallback to "anthropic"
  - Root cause confirmed in source code
- **GitHub Issue #10883**: "Subagent Model Configuration Not Enforced"
  - User configured `subagents.model.primary = "ollama/phi3:mini"`, subagent used `claude-haiku-4-5` instead
  - The subagent config is simply ignored in certain code paths

### Our Config
```json
"subagents": {
  "maxConcurrent": 20,
  "model": "anthropic/claude-opus-4-6"
}
```
This works because our subagent default IS Anthropic. But when we try to spawn with `model: "kimi"` or `model: "deepseek"`, the override is ignored and it falls back to Anthropic, then fails if the alias resolves to a provider without keys.

### Root Cause
This is a **Clawdbot code bug**, not a configuration issue. The subagent runner's model resolution pipeline doesn't properly inherit custom provider configurations from the parent session.

### Status in Upstream
- Issue #3237 is open (1 month old)
- Issue #10883 is open (3 weeks old)
- No fix released as of 2026.2.25

### Workarounds
1. **Route all non-Anthropic models through OpenRouter**: `openrouter/moonshotai/kimi-k2-0905-preview` — this uses the OpenRouter API key which IS configured
2. **Don't use non-Anthropic models for subagents** until the upstream bug is fixed
3. **Our current config already has OpenRouter aliases** — but the `moonshot/`, `deepseek/`, `minimax/` direct routes still exist and will fail

---

## Issue #3: Provider Configuration Mismatch (No API Keys for Direct Routes)

### The Problem
Config has model aliases pointing to direct providers that have no API keys:

| Alias | Routes To | Provider Key? | Result |
|-------|-----------|--------------|--------|
| `moonshot/kimi-k2-0905-preview` | moonshot provider | ❌ No MOONSHOT_API_KEY | 401 Auth Error |
| `deepseek/deepseek-chat` | deepseek provider | ❌ No provider configured | Connection Error |
| `minimax/MiniMax-M2.5` | minimax provider | ❌ No provider configured | Connection Error |
| `openrouter/moonshotai/kimi-k2-0905-preview` | OpenRouter | ✅ OPENROUTER_API_KEY set | ✅ Works |
| `openrouter/deepseek/deepseek-chat-v3-0324` | OpenRouter | ✅ OPENROUTER_API_KEY set | ✅ Works |
| `openrouter/minimax/minimax-m2.5` | OpenRouter | ✅ OPENROUTER_API_KEY set | ✅ Works |

### Why It's Confusing
- Both direct AND OpenRouter routes share the same alias (e.g., `kimi` maps to both `moonshot/kimi-k2-0905-preview` AND `openrouter/moonshotai/kimi-k2-0905-preview`)
- When Clawdbot resolves the alias, which one does it pick? First match? Random?
- The moonshot provider IS configured with a `baseUrl` but NO API key — so it connects but gets 401'd

### The Fix
Either:
a) **Remove direct provider aliases** entirely, keep only OpenRouter routes (simplest)
b) **Add API keys** for Moonshot, DeepSeek, MiniMax direct providers (more control, potentially cheaper)
c) **Set priority/order** in alias resolution to prefer OpenRouter routes

---

## Issue #4: Clawdbot Version Outdated (2026.1.24-3 vs Latest 2026.2.25)

### Current Version
```
2026.1.24-3
```

### Latest Version
```
2026.2.25 (unreleased, but 2026.2.24 is latest stable)
```

### We're ~1 Month Behind

### Relevant Changes We're Missing (from CHANGELOG):

1. **Agents/Context pruning**: "Extend cache-ttl eligibility to Moonshot/Kimi and ZAI/GLM providers (including OpenRouter model refs), so contextPruning.mode: 'cache-ttl' is no longer silently skipped for those sessions."
   - **THIS IS CRITICAL**: Our cache-ttl pruning might be silently doing nothing for Kimi/DeepSeek sessions because the old version doesn't recognize those providers

2. **Agents/Model fallback**: "Keep explicit text + image fallback chains reachable even when `agents.defaults.models` allowlists are present, prefer explicit run `agentId` over session-key parsing for followup fallback override resolution"
   - Fixes model fallback issues we might be hitting

3. **1M Token Context Window Support**: v2026.2.17 unlocked Anthropic's 1M context window for Opus and Sonnet
   - Michael mentioned "OpenBot has 1 million token context" — this is the update
   - Our `contextTokens: 200000` cap might be artificially limiting us

4. **Heartbeat delivery hardening**: Multiple fixes for heartbeat routing, queueing, and delivery
   - Prevents heartbeat spam, duplicate responses, thread leakage

5. **Subagent/Cron reliability**: "Honor ANNOUNCE_SKIP in sessions_spawn completion flows, add transient direct-announce retries"
   - Better subagent behavior

6. **Automation/Subagent/Cron reliability**: Multiple fixes for subagent model resolution and fallback

7. **Security hardening**: Multiple cross-channel authorization fixes, sandbox improvements

### ⚠️ Breaking Changes in Newer Versions:
- Heartbeat delivery now blocks DM targets (blocks direct-message heartbeat delivery)
- Docker namespace-join mode blocked by default for sandbox

---

## Issue #5: contextTokens Cap at 200k (Opus 4.6 Supports 1M)

### Current Config
```json
"contextTokens": 200000
```

### What Claude Opus 4.6 Actually Supports
- **1 million tokens** context window (confirmed in v2026.2.17 release)
- Our config caps at 200k — using only 20% of available context

### What This Affects
- Long sessions get pruned/compacted earlier than necessary
- Memory search results might be artificially limited
- Complex multi-agent coordination loses context faster

### Consideration
- More context = more tokens per API call = higher cost
- Michael needs to decide the right balance between context richness and cost
- Anthropic charges for all tokens in the context window, so 1M context = 5x the per-call cost vs 200k

---

## Issue #6: ~~Heartbeat Interval at 6h~~ — CORRECTED: Heartbeat is 30m, NOT 6h

### Current Config (ACTUAL)
```json
"heartbeat": {
  "every": "30m",
  "model": "anthropic/claude-sonnet-4-20250514",
  "includeReasoning": false
}
```

### Correction (2026-02-25 19:57 AEDT)
**I was wrong.** The heartbeat is set to every 30 minutes, not 6 hours. This means:
- Heartbeats already keep the Anthropic server-side cache warm (30m < 1h TTL)
- ~48 heartbeats per day, not 4
- This is NOT an issue — it's working correctly
- The "heartbeat at 6h vs TTL interaction" concern was based on incorrect data

---

## Summary: The Big Picture

### What's Actually Broken vs What's Misconfigured

| Category | Issue | Type | Fix Location |
|----------|-------|------|-------------|
| TTL | Pruning at 1h instead of 8h | **Config** | clawdbot.json |
| Subagents | Models fall back to Anthropic | **Clawdbot Bug** | Upstream fix needed |
| Providers | Direct routes have no API keys | **Config** | clawdbot.json |
| Version | 1 month behind, missing critical fixes | **Update** | `clawdbot update` |
| Context | Capped at 200k when 1M available | **Config** | clawdbot.json |
| Cache-TTL | Silently skipped for Kimi/DeepSeek | **Clawdbot Bug** (fixed in newer version) | Update |

### The Right Fix Order
1. **Update Clawdbot** to 2026.2.24 — this fixes the cache-ttl provider bug and model fallback issues
2. **After update**: Adjust config (TTL, contextTokens, provider cleanup)
3. **Clean up aliases** — remove broken direct provider routes, keep only OpenRouter
4. **Test thoroughly** — each model as primary, as subagent, verify cache behavior
5. **Monitor** — watch token usage for 48h after changes to catch regressions

### What We Can't Fix (Upstream Bugs)
- Subagent model override being ignored (#3237, #10883) — may be partially fixed in newer versions
- Anthropic cache max TTL is 1 hour — no way around this server-side limitation

---

*This document will be updated as we learn more. No quick fixes. Fix it right.*
