fix(agent): resolve reasoningMode from profile config and session meta
- Read reasoningMode from profile config and storedMeta when not explicitly set via options (matching thinkingLevel pattern) - Skip extractThinking() call when reasoningMode is "off" - Clean up redundant ?? undefined casts in CLI entry points Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
953a29672a
commit
8fe2b5f010
5 changed files with 19 additions and 6 deletions
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import { Agent } from "../../runner.js";
|
||||
import type { AgentOptions } from "../../types.js";
|
||||
import type { ToolsConfig } from "../../tools/policy.js";
|
||||
import { cyan, yellow, dim } from "../colors.js";
|
||||
|
||||
|
|
@ -198,7 +199,7 @@ export async function runCommand(args: string[]): Promise<void> {
|
|||
baseUrl: opts.baseUrl,
|
||||
systemPrompt: opts.system,
|
||||
thinkingLevel: opts.thinking as any,
|
||||
reasoningMode: (opts.reasoning as any) ?? undefined,
|
||||
reasoningMode: opts.reasoning as AgentOptions["reasoningMode"],
|
||||
cwd: opts.cwd,
|
||||
sessionId: opts.session,
|
||||
debug: opts.debug,
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ class InteractiveCLI {
|
|||
model: this.opts.model,
|
||||
systemPrompt: this.opts.system,
|
||||
thinkingLevel: this.opts.thinking as AgentOptions["thinkingLevel"],
|
||||
reasoningMode: (this.opts.reasoning as AgentOptions["reasoningMode"]) ?? undefined,
|
||||
reasoningMode: this.opts.reasoning as AgentOptions["reasoningMode"],
|
||||
cwd: this.opts.cwd,
|
||||
sessionId,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ async function main() {
|
|||
baseUrl: opts.baseUrl,
|
||||
systemPrompt: opts.system,
|
||||
thinkingLevel: opts.thinking as any,
|
||||
reasoningMode: (opts.reasoning as any) ?? undefined,
|
||||
reasoningMode: opts.reasoning as any,
|
||||
cwd: opts.cwd,
|
||||
sessionId: opts.session,
|
||||
debug: opts.debug,
|
||||
|
|
|
|||
|
|
@ -249,8 +249,8 @@ export function createAgentOutput(params: {
|
|||
state.streaming = false;
|
||||
state.lastAssistantText = text;
|
||||
|
||||
// Extract and store thinking content
|
||||
const thinking = extractThinking(msg);
|
||||
// Extract and store thinking content (skip when off)
|
||||
const thinking = reasoningMode !== "off" ? extractThinking(msg) : "";
|
||||
state.lastAssistantThinking = thinking;
|
||||
|
||||
// Show thinking at end for "on" mode
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export class Agent {
|
|||
private readonly skillManager?: SkillManager;
|
||||
private readonly contextWindowGuard: ContextWindowGuardResult;
|
||||
private readonly debug: boolean;
|
||||
private readonly reasoningMode: ReasoningMode;
|
||||
private reasoningMode: ReasoningMode;
|
||||
private toolsOptions: AgentOptions;
|
||||
private readonly originalToolsConfig?: ToolsConfig;
|
||||
private readonly stderr: NodeJS.WritableStream;
|
||||
|
|
@ -267,6 +267,18 @@ export class Agent {
|
|||
this.agent.setThinkingLevel(options.thinkingLevel);
|
||||
}
|
||||
|
||||
// Resolve reasoningMode: options > profile config > storedMeta > default "stream"
|
||||
if (!options.reasoningMode) {
|
||||
const profileReasoningMode = this.profile?.getProfile()?.config?.reasoningMode;
|
||||
const metaReasoningMode = storedMeta?.reasoningMode as ReasoningMode | undefined;
|
||||
const resolved = profileReasoningMode ?? metaReasoningMode ?? "stream";
|
||||
if (resolved !== this.reasoningMode) {
|
||||
this.reasoningMode = resolved;
|
||||
// Re-create output with correct reasoningMode
|
||||
this.output = createAgentOutput({ stdout, stderr: this.stderr, reasoningMode: this.reasoningMode });
|
||||
}
|
||||
}
|
||||
|
||||
this.agent.setModel(model);
|
||||
|
||||
// Save original tools config from options (for later merging during reload)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue