mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:37:38 +00:00
fix(tools): correct Grok response parsing for xAI Responses API (#13049)
* fix(tools): correct Grok response parsing for xAI Responses API The xAI Responses API returns content in output[0].content[0].text, not in output_text field. Updated GrokSearchResponse type and runGrokSearch to extract content from the correct path. Fixes the 'No response' issue when using Grok web search. * fix(tools): harden Grok web_search parsing (#13049) (thanks @ereid7) --------- Co-authored-by: erai <erai@erais-Mac-mini.local> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ const {
|
||||
resolveGrokApiKey,
|
||||
resolveGrokModel,
|
||||
resolveGrokInlineCitations,
|
||||
extractGrokContent,
|
||||
} = __testing;
|
||||
|
||||
describe("web_search perplexity baseUrl defaults", () => {
|
||||
@@ -142,3 +143,23 @@ describe("web_search grok config resolution", () => {
|
||||
expect(resolveGrokInlineCitations({ inlineCitations: false })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("web_search grok response parsing", () => {
|
||||
it("extracts content from Responses API output blocks", () => {
|
||||
expect(
|
||||
extractGrokContent({
|
||||
output: [
|
||||
{
|
||||
content: [{ text: "hello from output" }],
|
||||
},
|
||||
],
|
||||
}),
|
||||
).toBe("hello from output");
|
||||
});
|
||||
|
||||
it("falls back to deprecated output_text", () => {
|
||||
expect(extractGrokContent({ output_text: "hello from output_text" })).toBe(
|
||||
"hello from output_text",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user