mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
feat(auto-mode): skip memory extraction when Claude not configured and add reasoning effort support
- Skip learning extraction when ANTHROPIC_API_KEY is not available - Add reasoningEffort parameter to simpleQuery for Codex model configuration - Add stdinData support to spawnProcess for CLI stdin input - Update UI API types for model override with reasoning support
This commit is contained in:
@@ -15,7 +15,13 @@
|
||||
*/
|
||||
|
||||
import { ProviderFactory } from './provider-factory.js';
|
||||
import type { ProviderMessage, ContentBlock, ThinkingLevel } from '@automaker/types';
|
||||
import type {
|
||||
ProviderMessage,
|
||||
ContentBlock,
|
||||
ThinkingLevel,
|
||||
ReasoningEffort,
|
||||
} from '@automaker/types';
|
||||
import { stripProviderPrefix } from '@automaker/types';
|
||||
|
||||
/**
|
||||
* Options for simple query execution
|
||||
@@ -42,6 +48,8 @@ export interface SimpleQueryOptions {
|
||||
};
|
||||
/** Thinking level for Claude models */
|
||||
thinkingLevel?: ThinkingLevel;
|
||||
/** Reasoning effort for Codex/OpenAI models */
|
||||
reasoningEffort?: ReasoningEffort;
|
||||
/** If true, runs in read-only mode (no file writes) */
|
||||
readOnly?: boolean;
|
||||
/** Setting sources for CLAUDE.md loading */
|
||||
@@ -97,6 +105,7 @@ const DEFAULT_MODEL = 'claude-sonnet-4-20250514';
|
||||
export async function simpleQuery(options: SimpleQueryOptions): Promise<SimpleQueryResult> {
|
||||
const model = options.model || DEFAULT_MODEL;
|
||||
const provider = ProviderFactory.getProviderForModel(model);
|
||||
const bareModel = stripProviderPrefix(model);
|
||||
|
||||
let responseText = '';
|
||||
let structuredOutput: Record<string, unknown> | undefined;
|
||||
@@ -104,7 +113,8 @@ export async function simpleQuery(options: SimpleQueryOptions): Promise<SimpleQu
|
||||
// Build provider options
|
||||
const providerOptions = {
|
||||
prompt: options.prompt,
|
||||
model: model,
|
||||
model: bareModel,
|
||||
originalModel: model,
|
||||
cwd: options.cwd,
|
||||
systemPrompt: options.systemPrompt,
|
||||
maxTurns: options.maxTurns ?? 1,
|
||||
@@ -112,6 +122,7 @@ export async function simpleQuery(options: SimpleQueryOptions): Promise<SimpleQu
|
||||
abortController: options.abortController,
|
||||
outputFormat: options.outputFormat,
|
||||
thinkingLevel: options.thinkingLevel,
|
||||
reasoningEffort: options.reasoningEffort,
|
||||
readOnly: options.readOnly,
|
||||
settingSources: options.settingSources,
|
||||
};
|
||||
@@ -176,6 +187,7 @@ export async function simpleQuery(options: SimpleQueryOptions): Promise<SimpleQu
|
||||
export async function streamingQuery(options: StreamingQueryOptions): Promise<SimpleQueryResult> {
|
||||
const model = options.model || DEFAULT_MODEL;
|
||||
const provider = ProviderFactory.getProviderForModel(model);
|
||||
const bareModel = stripProviderPrefix(model);
|
||||
|
||||
let responseText = '';
|
||||
let structuredOutput: Record<string, unknown> | undefined;
|
||||
@@ -183,7 +195,8 @@ export async function streamingQuery(options: StreamingQueryOptions): Promise<Si
|
||||
// Build provider options
|
||||
const providerOptions = {
|
||||
prompt: options.prompt,
|
||||
model: model,
|
||||
model: bareModel,
|
||||
originalModel: model,
|
||||
cwd: options.cwd,
|
||||
systemPrompt: options.systemPrompt,
|
||||
maxTurns: options.maxTurns ?? 250,
|
||||
@@ -191,6 +204,7 @@ export async function streamingQuery(options: StreamingQueryOptions): Promise<Si
|
||||
abortController: options.abortController,
|
||||
outputFormat: options.outputFormat,
|
||||
thinkingLevel: options.thinkingLevel,
|
||||
reasoningEffort: options.reasoningEffort,
|
||||
readOnly: options.readOnly,
|
||||
settingSources: options.settingSources,
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ import type {
|
||||
ThinkingLevel,
|
||||
PlanningMode,
|
||||
} from '@automaker/types';
|
||||
import { DEFAULT_PHASE_MODELS, stripProviderPrefix } from '@automaker/types';
|
||||
import { DEFAULT_PHASE_MODELS, isClaudeModel, stripProviderPrefix } from '@automaker/types';
|
||||
import {
|
||||
buildPromptWithImages,
|
||||
classifyError,
|
||||
@@ -3586,10 +3586,29 @@ If nothing notable: {"learnings": []}`;
|
||||
const phaseModelEntry =
|
||||
settings?.phaseModels?.memoryExtractionModel || DEFAULT_PHASE_MODELS.memoryExtractionModel;
|
||||
const { model } = resolvePhaseModel(phaseModelEntry);
|
||||
const hasClaudeKey = Boolean(process.env.ANTHROPIC_API_KEY);
|
||||
let resolvedModel = model;
|
||||
|
||||
if (isClaudeModel(model) && !hasClaudeKey) {
|
||||
const fallbackModel = feature.model
|
||||
? resolveModelString(feature.model, DEFAULT_MODELS.claude)
|
||||
: null;
|
||||
if (fallbackModel && !isClaudeModel(fallbackModel)) {
|
||||
console.log(
|
||||
`[AutoMode] Claude not configured for memory extraction; using feature model "${fallbackModel}".`
|
||||
);
|
||||
resolvedModel = fallbackModel;
|
||||
} else {
|
||||
console.log(
|
||||
'[AutoMode] Claude not configured for memory extraction; skipping learning extraction.'
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const result = await simpleQuery({
|
||||
prompt: userPrompt,
|
||||
model,
|
||||
model: resolvedModel,
|
||||
cwd: projectPath,
|
||||
maxTurns: 1,
|
||||
allowedTools: [],
|
||||
|
||||
Reference in New Issue
Block a user