fix(kiro): honor thinking effort budgets
Resolve the Kiro thinking budget from client intent (OpenAI reasoning_effort, OpenAI Responses reasoning.effort, Claude output_config.effort, and Claude thinking.budget_tokens) by reusing the shared thinkingUnified extractThinking parser, then inject the resolved budget into the Kiro thinking system prefix. Explicit none/off/disabled stops the prefix injection; synthetic -thinking aliases keep the default budget. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -27,7 +27,7 @@ import { FORMATS } from "../formats.js";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import {
|
||||
resolveKiroModel,
|
||||
isThinkingEnabled,
|
||||
resolveKiroThinkingBudget,
|
||||
buildThinkingSystemPrefix,
|
||||
KIRO_AGENTIC_SYSTEM_PROMPT,
|
||||
resolveDefaultProfileArn,
|
||||
@@ -374,13 +374,8 @@ export function claudeToKiroRequest(model, body, stream, credentials) {
|
||||
const temperature = body.temperature;
|
||||
const topP = body.top_p;
|
||||
|
||||
const {
|
||||
upstream: upstreamModel,
|
||||
agentic,
|
||||
thinking: modelImpliesThinking,
|
||||
} = resolveKiroModel(model);
|
||||
const thinkingEnabled =
|
||||
modelImpliesThinking || isThinkingEnabled(body, null, model);
|
||||
const { upstream: upstreamModel, agentic } = resolveKiroModel(model);
|
||||
const thinkingBudget = resolveKiroThinkingBudget(body, credentials?.rawHeaders, model);
|
||||
|
||||
// Guard 1: no client tools → flatten all tool interactions to text.
|
||||
if (!clientProvidedTools) {
|
||||
@@ -420,7 +415,7 @@ export function claudeToKiroRequest(model, body, stream, credentials) {
|
||||
// Prefix order: thinking_mode tag, timestamp marker, then agentic prompt.
|
||||
const timestamp = new Date().toISOString();
|
||||
const prefixParts = [];
|
||||
if (thinkingEnabled) prefixParts.push(buildThinkingSystemPrefix());
|
||||
if (thinkingBudget !== null) prefixParts.push(buildThinkingSystemPrefix(thinkingBudget));
|
||||
prefixParts.push(`[Context: Current time is ${timestamp}]`);
|
||||
if (agentic) prefixParts.push(KIRO_AGENTIC_SYSTEM_PROMPT);
|
||||
finalContent = `${prefixParts.join("\n\n")}\n\n${finalContent}`;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { v4 as uuidv4 } from "uuid";
|
||||
import { resolveSessionId } from "../../utils/sessionManager.js";
|
||||
import {
|
||||
resolveKiroModel,
|
||||
isThinkingEnabled,
|
||||
resolveKiroThinkingBudget,
|
||||
buildThinkingSystemPrefix,
|
||||
KIRO_AGENTIC_SYSTEM_PROMPT,
|
||||
resolveDefaultProfileArn
|
||||
@@ -519,8 +519,8 @@ export function openaiToKiroRequest(model, body, stream, credentials) {
|
||||
const temperature = body.temperature;
|
||||
const topP = body.top_p;
|
||||
|
||||
const { upstream: upstreamModel, agentic, thinking: modelImpliesThinking } = resolveKiroModel(model);
|
||||
const thinkingEnabled = modelImpliesThinking || isThinkingEnabled(body, null, model);
|
||||
const { upstream: upstreamModel, agentic } = resolveKiroModel(model);
|
||||
const thinkingBudget = resolveKiroThinkingBudget(body, credentials?.rawHeaders, model);
|
||||
|
||||
const { history, currentMessage } = convertMessages(messages, tools, upstreamModel);
|
||||
|
||||
@@ -543,8 +543,8 @@ export function openaiToKiroRequest(model, body, stream, credentials) {
|
||||
// Order: thinking_mode tag first (so Kiro sees it before any user text),
|
||||
// then context/timestamp marker, then optional agentic chunked-write prompt.
|
||||
const prefixParts = [];
|
||||
if (thinkingEnabled) {
|
||||
prefixParts.push(buildThinkingSystemPrefix());
|
||||
if (thinkingBudget !== null) {
|
||||
prefixParts.push(buildThinkingSystemPrefix(thinkingBudget));
|
||||
}
|
||||
prefixParts.push(`[Context: Current time is ${timestamp}]`);
|
||||
if (agentic) {
|
||||
|
||||
Reference in New Issue
Block a user