fix(llm): GPT-5 needs max_completion_tokens; bump xAI default to grok-4.3#31
Merged
Merged
Conversation
…-4.3 Live smoke test of the multi-LLM path (PR #27) caught two real issues that the type system + factory tests didn't. ## Bug — OpenAI completion fails with 400 on GPT-5 GPT-5 (and the o-series) rejects the legacy `max_tokens` field with: 400 Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead. The OpenAI SDK passes the field through unmodified, so `LlmClient` needed to send the right name. xAI's OpenAI-compatible API still uses `max_tokens` though, so the fix branches on provider flavor: - provider === 'openai' → max_completion_tokens - provider === 'xai' → max_tokens (unchanged) End-to-end smoke tests now green for both providers: [1] factory: openai / gpt-5 [3] tool-use stop: tool_use, 1 tool call → get_time [4] tool-result roundtrip: "It's 07:00 UTC..." [1] factory: xai / grok-4.3 [2] text stop: end_turn, "verified" in 1 token [3] tool-use: 1 call to get_time [4] roundtrip: "The current time is 2026-05-22T07:00:00Z" Note for operators on GPT-5: the model uses internal reasoning tokens that count against `max_tokens`. With a tight ceiling (say 30) it may return empty content with stop_reason=max_tokens. The default 4096 is fine; just don't lower it aggressively when using gpt-5. ## Default model bump — grok-3-latest → grok-4.3 xAI released grok-4.3 since we shipped 0.5.0; updating the default gives new operators the current generation. Existing users who set AGENT_MODEL=grok-3-latest explicitly are unaffected. Updated in: - openclaw/starter/agent/src/llm/types.ts (DEFAULT_MODELS.xai) - README + QUICKSTART tables across all surfaces - start.sh help text (3 occurrences per file) ## Versions @xpr-agents/openclaw → 0.5.2 (patch — fix only) create-xpr-agent → 0.7.2 (patch — model default in scaffold) ## What's still untested Gemini path is in code but unverified end-to-end (no key available during this session). Most-different SDK + message shape of the four impls; treat as "best-effort" until someone exercises it with a real key. The structural code path matches the OpenAI one, but Gemini's `functionResponse` part shape + 'function' role for tool results is unique to that impl. ## Verification - 80 openclaw tests pass - Agent runner builds clean (tsc no errors) - Frontend rebuild clean (all 13 routes prerendered) - OpenAI smoke test (gpt-5): factory + text + tool-use + tool-result roundtrip ✓ - xAI smoke test (grok-4.3): same four checkpoints ✓
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Live smoke test of the multi-LLM path (PR #27) caught two real issues that the type system + factory tests didn't.
Bug — OpenAI completion fails with 400 on GPT-5
GPT-5 / o-series reject
max_tokenswith:xAI's OpenAI-compatible API still uses
max_tokens. Fix branches on provider flavor:provider === 'openai'→max_completion_tokensprovider === 'xai'→max_tokens(unchanged)End-to-end smoke tests now GREEN for both providers
OpenAI / gpt-5:
get_timexAI / grok-4.3:
end_turnDefault model bump — grok-3-latest → grok-4.3
xAI released grok-4.3 since we shipped 0.5.0; the default now picks it up. Operators with
AGENT_MODEL=grok-3-latestexplicit are unaffected.What's still untested
Gemini path is in code but unverified end-to-end (no key available during this session). Treat as "best-effort" until exercised.
Versions
@xpr-agents/openclaw→ 0.5.2 (patch)create-xpr-agent→ 0.7.2 (patch)Verification