fix: satisfy OpenAI tool payload lint · openclaw/openclaw@a656f88
2026-05-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -951,7 +951,7 @@ function convertResponsesTools(
|
951 | 951 | model, |
952 | 952 | }); |
953 | 953 | return sortTransportToolsByName(tools).map((tool): FunctionTool => { |
954 | | -const base = { |
| 954 | +const result = { |
955 | 955 | type: "function" as const, |
956 | 956 | name: tool.name, |
957 | 957 | description: tool.description, |
@@ -960,8 +960,11 @@ function convertResponsesTools(
|
960 | 960 | strict === true, |
961 | 961 | model.compat, |
962 | 962 | ) as Record<string, unknown>, |
963 | | -}; |
964 | | -return strict === undefined ? (base as FunctionTool) : { ...base, strict }; |
| 963 | +} as FunctionTool; |
| 964 | +if (strict !== undefined) { |
| 965 | +result.strict = strict; |
| 966 | +} |
| 967 | +return result; |
965 | 968 | }); |
966 | 969 | } |
967 | 970 | |
@@ -2686,19 +2689,29 @@ function convertTools(
|
2686 | 2689 | model, |
2687 | 2690 | }, |
2688 | 2691 | ); |
2689 | | -return sortTransportToolsByName(tools).map((tool) => ({ |
2690 | | -type: "function", |
2691 | | -function: { |
| 2692 | +return sortTransportToolsByName(tools).map((tool) => { |
| 2693 | +const functionTool: { |
| 2694 | +name: string; |
| 2695 | +description: string | undefined; |
| 2696 | +parameters: ReturnType<typeof normalizeOpenAIStrictToolParameters>; |
| 2697 | +strict?: boolean; |
| 2698 | +} = { |
2692 | 2699 | name: tool.name, |
2693 | 2700 | description: tool.description, |
2694 | 2701 | parameters: normalizeOpenAIStrictToolParameters( |
2695 | 2702 | tool.parameters, |
2696 | 2703 | strict === true, |
2697 | 2704 | model.compat, |
2698 | 2705 | ), |
2699 | | - ...(strict === undefined ? {} : { strict }), |
2700 | | -}, |
2701 | | -})); |
| 2706 | +}; |
| 2707 | +if (strict !== undefined) { |
| 2708 | +functionTool.strict = strict; |
| 2709 | +} |
| 2710 | +return { |
| 2711 | +type: "function", |
| 2712 | +function: functionTool, |
| 2713 | +}; |
| 2714 | +}); |
2702 | 2715 | } |
2703 | 2716 | |
2704 | 2717 | function compareTransportToolText(left: string | undefined, right: string | undefined): number { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。