chatAtoms.ts1.4 KBView on GitHub
import { atomWithStorage } from 'jotai/utils';

/**
 * Chat-composer runtime/effort selection.
 * - 'cedar-fast' is not an effort level: it pins the turn to Cedar's fast Mastra
 *   runtime with the new tool families (non-viewers) instead of the SDK harness.
 * - 'low'|'medium'|'high' set the reasoning-effort of the in-app SDK-harness path.
 *   Capped at 'high' by design — 'xhigh'/'max' are Opus-only and not offered here.
 */
export type ReasoningEffort = 'low' | 'medium' | 'high' | 'cedar-fast';

/**
 * Defaults to Cedar's fast runtime, and the KEY is versioned to make that default reach people
 * who already have one stored.
 *
 * `atomWithStorage` only consults the default when the key is absent, so changing the default
 * alone would have moved nobody: every existing user carries `chat:reasoningEffort = "low"` from
 * the old default and would have gone on using the harness forever. Bumping the key retires those
 * values wholesale — a one-line, one-time reset that needs no migration code — and anyone who
 * then picks a runtime keeps it, because their choice lands under the new key.
 *
 * Bump it again only to force another default across everyone; a plain default change is not
 * enough, and silently reusing the key is how a "new default" ships to new accounts only.
 */
export const reasoningEffortAtom = atomWithStorage<ReasoningEffort>(
  'chat:reasoningEffort:v2',
  'cedar-fast',
);