Add Thinking default and Dreaming toggles to General menu#73
Open
x4484 wants to merge 3 commits into
Open
Conversation
Persists `agentDefaults.thinking` (off/low/medium/high) and `agentDefaults.dreaming` (boolean) under openclaw.json via a new `/api/agent-defaults` GET/PUT route. Mutations mark the gateway restart-required so OpenClaw picks up new defaults. Adds an "Agent Defaults" card to the General tab with a thinking-level select and a dreaming on/off toggle, plus unit and route tests for the read/write/normalize paths.
- Pass `true` to onRestartRequired() so the global restart banner renders (matches the pattern in envars/exec-config/setup-wizard). - Add `/api/agent-defaults` to SETUP_API_PREFIXES so the proxy catch-all knows the path is locally served, not gateway-bound.
- Refuse to overwrite openclaw.json when it exists but cannot be parsed. writeAgentDefaults now reads with fallback:null, throws MalformedOpenclawConfigError, and the route returns 409. Prevents the cascade where a transient parse failure was silently converted into permanent loss of channels/plugins/secrets. - Wire agentDefaults.thinking into the doctor service so the persisted value actually shapes agent behavior. Drop markRequired() from the PUT handler and remove the unused onRestartRequired prop on AgentDefaults -- the doctor reads the value per call, so no gateway restart is needed. - Refactor AgentDefaults to useCachedFetch (per AGENTS.md), and update the api-cache entry on successful PUT so a stale GET cannot reappear immediately after a write.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an Agent Defaults card to the Setup UI's General tab with two settings:
off/low/medium/high. Already wired intodoctor/service.jsso it actually shapes agent calls (replaces the hard-codedthinking: \"medium\").agentDefaults.dreamingfor OpenClaw to pick up when the gateway-side feature lands.Backed by
GET/PUT /api/agent-defaultswriting toopenclaw.jsonunderagentDefaults.Why these shapes
agentDefaults.thinkingat invocation time, so changing the default takes effect on the next agent call. The PUT handler does not mark restart-required — the prior version did, but the only consumer doesn't need a restart and signaling one would have been misleading.openclaw.json.writeAgentDefaultsdistinguishes ENOENT from parse failure: if the file exists but can't be parsed, the route returns409and the file stays untouched. Mirrors theexistsSync + fallback:nullpattern fromexec-defaults-config.js.useCachedFetchper AGENTS.md. The component reads through the shared cache and writes throughsetCachedafter PUT, so other tabs reading the same key see fresh data without a refetch.What's not in this PR
dreamingconsumer. The value persists, but nothing reads it yet. Out of scope by design — AlphaClaw owns persistence; OpenClaw owns runtime.agentDefaultskeys. Today PUT rejects bodies with no recognized fields. Tracked locally under ticket 4 in the run artifact; trivial fix when a third key is needed.tests/frontend/api.test.jswould cover this; tracked in the same ticket file.Test plan
npm test— 585 pass (was 582; adds 3 new tests covering the malformed-openclaw.jsonrefusal path and the from-scratch write path).npm run build:ui— bundle rebuilds cleanly.openclaw.json.openclaw.json(e.g., drop a closing brace), attempt a PUT, verify it returns 409 and the file is untouched.🤖 Generated with Claude Code