[GH-ISSUE #1329] [Bug] Tool schemas use \0 regex escape that DeepSeek API rejects — every turn fails with 400 invalid_request_error while the MCP server is connected #465

Closed
opened 2026-10-15 18:25:16 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @commit-regrets on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/1329

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

MCP or agent integration

Observed behavior

Summary

With the REA MCP server connected and a DeepSeek model selected, every model request fails with 400 invalid_request_error before any tool is invoked.
REA's MCP tool schemas include JSON-Schema pattern fields containing the regex
^[^\0]*$ (a NUL escape inside a character class). The DeepSeek API validates tool
schemas server-side and rejects this regex ("is not a 'regex'"), returning
400 invalid_request_error for the entire request. Because tool schemas are sent
with every model request, all turns fail — not just REA tool calls — whenever the
client is connected to REA while using a DeepSeek model.

Error (verbatim, from the client)

Invalid schema for function 'mcp__rea__observe_native_calls': "^[^\0]*$" is not a "regex"
provider_code=invalid_request_error model=deepseek-flash status=400 retryable=false

Root cause

Emitted schema fragment: "pattern": "^[^\0]*$"
The pattern is emitted from at least these dist modules (rea-agents 6.1.0):

  • dist/contracts/native/nativeToolContracts.js
  • dist/domain/native/nativeCallObservation.js (observe_native_calls)
  • dist/domain/process/processScenario.js (capture_process_scenario)

\0 inside a character class is valid ECMA-262 regex, but DeepSeek's server-side
validator does not accept it, and one invalid schema poisons the whole tool list.

Suggested fix

Emit a provider-safe constraint instead of the \0 escape — e.g. drop the pattern
and constrain via description/maxLength, or make strict patterns opt-out via an
env flag for providers with stricter regex validation. Note observe_native_calls is
macOS-only, so excluding non-macOS tools from the advertised schema set on non-mac
hosts would also reduce exposure.

Workaround

Switch to a model whose provider accepts the schema, or disable the rea MCP server
when using DeepSeek models.

Environment

  • OS: Windows 11 (10.0.26300) x64
  • Node: 26.4.0
  • rea-agents: 6.1.0 (npx)
  • Client: ZCode (MCP stdio)
  • Model/provider: deepseek-flash (DeepSeek API)

Reproduction

Steps to reproduce

  1. Register REA with any MCP client (rea-agents@6.1.0 mcp, stdio).
  2. Point the client at a DeepSeek model (deepseek-flash).
  3. Send any message. The request 400s before the model runs.

Expected behavior

Any model request should succeed while the REA MCP server is connected, regardless of the model provider's schema validator. Tool schemas advertised over MCP must be accepted by mainstream providers (the \0 escape in the pattern regex causes DeepSeek to reject the entire request with 400 invalid_request_error before the model runs).

Impact and scope

Complete loss of functionality: every turn fails (not just REA tool calls) whenever the client uses a DeepSeek model while the REA MCP server is connected. Affects all users pairing REA with DeepSeek-family models. The same pattern appears in several tools (observe_native_calls, capture_process_scenario, …), so it is not limited to macOS-only tools.

REA version

6.1.0 (npx rea-agents@6.1.0)

Runtime and platform

Node 26.4.0, Windows 11 x64 (10.0.26300). MCP transport: stdio.

Target and artifact context

None — the failure is schema-level and occurs before any target or artifact is involved.

Interface

MCP

Earliest failure stage

Request parsing or validation

Relevant output or evidence

Invalid schema for function 'mcp__rea__observe_native_calls': "^[^\\0]*$" is not a "regex"
provider_code=invalid_request_error  model=deepseek-flash  status=400  retryable=false
(request_id fd208285-c71d-4536-8876-c4a31bf6eb55)

Pattern location (rea-agents 6.1.0 dist): dist/contracts/native/nativeToolContracts.js,
dist/domain/native/nativeCallObservation.js, dist/domain/process/processScenario.js —
JSON-Schema `pattern`: ^[^\0]*$

Typed outcome or recovery expected

Typed outcome observed: provider 400 invalid_request_error, retryable=false. Expected recovery: either the schema is emitted in a provider-safe form, or the request is retried/served with the offending pattern omitted — anything that lets turns proceed with REA connected.

Analysis or suspected cause

The JSON-Schema pattern uses the ECMA-262 \0 (NUL) escape inside a character class. DeepSeek's server-side tool-schema validator does not accept that escape and rejects the whole function list. Suggested fix: drop the pattern (constrain via description/maxLength instead) or make strict patterns opt-out for providers with stricter regex validation. Note observe_native_calls is macOS-only, so excluding non-macOS tools from the advertised schema set would also reduce exposure.

Additional context

Workaround confirmed: switching to a non-DeepSeek model (or disabling the rea MCP server) restores normal operation. Request_id from the failing turn: fd208285-c71d-4536-8876-c4a31bf6eb55.

Originally created by @commit-regrets on GitHub (Oct 9, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/1329 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area MCP or agent integration ### Observed behavior ## Summary With the REA MCP server connected and a DeepSeek model selected, every model request fails with 400 invalid_request_error before any tool is invoked. REA's MCP tool schemas include JSON-Schema `pattern` fields containing the regex `^[^\0]*$` (a NUL escape inside a character class). The DeepSeek API validates tool schemas server-side and rejects this regex ("is not a 'regex'"), returning `400 invalid_request_error` for the **entire request**. Because tool schemas are sent with every model request, *all* turns fail — not just REA tool calls — whenever the client is connected to REA while using a DeepSeek model. ## Error (verbatim, from the client) Invalid schema for function 'mcp__rea__observe_native_calls': "^[^\\0]*$" is not a "regex" provider_code=invalid_request_error model=deepseek-flash status=400 retryable=false ## Root cause Emitted schema fragment: "pattern": "^[^\\0]*$" The pattern is emitted from at least these dist modules (rea-agents 6.1.0): - `dist/contracts/native/nativeToolContracts.js` - `dist/domain/native/nativeCallObservation.js` (observe_native_calls) - `dist/domain/process/processScenario.js` (capture_process_scenario) `\0` inside a character class is valid ECMA-262 regex, but DeepSeek's server-side validator does not accept it, and one invalid schema poisons the whole tool list. ## Suggested fix Emit a provider-safe constraint instead of the `\0` escape — e.g. drop the `pattern` and constrain via `description`/`maxLength`, or make strict patterns opt-out via an env flag for providers with stricter regex validation. Note `observe_native_calls` is macOS-only, so excluding non-macOS tools from the advertised schema set on non-mac hosts would also reduce exposure. ## Workaround Switch to a model whose provider accepts the schema, or disable the `rea` MCP server when using DeepSeek models. ## Environment - OS: Windows 11 (10.0.26300) x64 - Node: 26.4.0 - rea-agents: 6.1.0 (npx) - Client: ZCode (MCP stdio) - Model/provider: deepseek-flash (DeepSeek API) ### Reproduction ## Steps to reproduce 1. Register REA with any MCP client (`rea-agents@6.1.0 mcp`, stdio). 2. Point the client at a DeepSeek model (`deepseek-flash`). 3. Send any message. The request 400s before the model runs. ### Expected behavior Any model request should succeed while the REA MCP server is connected, regardless of the model provider's schema validator. Tool schemas advertised over MCP must be accepted by mainstream providers (the `\0` escape in the `pattern` regex causes DeepSeek to reject the entire request with 400 invalid_request_error before the model runs). ### Impact and scope Complete loss of functionality: every turn fails (not just REA tool calls) whenever the client uses a DeepSeek model while the REA MCP server is connected. Affects all users pairing REA with DeepSeek-family models. The same pattern appears in several tools (observe_native_calls, capture_process_scenario, …), so it is not limited to macOS-only tools. ### REA version 6.1.0 (npx rea-agents@6.1.0) ### Runtime and platform Node 26.4.0, Windows 11 x64 (10.0.26300). MCP transport: stdio. ### Target and artifact context None — the failure is schema-level and occurs before any target or artifact is involved. ### Interface MCP ### Earliest failure stage Request parsing or validation ### Relevant output or evidence ```text Invalid schema for function 'mcp__rea__observe_native_calls': "^[^\\0]*$" is not a "regex" provider_code=invalid_request_error model=deepseek-flash status=400 retryable=false (request_id fd208285-c71d-4536-8876-c4a31bf6eb55) Pattern location (rea-agents 6.1.0 dist): dist/contracts/native/nativeToolContracts.js, dist/domain/native/nativeCallObservation.js, dist/domain/process/processScenario.js — JSON-Schema `pattern`: ^[^\0]*$ ``` ### Typed outcome or recovery expected Typed outcome observed: provider 400 invalid_request_error, retryable=false. Expected recovery: either the schema is emitted in a provider-safe form, or the request is retried/served with the offending pattern omitted — anything that lets turns proceed with REA connected. ### Analysis or suspected cause The JSON-Schema `pattern` uses the ECMA-262 `\0` (NUL) escape inside a character class. DeepSeek's server-side tool-schema validator does not accept that escape and rejects the whole function list. Suggested fix: drop the `pattern` (constrain via description/maxLength instead) or make strict patterns opt-out for providers with stricter regex validation. Note `observe_native_calls` is macOS-only, so excluding non-macOS tools from the advertised schema set would also reduce exposure. ### Additional context Workaround confirmed: switching to a non-DeepSeek model (or disabling the `rea` MCP server) restores normal operation. Request_id from the failing turn: fd208285-c71d-4536-8876-c4a31bf6eb55.
bsakaguchi 2026-10-15 18:25:16 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#465
No description provided.