hermes - 💡(How to fix) Fix GPT/OpenAI-compatible endpoints reject tool schemas with regex lookaround pattern

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When Hermes is configured to use a GPT / OpenAI-compatible endpoint with tool calling enabled, some requests fail before model inference because the endpoint rejects a tool JSON Schema containing a regex lookaround in a pattern keyword.

Observed error:

Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $...*.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}

This appears to be the same class of issue as MCP/Zod-generated schemas containing lookahead/lookbehind regex patterns, especially with OpenAI/GPT-style strict tool schema validation.

Error Message

Relevant gateway/agent logs:

agent.conversation_loop: conversation turn: session=... model=gpt-5.5 provider=custom platform=weixin ...
agent.chat_completion_helpers: Streaming failed before delivery: Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}
agent.conversation_loop: API call failed (attempt 1/3) error_type=BadRequestError provider=custom base_url=... model=gpt-5.5 summary=HTTP 400: Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.
agent.conversation_loop: Non-retryable client error: Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}

Root Cause

Switching from Anthropic/Claude-compatible endpoints to GPT/OpenAI-compatible endpoints can break existing Hermes gateway sessions even when Hermes version is unchanged, because the active runtime tool/MCP/plugin set may include schemas with unsupported regex dialect features.

This is hard for users to diagnose because the failure is reported as a model/API error, but the actual issue is in tools schema validation before inference.

Fix Action

Fix / Workaround

Local workaround tested

A local patch to agent/error_classifier.py classified this error pattern as FailoverReason.llama_cpp_grammar_pattern, allowing Hermes to reuse the existing recovery path that strips pattern / format from tool schemas and retries.

Patch shape:

Code Example

Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $...*.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}

---

Hermes Agent v0.16.0 (2026.6.5) · upstream 09a6a2dd
Python: 3.11.11
OpenAI SDK: 2.24.0
Provider: custom
Model: gpt-5.5
Base URL: OpenAI-compatible /v1 endpoint
Platform: gateway / Weixin DM
OS: macOS

---

agent.conversation_loop: conversation turn: session=... model=gpt-5.5 provider=custom platform=weixin ...
agent.chat_completion_helpers: Streaming failed before delivery: Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}
agent.conversation_loop: API call failed (attempt 1/3) error_type=BadRequestError provider=custom base_url=... model=gpt-5.5 summary=HTTP 400: Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.
agent.conversation_loop: Non-retryable client error: Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}

---

Invalid JSON schema: regex lookaround is not supported. Found at $.properties.email.pattern.

---

or (
    "invalid json schema" in error_msg
    and "regex" in error_msg
    and "lookaround" in error_msg
    and "not supported" in error_msg
    and "pattern" in error_msg
)

---

python -m pytest tests/tools/test_schema_sanitizer.py tests/agent/test_error_classifier.py -q -o 'addopts='
Pytest: 195 passed

---

FailoverReason.llama_cpp_grammar_pattern True False
RAW_BUFFERClick to expand / collapse

Summary

When Hermes is configured to use a GPT / OpenAI-compatible endpoint with tool calling enabled, some requests fail before model inference because the endpoint rejects a tool JSON Schema containing a regex lookaround in a pattern keyword.

Observed error:

Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $...*.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}

This appears to be the same class of issue as MCP/Zod-generated schemas containing lookahead/lookbehind regex patterns, especially with OpenAI/GPT-style strict tool schema validation.

Environment

Hermes Agent v0.16.0 (2026.6.5) · upstream 09a6a2dd
Python: 3.11.11
OpenAI SDK: 2.24.0
Provider: custom
Model: gpt-5.5
Base URL: OpenAI-compatible /v1 endpoint
Platform: gateway / Weixin DM
OS: macOS

The same Hermes version on another machine configured for GPT did not reproduce, which suggests the trigger depends on the runtime tool/MCP/plugin schema set rather than Hermes version alone.

Logs

Relevant gateway/agent logs:

agent.conversation_loop: conversation turn: session=... model=gpt-5.5 provider=custom platform=weixin ...
agent.chat_completion_helpers: Streaming failed before delivery: Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}
agent.conversation_loop: API call failed (attempt 1/3) error_type=BadRequestError provider=custom base_url=... model=gpt-5.5 summary=HTTP 400: Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.
agent.conversation_loop: Non-retryable client error: Error code: 400 - {'error': {'message': 'Invalid JSON schema: regex lookaround is not supported. Found at $.***.***.***.pattern.', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_json_schema'}}

Expected behavior

Hermes should treat this as a recoverable tool-schema compatibility failure, similar to existing llama.cpp grammar/schema recovery cases, and either:

  1. strip incompatible JSON Schema keywords such as pattern / format and retry once; or
  2. apply a provider/model-specific tool schema compatibility sanitizer before sending the request to strict OpenAI-compatible endpoints.

The conversation should not fail permanently with a non-retryable 400.

Actual behavior

The error is classified as a non-retryable client error and the gateway returns the raw 400 error to the user.

Related external evidence

A very similar report exists in SmartBear MCP:

  • z.string().email() generated a JSON Schema pattern containing negative lookahead
  • OpenAI gpt-5.5 rejected it with:
Invalid JSON schema: regex lookaround is not supported. Found at $.properties.email.pattern.

Reference: https://github.com/SmartBear/smartbear-mcp/issues/491

Mastra also documented provider-specific tool schema incompatibilities and the need for a compatibility layer: https://mastra.ai/blog/mcp-tool-compatibility-layer

Local workaround tested

A local patch to agent/error_classifier.py classified this error pattern as FailoverReason.llama_cpp_grammar_pattern, allowing Hermes to reuse the existing recovery path that strips pattern / format from tool schemas and retries.

Patch shape:

or (
    "invalid json schema" in error_msg
    and "regex" in error_msg
    and "lookaround" in error_msg
    and "not supported" in error_msg
    and "pattern" in error_msg
)

Tests run locally:

python -m pytest tests/tools/test_schema_sanitizer.py tests/agent/test_error_classifier.py -q -o 'addopts='
Pytest: 195 passed

A direct classifier probe returned:

FailoverReason.llama_cpp_grammar_pattern True False

Possible fix

Short-term:

  • Extend agent.error_classifier.classify_api_error() so HTTP 400 errors with:

    • Invalid JSON schema
    • regex lookaround is not supported
    • param: tools or pattern in the message

    are classified as a recoverable schema/grammar compatibility failure and routed through the existing strip_pattern_and_format() retry path.

Long-term:

  • Add a provider/model-specific tool schema compatibility layer for strict OpenAI-compatible endpoints.
  • Consider moving dropped constraints into property descriptions rather than sending unsupported JSON Schema keywords directly.
  • Preserve property names literally called pattern (e.g. search_files.pattern) while removing only schema-keyword pattern fields that are siblings of type / schema combinators.

Why this matters

Switching from Anthropic/Claude-compatible endpoints to GPT/OpenAI-compatible endpoints can break existing Hermes gateway sessions even when Hermes version is unchanged, because the active runtime tool/MCP/plugin set may include schemas with unsupported regex dialect features.

This is hard for users to diagnose because the failure is reported as a model/API error, but the actual issue is in tools schema validation before inference.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Hermes should treat this as a recoverable tool-schema compatibility failure, similar to existing llama.cpp grammar/schema recovery cases, and either:

  1. strip incompatible JSON Schema keywords such as pattern / format and retry once; or
  2. apply a provider/model-specific tool schema compatibility sanitizer before sending the request to strict OpenAI-compatible endpoints.

The conversation should not fail permanently with a non-retryable 400.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING