(workspaceId: string)
| 39 | * Used by compaction, resume, idle-compaction, and plan execution outside React context. |
| 40 | */ |
| 41 | export function getSendOptionsFromStorage(workspaceId: string): SendMessageOptions { |
| 42 | const defaultModel = getDefaultModel(); |
| 43 | const rawModel = readPersistedState<string>(getModelKey(workspaceId), defaultModel); |
| 44 | const baseModel = normalizeModelPreference(rawModel, defaultModel); |
| 45 | |
| 46 | // Read thinking level (workspace-scoped). |
| 47 | // Migration: if the workspace-scoped value is missing, fall back to legacy per-model storage |
| 48 | // once, then persist into the workspace-scoped key. |
| 49 | const scopedKey = getThinkingLevelKey(workspaceId); |
| 50 | const existingScoped = readPersistedState<ThinkingLevel | undefined>(scopedKey, undefined); |
| 51 | const thinkingLevel = |
| 52 | existingScoped ?? |
| 53 | readPersistedState<ThinkingLevel>( |
| 54 | getThinkingLevelByModelKey(baseModel), |
| 55 | WORKSPACE_DEFAULTS.thinkingLevel |
| 56 | ); |
| 57 | if (existingScoped === undefined) { |
| 58 | // Best-effort: avoid losing a user's existing per-model preference. |
| 59 | updatePersistedState<ThinkingLevel>(scopedKey, thinkingLevel); |
| 60 | } |
| 61 | |
| 62 | const agentId = readPersistedState<string>( |
| 63 | getAgentIdKey(workspaceId), |
| 64 | WORKSPACE_DEFAULTS.agentId |
| 65 | ); |
| 66 | |
| 67 | const providerOptions = getProviderOptions(); |
| 68 | |
| 69 | const disableWorkspaceAgents = readPersistedState<boolean>( |
| 70 | getDisableWorkspaceAgentsKey(workspaceId), |
| 71 | false |
| 72 | ); |
| 73 | |
| 74 | return buildSendMessageOptions({ |
| 75 | model: baseModel, |
| 76 | agentId, |
| 77 | thinkingLevel, |
| 78 | providerOptions, |
| 79 | disableWorkspaceAgents, |
| 80 | experiments: { |
| 81 | programmaticToolCalling: isExperimentEnabled(EXPERIMENT_IDS.PROGRAMMATIC_TOOL_CALLING), |
| 82 | programmaticToolCallingExclusive: isExperimentEnabled( |
| 83 | EXPERIMENT_IDS.PROGRAMMATIC_TOOL_CALLING_EXCLUSIVE |
| 84 | ), |
| 85 | advisorTool: isExperimentEnabled(EXPERIMENT_IDS.ADVISOR_TOOL), |
| 86 | execSubagentHardRestart: isExperimentEnabled(EXPERIMENT_IDS.EXEC_SUBAGENT_HARD_RESTART), |
| 87 | dynamicWorkflows: isExperimentEnabled(EXPERIMENT_IDS.DYNAMIC_WORKFLOWS), |
| 88 | memory: isExperimentEnabled(EXPERIMENT_IDS.MEMORY), |
| 89 | }, |
| 90 | }); |
| 91 | } |
no test coverage detected