Skip to content

Commit afbbde9

Browse files
committed
fix(tarko-cli): --thinking does not work
feat(tarko-agent): add `thinking` option type check feat(tarko-cli): correctly handle thinking option
1 parent 7bcff07 commit afbbde9

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

multimodal/tarko/agent-cli/src/config/builder.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export function buildAppConfig<
7070
apiKey,
7171
baseURL,
7272
shareProvider,
73+
thinking,
7374
// Extract tool filter options
7475
tool,
7576
// Extract MCP server filter options
@@ -80,7 +81,13 @@ export function buildAppConfig<
8081
} = cliArguments;
8182

8283
// Handle deprecated options
83-
const deprecatedOptions = { provider, apiKey: apiKey || undefined, baseURL, shareProvider }; // secretlint-disable-line @secretlint/secretlint-rule-pattern
84+
const deprecatedOptions = {
85+
provider,
86+
apiKey: apiKey || undefined,
87+
baseURL,
88+
shareProvider,
89+
thinking,
90+
}; // secretlint-disable-line @secretlint/secretlint-rule-pattern
8491
const deprecatedKeys = Object.entries(deprecatedOptions)
8592
.filter(([, value]) => value !== undefined)
8693
.map(([optionName]) => optionName);
@@ -132,9 +139,10 @@ function handleCoreDeprecatedOptions(
132139
apiKey?: string;
133140
baseURL?: string;
134141
shareProvider?: string;
142+
thinking?: boolean;
135143
},
136144
): void {
137-
const { provider, apiKey: deprecatedApiKey, baseURL, shareProvider } = deprecated; // secretlint-disable-line @secretlint/secretlint-rule-pattern
145+
const { provider, apiKey: deprecatedApiKey, baseURL, shareProvider, thinking } = deprecated; // secretlint-disable-line @secretlint/secretlint-rule-pattern
138146

139147
// Handle deprecated model configuration
140148
if (provider || deprecatedApiKey || baseURL) {
@@ -171,6 +179,19 @@ function handleCoreDeprecatedOptions(
171179
config.share.provider = shareProvider;
172180
}
173181
}
182+
183+
if (thinking) {
184+
if (typeof thinking === 'boolean') {
185+
config.thinking = {
186+
type: thinking ? 'enabled' : 'disabled',
187+
};
188+
} else if (typeof thinking === 'object') {
189+
config.thinking = {
190+
type: 'disabled',
191+
...(config.thinking || {}),
192+
};
193+
}
194+
}
174195
}
175196

176197
/**

multimodal/tarko/agent/src/agent/agent.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,17 @@ export class Agent<T extends AgentOptions = AgentOptions>
140140

141141
this.temperature = options.temperature ?? 0.7;
142142
this.top_p = options.top_p;
143-
this.reasoningOptions = options.thinking ?? { type: 'disabled' };
143+
144+
if (options.thinking) {
145+
if (typeof options.thinking !== 'object') {
146+
throw new Error(
147+
`Invalid thinking option, expected an object, but got ${JSON.stringify(options.thinking)}`,
148+
);
149+
}
150+
this.reasoningOptions = { type: 'disabled' };
151+
} else {
152+
this.reasoningOptions = { type: 'disabled' };
153+
}
144154

145155
// Initialize the resolved model early if possible
146156
this.initializeEarlyResolvedModel();

multimodal/tarko/interface/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type AgentCLIArguments = Pick<
2626
apiKey?: string;
2727
baseURL?: string;
2828
shareProvider?: string;
29+
thinking?: boolean;
2930

3031
/** Configuration file paths or URLs */
3132
config?: string[];

0 commit comments

Comments
 (0)