← Back to PRs

#22089: feat: persist default /usage mode via agents.defaults.usage

by AIflow-Labs open 2026-02-20 18:05 View on GitHub →
size: S
## Summary - Add `agents.defaults.usage` to agent defaults config schema and types. - Wire session initialization so new sessions (including `/new` resets) use the configured usage default when no per-session `/usage` override exists. - Preserve existing `/new` per-session `/usage` override behavior by carrying prior `responseUsage` when present. - Add regression coverage in `initSessionState` for config-backed defaults and override precedence. ## Validation - `pnpm test src/auto-reply/reply/session.test.ts` - `pnpm test src/config/sessions.test.ts` - `pnpm check` (format + tsgo + lint) ## Notes This is intentionally scoped to one issue and keeps `/usage` slash-command behavior intact while making default usage mode persistent from `openclaw.json`. Closes #22083. <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds persistent `agents.defaults.usage` configuration to control the default `/usage` mode across sessions. The implementation correctly wires the config schema, types, and help text, and includes comprehensive test coverage for the happy paths. **Critical issue found:** - When `/new` is triggered on an existing session without a prior `/usage` override, the config default is ignored and `"off"` is used instead. This breaks the main feature of this PR - making the usage default persistent from config. <h3>Confidence Score: 2/5</h3> - This PR has a critical logical error that prevents the main feature from working correctly - The implementation contains a bug in the reset logic that breaks the config default behavior - when users trigger `/new` on existing sessions without prior overrides, the config default is bypassed. The rest of the implementation (schema, types, tests for other scenarios) is solid, but this bug undermines the core functionality - Pay close attention to `src/auto-reply/reply/session.ts:261` - the logic error will cause incorrect behavior for the main use case <sub>Last reviewed commit: fdac13f</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs