Skip to content

feat(xai): add first-class xai-oauth provider + correct base grok-4.3 context length (512k)#1

Open
am423 wants to merge 2 commits into
mainfrom
feat/xai-oauth-grok-support
Open

feat(xai): add first-class xai-oauth provider + correct base grok-4.3 context length (512k)#1
am423 wants to merge 2 commits into
mainfrom
feat/xai-oauth-grok-support

Conversation

@am423
Copy link
Copy Markdown
Owner

@am423 am423 commented May 15, 2026

Summary

Adds proper first-class support for using Grok models via the official Grok CLI OAuth login (xai-oauth).

This fixes the "response.created before error" issue for users who use grok login credentials in Hermes.

Key Changes

  • New plugin: plugins/model-providers/xai-oauth/
  • Runtime resolution forces chat_completions for OAuth tokens
  • x-grok-conv-id header support on chat_completions transport
  • Correct context length (base grok-4.3 = 512k)
  • New dedicated guide: website/docs/guides/grok-oauth.md
  • Updated public docs + test + AGENTS.md guidance

Testing

  • New test passes
  • Manual verification with real Grok CLI credentials successful

Ready for review.

am423 added 2 commits May 14, 2026 22:03
… context length (512k)

This PR introduces proper first-class support for using Grok models
via the official Grok CLI OAuth login (xai-oauth).

### Changes
- New model provider plugin: plugins/model-providers/xai-oauth/
- Runtime resolution forces chat_completions for OAuth tokens (prevents
  the 'response.created before error' failure on the Responses API)
- x-grok-conv-id header is now sent on the chat_completions transport
  for any *.x.ai endpoint (enables prompt caching for OAuth users)
- Correct context length fallbacks: base grok-4.3 = 512k,
  grok-4.3-fast and newer variants = 2M
- Comprehensive README with setup, troubleshooting, and context notes
- Updated public documentation (providers.md) to clearly document both
  xai-oauth and xai paths
- Added regression test for xai-oauth runtime resolution
- Added contributor guidance in AGENTS.md for OAuth model providers

This enables reliable, zero-config use of grok-4.3 (and other Grok models)
for users who already authenticate via the official Grok CLI.
- New guide: website/docs/guides/grok-oauth.md (setup, context notes, troubleshooting, comparison with xai provider)
- Updated integrations/providers.md to link to the new guide and clearly document both xai-oauth and xai paths
@am423 am423 added feature New feature or request provider Model provider related xai xAI / Grok related documentation Improvements or additions to documentation tests Test additions or changes labels May 15, 2026
@am423
Copy link
Copy Markdown
Owner Author

am423 commented May 15, 2026

PR Overview

This adds proper xai-oauth support so people who use the official Grok CLI can have a first-class experience in Hermes without needing a separate XAI_API_KEY.

Scope

  • Runtime safety (prevents Responses API misuse with OAuth tokens)
  • Prompt caching support on the chat_completions path
  • Correct context length handling for base vs fast Grok-4.3 variants
  • Full documentation (new dedicated guide + updates)
  • Test coverage + contributor notes in AGENTS.md

Review Focus Areas

  • Runtime resolution logic in hermes_cli/runtime_provider.py
  • Header injection in agent/transports/chat_completions.py
  • Context length fallbacks in agent/model_metadata.py
  • New guide quality (website/docs/guides/grok-oauth.md)

Happy to address any feedback quickly. Thanks!

@github-actions
Copy link
Copy Markdown

🔎 Lint report: feat/xai-oauth-grok-support vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8341 on HEAD, 8340 on base (🆕 +1)

🆕 New issues (4):

Rule Count
invalid-argument-type 3
unresolved-import 1
First entries
run_agent.py:13711: [invalid-argument-type] invalid-argument-type: Argument to function `_is_oauth_token` is incorrect: Expected `str`, found `str | dict[Unknown | str, Unknown | str | dict[str, str]] | Any | ... omitted 3 union elements`
run_agent.py:7480: [invalid-argument-type] invalid-argument-type: Argument to function `build_anthropic_client` is incorrect: Expected `str`, found `str | dict[Unknown | str, Unknown | str | dict[str, str]] | Any | ... omitted 3 union elements`
run_agent.py:13714: [invalid-argument-type] invalid-argument-type: Argument to function `len` is incorrect: Expected `Sized`, found `(str & ~AlwaysFalsy) | (dict[Unknown | str, Unknown | str | dict[str, str]] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | ... omitted 3 union elements`
hermes_cli/runtime_provider.py:288: [unresolved-import] unresolved-import: Module `hermes_cli.auth` has no member `resolve_xai_oauth_runtime_credentials`

✅ Fixed issues (3):

Rule Count
invalid-argument-type 3
First entries
run_agent.py:7480: [invalid-argument-type] invalid-argument-type: Argument to function `build_anthropic_client` is incorrect: Expected `str`, found `str | dict[Unknown, Unknown] | Any | ... omitted 3 union elements`
run_agent.py:13714: [invalid-argument-type] invalid-argument-type: Argument to function `len` is incorrect: Expected `Sized`, found `(str & ~AlwaysFalsy) | (dict[Unknown, Unknown] & ~AlwaysFalsy) | (Any & ~AlwaysFalsy) | ... omitted 3 union elements`
run_agent.py:13711: [invalid-argument-type] invalid-argument-type: Argument to function `_is_oauth_token` is incorrect: Expected `str`, found `str | dict[Unknown, Unknown] | Any | ... omitted 3 union elements`

Unchanged: 4385 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature New feature or request provider Model provider related tests Test additions or changes xai xAI / Grok related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant