fix(ai): remove <thinking> tag wrapping, convert to plain text on cross-model handoff

- Remove <thinking> tag generation from google-shared.ts, transorm-messages.ts, openai-completions.ts
- Thinking blocks now convert to plain text when switching models (prevents models mimicking tags)
- Skip empty thinking blocks to avoid API errors
- Keep thinking blocks only when same provider AND same model

fixes #561
This commit is contained in:
Mario Zechner
2026-01-08 21:19:16 +01:00
parent 8fda948866
commit 16e142ef7d
5 changed files with 17 additions and 12 deletions
@@ -45,12 +45,13 @@ export function transformMessages<TApi extends Api>(messages: Message[], model:
assistantMsg.api !== model.api;
// Transform message from different provider/model
const transformedContent = assistantMsg.content.map((block) => {
const transformedContent = assistantMsg.content.flatMap((block) => {
if (block.type === "thinking") {
// Convert thinking block to text block with <thinking> tags
// Skip empty thinking blocks, convert others to plain text
if (!block.thinking || block.thinking.trim() === "") return [];
return {
type: "text" as const,
text: `<thinking>\n${block.thinking}\n</thinking>`,
text: block.thinking,
};
}
// Normalize tool call IDs for github-copilot cross-API switches