#22140: feat(config): add usageDefault to agent defaults for persistent /usage mode
size: XS
Cluster:
Compaction Enhancements and Features
## Summary
Fixes #22083
Adds `usageDefault` to `AgentDefaultsConfig` so users can persist their preferred `/usage` footer level in `openclaw.json` without re-running `/usage` after every `/new` or restart.
## Usage
```jsonc
{
"agents": {
"defaults": {
"usageDefault": "tokens" // off | tokens | full
}
}
}
```
## Change Type
- [x] Feature
## Scope
- [x] Config / DX
## Linked Issues
Fixes #22083
## Root Cause
`/usage` sets `responseUsage` on the session entry, but this resets on every `/new` or restart. There was no config-level default to fall back to.
## Fix
**`src/config/types.agent-defaults.ts`** — added `usageDefault?: "off" | "tokens" | "full"` to `AgentDefaultsConfig`, following the same pattern as `verboseDefault`, `thinkingDefault`, and `elevatedDefault`.
**`src/auto-reply/reply/agent-runner.ts`** — extended the `responseUsageRaw` fallback chain:
```ts
// Before:
const responseUsageRaw =
activeSessionEntry?.responseUsage ??
(sessionKey ? activeSessionStore?.[sessionKey]?.responseUsage : undefined);
// After:
const responseUsageRaw =
activeSessionEntry?.responseUsage ??
(sessionKey ? activeSessionStore?.[sessionKey]?.responseUsage : undefined) ??
followupRun.run.config.agents?.defaults?.usageDefault;
```
The `/usage` per-session override continues to work exactly as before — `responseUsage` on the session entry takes precedence over the config default.
## Compatibility / Migration
- Backward compatible? Yes — new optional field, defaults to `undefined` (existing behavior unchanged)
- Config/env changes? No migration needed; add `usageDefault` to `openclaw.json` to opt in
🤖 AI-Assisted: Yes (via OpenClaw / MIST)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds `usageDefault` config field to persist `/usage` footer preferences across sessions and restarts, following the same pattern as `verboseDefault`, `thinkingDefault`, and `elevatedDefault`.
- Added `usageDefault?: "off" | "tokens" | "full"` to `AgentDefaultsConfig` TypeScript type
- Extended fallback chain in `agent-runner.ts` to check config default after session-level overrides
- **Critical issue**: Missing Zod schema definition for `usageDefault` field
The implementation correctly follows the existing pattern for similar defaults, with proper fallback precedence (session override → config default). However, the Zod schema wasn't updated, which will cause config validation to reject `usageDefault` due to the `.strict()` mode in `AgentDefaultsSchema`.
<h3>Confidence Score: 2/5</h3>
- Implementation is correct but missing critical schema validation, will break when users try to use the feature
- The TypeScript implementation correctly follows existing patterns and the fallback chain is properly ordered. However, the missing Zod schema entry means the feature won't work in practice - config validation will reject `usageDefault` settings, making this a breaking issue that needs to be fixed before merge.
- src/config/zod-schema.agent-defaults.ts needs the missing schema field added
<sub>Last reviewed commit: ea26de1</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22089: feat: persist default /usage mode via agents.defaults.usage
by AIflow-Labs · 2026-02-20
85.3%
#10197: fix: add missing allowAgents to agent defaults subagents schema
by Yida-Dev · 2026-02-06
76.1%
#14640: feat(agents): support per-agent temperature and maxTokens in agents...
by lailoo · 2026-02-12
75.6%
#21558: config: support agents.list[].thinkingDefault
by Uarmagan · 2026-02-20
75.3%
#13215: fix: pass agentId to loadCostUsageSummary in /usage cost command
by veast · 2026-02-10
75.1%
#16899: feat(config): per-agent and per-model thinking defaults
by jh280722 · 2026-02-15
73.8%
#10807: fix(config): coerce numeric meta.lastTouchedAt to ISO string
by mcaxtr · 2026-02-07
73.5%
#13825: feat: add agents.defaults.responseUsage config option
by dor-sr · 2026-02-11
73.5%
#19329: feat: add per-agent compaction and context pruning overrides
by curtismercier · 2026-02-17
73.3%
#14934: fix: add mistral to MemorySearchSchema provider/fallback unions
by ThomsenDrake · 2026-02-12
73.1%