Skip to content

Add Thinking default and Dreaming toggles to General menu#73

Open
x4484 wants to merge 3 commits into
chrysb:mainfrom
x4484:feat/general-thinking-dreaming-settings
Open

Add Thinking default and Dreaming toggles to General menu#73
x4484 wants to merge 3 commits into
chrysb:mainfrom
x4484:feat/general-thinking-dreaming-settings

Conversation

@x4484

@x4484 x4484 commented Apr 25, 2026

Copy link
Copy Markdown

Summary

Adds an Agent Defaults card to the Setup UI's General tab with two settings:

  • Thinking defaultoff / low / medium / high. Already wired into doctor/service.js so it actually shapes agent calls (replaces the hard-coded thinking: \"medium\").
  • Dreaming — boolean toggle, persisted under agentDefaults.dreaming for OpenClaw to pick up when the gateway-side feature lands.

Backed by GET/PUT /api/agent-defaults writing to openclaw.json under agentDefaults.

Why these shapes

  • Per-call read, no restart needed. The doctor service reads agentDefaults.thinking at 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.
  • Refuses to overwrite a corrupt openclaw.json. writeAgentDefaults distinguishes ENOENT from parse failure: if the file exists but can't be parsed, the route returns 409 and the file stays untouched. Mirrors the existsSync + fallback:null pattern from exec-defaults-config.js.
  • useCachedFetch per AGENTS.md. The component reads through the shared cache and writes through setCached after PUT, so other tabs reading the same key see fresh data without a refetch.

What's not in this PR

  • OpenClaw-side dreaming consumer. The value persists, but nothing reads it yet. Out of scope by design — AlphaClaw owns persistence; OpenClaw owns runtime.
  • Forward-compat for additional agentDefaults keys. 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.
  • Frontend component tests. Existing pattern in tests/frontend/api.test.js would cover this; tracked in the same ticket file.

Test plan

  • npm test — 585 pass (was 582; adds 3 new tests covering the malformed-openclaw.json refusal path and the from-scratch write path).
  • npm run build:ui — bundle rebuilds cleanly.
  • Manual: change Thinking default in the UI, run a doctor scan, verify the gateway call uses the new value.
  • Manual: toggle Dreaming on/off, verify the value round-trips in openclaw.json.
  • Manual: corrupt openclaw.json (e.g., drop a closing brace), attempt a PUT, verify it returns 409 and the file is untouched.

🤖 Generated with Claude Code

x4484 added 3 commits April 24, 2026 17:49
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant