Skip to content

Artifact tool schema (Unicode property regex) rejected by backend: 400 Invalid schema for function 'Artifact' #142

Description

@mjrouser

Summary

Every request through the proxy to a Codex/OpenAI backend fails with a 400 because the built-in Claude Code Artifact tool's JSON schema uses regex features the backend's function-calling schema validator rejects. This is unconditional — it reproduces on a bare hi prompt with no other tools or context involved, since Claude Code sends its full built-in tool list (including Artifact) with every request regardless of whether the tool is used.

Error

API Error: 400 Invalid schema for function 'Artifact': '^(?!__.*__$)[^\p{Cc}\p{Cf}\p{Zl}\p{Zp}"\\./[\]]{1,200}$' is not a 'regex'.

Reproduction

  1. Point Claude Code at the proxy with a Codex/OpenAI backend model selected.
  2. Start a fresh session, send a single trivial message (e.g. hi).
  3. Request fails immediately with the 400 above, before the model sees any prompt content.

Environment

  • Claude Code CLI: 2.1.266
  • claude-code-proxy: 0.1.37
  • Backend: a GPT-6-class model via ChatGPT Codex login

Likely cause

The Artifact tool's pattern constraint combines a negative lookahead ((?!__.*__$)) with Unicode property escapes (\p{Cc}, \p{Cf}, \p{Zl}, \p{Zp}). Both are valid in the regex dialect Claude Code emits, but the OpenAI-side function-calling/structured-output schema validator appears to accept only a restricted regex subset (no lookaround, no \p{...} Unicode categories) — the same class of incompatibility reported elsewhere for lookaround support (e.g. anomalyco/opencode#31996 for an unrelated tool's pattern).

Since Claude Code has no way to know a session is being proxied to a backend with a stricter schema validator, this likely needs to be handled on the proxy side: either strip/loosen the pattern constraint on tool schemas being forwarded to backends that don't support the full regex feature set, or replace unsupported constructs with an equivalent the backend's validator accepts.

Impact

Any session with a Codex/OpenAI backend model selected as the top-level session model is unusable — it cannot process any message, since the Artifact tool schema is sent unconditionally on every request. Subagent-only workflows that don't carry the Artifact tool in their scoped tool list are unaffected.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions