Skip to content

Ensure follow-up messages have content#129

Merged
kzu merged 2 commits intomainfrom
dev/emptycontent
Apr 30, 2026
Merged

Ensure follow-up messages have content#129
kzu merged 2 commits intomainfrom
dev/emptycontent

Conversation

@kzu
Copy link
Copy Markdown
Member

@kzu kzu commented Apr 30, 2026

The Grok API rejects messages without content elements, even with tool calls. Added EnsureContentElement() to insert placeholder space where messages have tool calls or reasoning metadata but no content. Fixes regression where assistant follow-up messages after tool invocation would fail with: 'StatusCode=InvalidArgument, Detail=Each message must have at least one content element.'

…ntent

The Grok API rejects messages without content elements, even with tool calls.
Added EnsureContentElement() to insert placeholder space where messages have
tool calls or reasoning metadata but no content. Fixes regression where
assistant follow-up messages after tool invocation would fail with:
'StatusCode=InvalidArgument, Detail=Each message must have at least one content element.'
@kzu kzu added the bug Something isn't working label Apr 30, 2026
@kzu kzu enabled auto-merge (rebase) April 30, 2026 02:18
@kzu
Copy link
Copy Markdown
Member Author

kzu commented Apr 30, 2026

43 passed 43 passed 35 skipped

🧪 Details on Ubuntu 24.04.4 LTS

from retest v1.1.0 on .NET 10.0.7 with 💜 by @devlooped

…ce behavior

xAI now rejects requests that set ToolChoice when no tools are present in
the request. The production code was already updated to gate ToolChoice on
request.Tools.Count > 0, but the five AsCompletionsRequest_*ToolMode* tests
were still passing an empty tools list and asserting ToolChoice was set.

Changes:
- Add DummyTool() helper that creates a minimal AIFunction for use in tests
- Add Tools = [DummyTool()] to all ToolMode tests so ToolChoice gets set
- Add AsCompletionsRequest_NoTools_DoesNotSetToolChoice to explicitly document
  and verify the new behavior: no tools => no ToolChoice, regardless of ToolMode
@kzu kzu disabled auto-merge April 30, 2026 02:22
@kzu kzu enabled auto-merge (rebase) April 30, 2026 02:22
@kzu kzu merged commit 7ac1465 into main Apr 30, 2026
4 checks passed
@kzu kzu deleted the dev/emptycontent branch April 30, 2026 02:23
@kzu kzu changed the title Fix GrokStreamsUpdatesFromAllTools: ensure follow-up messages have content Ensure follow-up messages have content Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant