feat: inject effort as soft default via CLI flags instead of env var (unlocks /effort and ultracode switching)#104
Open
TeigenZhang wants to merge 1 commit into
Conversation
CLAUDE_CODE_EFFORT_LEVEL hard-locks effort for the whole session and makes
Claude reject in-session /effort switching (incl. ultracode). Carry effort
as a dedicated payload field instead, injected at spawn as a soft default:
- regular levels (incl. max) -> claude --effort <level>
(the settings effortLevel key is enum([low,medium,high,xhigh]) with
.catch(undefined), so max would be silently dropped there)
- ultracode -> claude --settings '{"ultracode":true}'
(dedicated boolean settings key, rejected by the --effort flag)
Changes:
- add effort enum field to create/quick-start/ralph-loop schemas and thread
it through Session -> CreateSessionOptions/RespawnPaneOptions -> spawn
- buildEffortCliArgs() in session-cli-builder, shared by tmux spawn command
and direct-PTY fallback args
- frontend: buildEnvOverrides() no longer emits CLAUDE_CODE_EFFORT_LEVEL;
validated effort goes into payloads via getEffortSetting()
- settings UI: add Ultracode option to the Thinking Effort dropdown
- legacy migration: Session constructor extracts CLAUDE_CODE_EFFORT_LEVEL
from persisted envOverrides; applyEnvOverrides() unsets the stale tmux
session var so respawned panes are no longer locked
- tests: test/effort-injection.test.ts (13 cases)
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.
Problem
Codeman currently carries the Thinking Effort setting as the
CLAUDE_CODE_EFFORT_LEVELenv var (set via tmuxsetenvfromenvOverrides). The env var is a hard override in Claude Code: it locks effort for the whole session and makes the CLI reject in-session/effortswitching with:This makes it impossible to run a session at a normal effort level and temporarily switch to
ultracode(xhigh + dynamic workflow orchestration, claude >= 2.1.154) — or any other level — without recreating the session.Solution
Carry effort as a dedicated
effortpayload field and inject it at spawn time as a soft default the user can override anytime via/effort:claude --effort <level>effortLevelkey isenum(["low","medium","high","xhigh"]).catch(undefined)—maxgets silently dropped thereclaude --settings '{"ultracode":true}'--effortflagBoth carriers verified against claude CLI 2.1.167: effort is active at spawn (banner + status bar) and
/effortswitching works freely in both directions.Changes
effortenum field onCreateSessionSchema/QuickStartSchema/RalphLoopStartSchemaSession._effort→CreateSessionOptions/RespawnPaneOptions→buildSpawnCommand(tmux) andbuildInteractiveArgs(direct-PTY fallback); persisted inSessionState.effortand restored on reboot recoverybuildEffortCliArgs()insession-cli-builder.ts— single source for both carriers, allowlist-validated (injection-safe)buildEnvOverrides()no longer emitsCLAUDE_CODE_EFFORT_LEVEL; newgetEffortSetting()validates and sends theeffortfield from quick-start, session create, resume, and Ralph wizard payloadsUltracode (multi-agent workflows)option added to the Thinking Effort dropdown; hint updatedCLAUDE_CODE_EFFORT_LEVELfrom persisted__envOverridesintoeffortapplyEnvOverrides()unconditionally unsets the stale var on the tmux session so respawned panes are no longer lockedtest/effort-injection.test.ts— 13 cases covering carrier mapping, injection guards, args building, and constructor migrationTest plan
tsc --noEmit,lint,format:checkcleannpm test -- test/effort-injection.test.ts— 13/13effort=max→ process spawned with--effort max, banner shows max effort,/effort ultracodeswitch workseffort=ultracode→--settings '{"ultracode":true}', status bar shows ultracode · xhigh effort + dynamic workflows,/effort high⇄/effort ultracodeswitching worksgetEffortSetting()validation verified in-page