Skip to content

feat: add Claude 4.6 models and fix OpenClaw 422 validation errors#39

Closed
bhargav18 wants to merge 1 commit intoRichardAtCT:mainfrom
bhargav18:feat/claude-4-6-openclaw-compat
Closed

feat: add Claude 4.6 models and fix OpenClaw 422 validation errors#39
bhargav18 wants to merge 1 commit intoRichardAtCT:mainfrom
bhargav18:feat/claude-4-6-openclaw-compat

Conversation

@bhargav18
Copy link

@bhargav18 bhargav18 commented Feb 28, 2026

Summary

  • Add claude-sonnet-4-6 and claude-opus-4-6 to CLAUDE_MODELS and set claude-sonnet-4-6 as the new DEFAULT_MODEL
  • Fix 422 validation errors when using OpenClaw as a client by accepting role: 'tool' messages, null content, and arbitrary content block types
  • Add model_config extra='ignore' to silently drop unknown fields (e.g. store, service_tier) sent by OpenClaw

Changes

src/constants.py

  • Added Claude 4.6 models (claude-sonnet-4-6, claude-opus-4-6) at the top of CLAUDE_MODELS
  • Updated DEFAULT_MODEL from claude-sonnet-4-5-20250929 to claude-sonnet-4-6

src/models.py

  • Message.role: added "tool" to allowed roles — OpenClaw sends tool result messages with role: "tool"
  • Message.content: changed to Optional[Union[str, List[Any]]] to handle null content (assistant messages mid-tool-call) and arbitrary content block arrays
  • ContentPart: loosened type from Literal["text"] to str and made text optional to handle non-text block types (tool_use, tool_result, image, etc.)
  • normalize_content: added null handling and text extraction from tool_result content blocks
  • Added model_config = {"extra": "ignore"} to both ContentPart and Message to silently drop unknown fields

Test plan

  • All existing tests pass: poetry run python tests/test_endpoints.py → 4/4
  • All existing tests pass: poetry run python tests/test_basic.py → 4/4
  • Server starts cleanly with poetry run uvicorn src.main:app --reload --port 8000
  • Verify OpenClaw requests no longer return 422 with a live OpenClaw instance

🤖 Generated with Claude Code

- Add claude-sonnet-4-6 and claude-opus-4-6 to CLAUDE_MODELS
- Set claude-sonnet-4-6 as the new DEFAULT_MODEL
- Fix 422 errors from OpenClaw by accepting role: 'tool' in messages
- Handle null/None message content (assistant messages mid-tool-call)
- Loosen ContentPart to accept any content block type (tool_use, tool_result, image, etc.)
- Extract text from tool_result content blocks during normalization
- Add model_config extra='ignore' to drop unknown fields silently

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bhargav18 bhargav18 closed this Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant