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>
This commit is contained in:
@@ -165,6 +165,7 @@ export class OpenAIClient implements LLMClient {
|
|||||||
// Validate with schema
|
// Validate with schema
|
||||||
const validation = tool.inputSchema.safeParse(parsedArgs)
|
const validation = tool.inputSchema.safeParse(parsedArgs)
|
||||||
if (!validation.success) {
|
if (!validation.success) {
|
||||||
|
console.error(validation.error)
|
||||||
throw new InvokeError(
|
throw new InvokeError(
|
||||||
InvokeErrorType.INVALID_TOOL_ARGS,
|
InvokeErrorType.INVALID_TOOL_ARGS,
|
||||||
'Tool arguments validation failed',
|
'Tool arguments validation failed',
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ export function modelPatch(body: Record<string, any>) {
|
|||||||
|
|
||||||
const modelName = normalizeModelName(model)
|
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')) {
|
if (modelName.startsWith('claude')) {
|
||||||
debug('Applying Claude patch: disable thinking')
|
debug('Applying Claude patch: disable thinking')
|
||||||
body.thinking = { type: 'disabled' }
|
body.thinking = { type: 'disabled' }
|
||||||
|
|||||||
@@ -305,6 +305,7 @@ export class PageAgent extends EventTarget {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
description: 'You MUST call this tool every step. Outputs your reflections and next action.',
|
||||||
inputSchema: macroToolSchema as zod.ZodType<MacroToolInput>,
|
inputSchema: macroToolSchema as zod.ZodType<MacroToolInput>,
|
||||||
execute: async (input: MacroToolInput): Promise<MacroToolResult> => {
|
execute: async (input: MacroToolInput): Promise<MacroToolResult> => {
|
||||||
// abort
|
// abort
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ export function normalizeResponse(response: any): any {
|
|||||||
|
|
||||||
// fix double stringified arguments
|
// fix double stringified arguments
|
||||||
resolvedArguments = safeJsonParse(resolvedArguments)
|
resolvedArguments = safeJsonParse(resolvedArguments)
|
||||||
|
if (resolvedArguments.action) {
|
||||||
|
resolvedArguments.action = safeJsonParse(resolvedArguments.action)
|
||||||
|
}
|
||||||
|
|
||||||
// fix incomplete formats
|
// fix incomplete formats
|
||||||
if (!resolvedArguments.action) {
|
if (!resolvedArguments.action) {
|
||||||
|
|||||||
Reference in New Issue
Block a user