From 3fa7c8b85aa8ab91f92098bd9634e7a578f978c4 Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Tue, 13 Jan 2026 15:04:03 +0800 Subject: [PATCH] feat: improve qwen3 compatibility (#106) * feat: improve qwen3 compatibility * fix: qwen Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/llms/src/OpenAIClient.ts | 1 + packages/llms/src/utils.ts | 5 +++++ packages/page-agent/src/PageAgent.ts | 1 + packages/page-agent/src/utils/autoFixer.ts | 3 +++ 4 files changed, 10 insertions(+) diff --git a/packages/llms/src/OpenAIClient.ts b/packages/llms/src/OpenAIClient.ts index 9fe44b9..72dfd56 100644 --- a/packages/llms/src/OpenAIClient.ts +++ b/packages/llms/src/OpenAIClient.ts @@ -165,6 +165,7 @@ export class OpenAIClient implements LLMClient { // Validate with schema const validation = tool.inputSchema.safeParse(parsedArgs) if (!validation.success) { + console.error(validation.error) throw new InvokeError( InvokeErrorType.INVALID_TOOL_ARGS, 'Tool arguments validation failed', diff --git a/packages/llms/src/utils.ts b/packages/llms/src/utils.ts index 9b192d7..5863e21 100644 --- a/packages/llms/src/utils.ts +++ b/packages/llms/src/utils.ts @@ -34,6 +34,11 @@ export function modelPatch(body: Record) { const modelName = normalizeModelName(model) + if (modelName.startsWith('qwen3')) { + debug('Applying Qwen-3 patch: use higher temperature for auto fixing') + body.temperature = Math.max(body.temperature || 0, 1.0) + } + if (modelName.startsWith('claude')) { debug('Applying Claude patch: disable thinking') body.thinking = { type: 'disabled' } diff --git a/packages/page-agent/src/PageAgent.ts b/packages/page-agent/src/PageAgent.ts index 78b607e..c50f422 100644 --- a/packages/page-agent/src/PageAgent.ts +++ b/packages/page-agent/src/PageAgent.ts @@ -305,6 +305,7 @@ export class PageAgent extends EventTarget { }) return { + description: 'You MUST call this tool every step. Outputs your reflections and next action.', inputSchema: macroToolSchema as zod.ZodType, execute: async (input: MacroToolInput): Promise => { // abort diff --git a/packages/page-agent/src/utils/autoFixer.ts b/packages/page-agent/src/utils/autoFixer.ts index 698b36f..9e8838e 100644 --- a/packages/page-agent/src/utils/autoFixer.ts +++ b/packages/page-agent/src/utils/autoFixer.ts @@ -74,6 +74,9 @@ export function normalizeResponse(response: any): any { // fix double stringified arguments resolvedArguments = safeJsonParse(resolvedArguments) + if (resolvedArguments.action) { + resolvedArguments.action = safeJsonParse(resolvedArguments.action) + } // fix incomplete formats if (!resolvedArguments.action) {