[GH-ISSUE #919] MCP tool input schemas exceed Muse Spark 1.3 function-calling limits (recursive $ref, nesting depth > 10); no REA tool is usable with that model #368

Closed
opened 2026-10-15 18:24:20 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @advokat11 on GitHub (Oct 7, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/919

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

With Muse Spark 1.3 selected in opencode, the request that carries the REA tool list is rejected, so none of the REA tools can be used with that model. The rejection reason depends on the REA build:

REA build Error
rea-agents@4.1.0 Recursive JSON schemas are not currently supported
branch fix/non-recursive-mcp-schemas (commit 3205a8d, recursion stripped from advertised schemas) JSON schema exceeds the maximum nesting depth of 10 levels

Fixing the first constraint exposed the second, so this report covers Muse Spark 1.3 schema compatibility as a whole, not only recursion.

The REA server itself is healthy: mcp doctor passes and reports 125/125 tools.

Reproduction

  1. Add REA to the opencode config (~/.config/opencode/opencode.json):
    {
      "mcp": {
        "rea": {
          "type": "local",
          "command": ["npx", "-y", "rea-agents@4.1.0", "mcp"],
          "enabled": true
        }
      }
    }
    
  2. Start opencode 1.18.34 and select Muse Spark 1.3.
  3. Send any prompt. The request fails with Recursive JSON schemas are not currently supported.
  4. Run REA from the fix/non-recursive-mcp-schemas build instead and repeat step 3. The request fails with JSON schema exceeds the maximum nesting depth of 10 levels.
  5. Server health check: npx -y rea-agents@4.1.0 mcp doctor --format json returns healthy: true, tools expected=125 observed=125.

Expected behavior

Every REA tool input schema that clients forward to the model fits within Muse Spark 1.3's function-calling schema limits. With that model, the tool list loads and the tools can be called.

Impact and scope

  • Every tool is blocked by any one schema. All tool definitions go to the model in one request. One schema over the limit causes the provider to reject the whole request, so not a single REA tool can be called.
  • The limits are probably the model API's, not opencode's. Neither error string appears in the opencode source (sst/opencode@ecc4916). For the meta provider, opencode sends only each MCP tool's inputSchema, passed through its OpenAI-style sanitizer, which keeps $ref and $defs. The most likely source of both errors is the Muse Spark API itself. Other clients or gateways that forward REA schemas to this model would probably hit the same limits. This has not been verified outside opencode.
  • CLI usage and mcp doctor are not affected.

REA version

4.1.0 (npm rea-agents@4.1.0); also reproduced on branch fix/non-recursive-mcp-schemas (3205a8d)

Runtime and platform

Node v26.8.1; npm 11.19.0; Linux x64; opencode 1.18.34; model Muse Spark 1.3; REA MCP protocol 2025-11-25

Target and artifact context

Not applicable. The failure happens when the tool definitions are sent to the model, before any target is opened.

Interface

MCP

Earliest failure stage

Transport or result projection (the advertised tool-list schemas)

Relevant output or evidence

Observed

  • 4.1.0: every generic JSON value node (z.json()) projects a self-referential definition, for example in annotate_native_function:
    "__schema0": { "anyOf": [ {"type":"string"}, {"type":"number"}, {"type":"boolean"}, {"type":"null"},
      {"type":"array", "items": {"$ref":"#/$defs/__schema0"}},
      {"type":"object", "additionalProperties": {"$ref":"#/$defs/__schema0"}} ] }
    
  • After 3205a8d: the generated catalog contains no reference cycles. 141 schemas still use $defs, through 745 non-recursive $refs.

Measured (branch 3205a8d): the depth of all 131 input schemas, after opencode's meta transform with $refs inlined. The exact depth rule Muse Spark applies is unknown, so here are three candidate rules:

Depth rule Max Schemas over 10
object/array levels only 11 1: compare_web_captures
object/array plus anyOf/oneOf/allOf levels 13 1: compare_web_captures
raw JSON document depth 25 23

Deepest paths in compare_web_captures input:

  • after.inspection.metadata.responses[].csp.directives[].sources[].kind (11 object/array levels)
  • after.inspection.network.websocket_events[].payload_shape → json_shape → properties[].types[] (13 levels when combinators count)

The input of compare_web_captures contains entire web-capture inspection objects (before/after → inspection, webmcp). That is where the depth comes from.

Not yet known

  • Which depth rule the Muse Spark API applies.
  • Whether the API enforces further limits, such as total property count, enum size, or overall schema size, that are hidden behind the first failing check.

Proposed discriminating check: disable that one tool in opencode with "tools": { "rea_compare_web_captures": false }.

  • If the depth error disappears, a level-based rule applies and one contract needs work.
  • If it persists, the API counts raw JSON depth and 23 schemas exceed it.

Typed outcome or recovery expected

  • REA advertises input schemas that satisfy one documented, testable compatibility profile: no recursive $ref (including root "$ref": "#") and a bounded nesting depth under a stated rule.
  • A boundary test asserts that profile on the schemas after SDK conversion.
  • A real opencode + Muse Spark 1.3 run confirms the claim.
  • Runtime Zod validation stays unchanged.

Analysis or suspected cause

The constraints are likely the model API's schema subset, which looks similar to strict OpenAI-style structured outputs. REA's contracts currently assume full JSON Schema 2020-12. The two observed violations are:

  1. Recursion. z.json() emits a self-referencing $defs entry. This is addressed by 3205a8d. Replacing the nested reference with {} is lossless for z.json(), because both mean "any JSON value".
  2. Depth. Inputs that embed whole nested result objects, such as compare_web_captures taking full inspections, go deeper than 10 levels.

Additional context

Possible directions (maintainer's choice):

  • Restructure deep inputs so they take compact references or projections instead of whole nested results. This keeps the catalog complete and self-describing.
  • Alternatively, apply a bounded wire-schema lowering at registration: replace subschemas beyond the depth limit with free-form {} while runtime Zod validation stays strict. This is lossy for the model's view of the schema.
  • Add a test that asserts the depth bound and the absence of "$ref": "#" alongside the existing recursion test.
  • Document known per-model schema limits for MCP clients.
Originally created by @advokat11 on GitHub (Oct 7, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/919 ### 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 With Muse Spark 1.3 selected in opencode, the request that carries the REA tool list is rejected, so none of the REA tools can be used with that model. The rejection reason depends on the REA build: | REA build | Error | |---|---| | `rea-agents@4.1.0` | `Recursive JSON schemas are not currently supported` | | branch `fix/non-recursive-mcp-schemas` (commit `3205a8d`, recursion stripped from advertised schemas) | `JSON schema exceeds the maximum nesting depth of 10 levels` | Fixing the first constraint exposed the second, so this report covers Muse Spark 1.3 schema compatibility as a whole, not only recursion. The REA server itself is healthy: `mcp doctor` passes and reports 125/125 tools. ### Reproduction 1. Add REA to the opencode config (`~/.config/opencode/opencode.json`): ```json { "mcp": { "rea": { "type": "local", "command": ["npx", "-y", "rea-agents@4.1.0", "mcp"], "enabled": true } } } ``` 2. Start opencode 1.18.34 and select Muse Spark 1.3. 3. Send any prompt. The request fails with `Recursive JSON schemas are not currently supported`. 4. Run REA from the `fix/non-recursive-mcp-schemas` build instead and repeat step 3. The request fails with `JSON schema exceeds the maximum nesting depth of 10 levels`. 5. Server health check: `npx -y rea-agents@4.1.0 mcp doctor --format json` returns `healthy: true`, tools expected=125 observed=125. ### Expected behavior Every REA tool input schema that clients forward to the model fits within Muse Spark 1.3's function-calling schema limits. With that model, the tool list loads and the tools can be called. ### Impact and scope - **Every tool is blocked by any one schema.** All tool definitions go to the model in one request. One schema over the limit causes the provider to reject the whole request, so not a single REA tool can be called. - **The limits are probably the model API's, not opencode's.** Neither error string appears in the opencode source (`sst/opencode@ecc4916`). For the `meta` provider, opencode sends only each MCP tool's `inputSchema`, passed through its OpenAI-style sanitizer, which keeps `$ref` and `$defs`. The most likely source of both errors is the Muse Spark API itself. Other clients or gateways that forward REA schemas to this model would probably hit the same limits. This has not been verified outside opencode. - CLI usage and `mcp doctor` are not affected. ### REA version 4.1.0 (npm `rea-agents@4.1.0`); also reproduced on branch `fix/non-recursive-mcp-schemas` (`3205a8d`) ### Runtime and platform Node v26.8.1; npm 11.19.0; Linux x64; opencode 1.18.34; model Muse Spark 1.3; REA MCP protocol 2025-11-25 ### Target and artifact context Not applicable. The failure happens when the tool definitions are sent to the model, before any target is opened. ### Interface MCP ### Earliest failure stage Transport or result projection (the advertised tool-list schemas) ### Relevant output or evidence **Observed** - 4.1.0: every generic JSON value node (`z.json()`) projects a self-referential definition, for example in `annotate_native_function`: ```json "__schema0": { "anyOf": [ {"type":"string"}, {"type":"number"}, {"type":"boolean"}, {"type":"null"}, {"type":"array", "items": {"$ref":"#/$defs/__schema0"}}, {"type":"object", "additionalProperties": {"$ref":"#/$defs/__schema0"}} ] } ``` - After `3205a8d`: the generated catalog contains no reference cycles. 141 schemas still use `$defs`, through 745 non-recursive `$ref`s. **Measured (branch `3205a8d`):** the depth of all 131 input schemas, after opencode's `meta` transform with `$ref`s inlined. The exact depth rule Muse Spark applies is unknown, so here are three candidate rules: | Depth rule | Max | Schemas over 10 | |---|---|---| | object/array levels only | 11 | 1: `compare_web_captures` | | object/array plus `anyOf`/`oneOf`/`allOf` levels | 13 | 1: `compare_web_captures` | | raw JSON document depth | 25 | 23 | Deepest paths in `compare_web_captures` input: - `after.inspection.metadata.responses[].csp.directives[].sources[].kind` (11 object/array levels) - `after.inspection.network.websocket_events[].payload_shape → json_shape → properties[].types[]` (13 levels when combinators count) The input of `compare_web_captures` contains entire web-capture inspection objects (`before`/`after` → `inspection`, `webmcp`). That is where the depth comes from. **Not yet known** - Which depth rule the Muse Spark API applies. - Whether the API enforces further limits, such as total property count, enum size, or overall schema size, that are hidden behind the first failing check. **Proposed discriminating check:** disable that one tool in opencode with `"tools": { "rea_compare_web_captures": false }`. - If the depth error disappears, a level-based rule applies and one contract needs work. - If it persists, the API counts raw JSON depth and 23 schemas exceed it. ### Typed outcome or recovery expected - REA advertises input schemas that satisfy one documented, testable compatibility profile: no recursive `$ref` (including root `"$ref": "#"`) and a bounded nesting depth under a stated rule. - A boundary test asserts that profile on the schemas after SDK conversion. - A real opencode + Muse Spark 1.3 run confirms the claim. - Runtime Zod validation stays unchanged. ### Analysis or suspected cause The constraints are likely the model API's schema subset, which looks similar to strict OpenAI-style structured outputs. REA's contracts currently assume full JSON Schema 2020-12. The two observed violations are: 1. **Recursion.** `z.json()` emits a self-referencing `$defs` entry. This is addressed by `3205a8d`. Replacing the nested reference with `{}` is lossless for `z.json()`, because both mean "any JSON value". 2. **Depth.** Inputs that embed whole nested result objects, such as `compare_web_captures` taking full inspections, go deeper than 10 levels. ### Additional context Possible directions (maintainer's choice): - Restructure deep inputs so they take compact references or projections instead of whole nested results. This keeps the catalog complete and self-describing. - Alternatively, apply a bounded wire-schema lowering at registration: replace subschemas beyond the depth limit with free-form `{}` while runtime Zod validation stays strict. This is lossy for the model's view of the schema. - Add a test that asserts the depth bound and the absence of `"$ref": "#"` alongside the existing recursion test. - Document known per-model schema limits for MCP clients.
bsakaguchi 2026-10-15 18:24:20 +00:00
Author
Owner

@JoAdo07 commented on GitHub (Oct 7, 2026):

Measured the advertised catalog on current main (post-SDK conversion through a loopback client, $defs followed per-path so diamonds don't count as cycles): 133 tools, 20 with recursive $ref cycles, 1 over depth 10 (compare_web_captures at 14).

Recursive: build_call_path, build_reconstruction_obligation_ledger, compare_application_versions, compare_artifacts, compare_functions, compare_javascript_export_shapes, compare_managed_members, compare_process_captures, compare_source_to_bundle, correlate_static_and_runtime, evaluate_reconstruction_coverage, find_changed_behavior, import_managed_reconstruction, project_android_application_graph, project_apple_application_graph, project_managed_application_graph, reconcile_javascript_runtime, trace_application_feature, trace_javascript_semantics, verify_managed_native_boundaries.

Opened #1033 with a ratchet test pinning these counts (bounds only decrease) plus walker unit tests, no contract changes — the actual schema diet is maintainer scope per the repo's truncation guidance.

<!-- gh-comment-id:6047468458 --> @JoAdo07 commented on GitHub (Oct 7, 2026): Measured the advertised catalog on current `main` (post-SDK conversion through a loopback client, `$defs` followed per-path so diamonds don't count as cycles): **133 tools, 20 with recursive `$ref` cycles, 1 over depth 10** (`compare_web_captures` at 14). Recursive: `build_call_path`, `build_reconstruction_obligation_ledger`, `compare_application_versions`, `compare_artifacts`, `compare_functions`, `compare_javascript_export_shapes`, `compare_managed_members`, `compare_process_captures`, `compare_source_to_bundle`, `correlate_static_and_runtime`, `evaluate_reconstruction_coverage`, `find_changed_behavior`, `import_managed_reconstruction`, `project_android_application_graph`, `project_apple_application_graph`, `project_managed_application_graph`, `reconcile_javascript_runtime`, `trace_application_feature`, `trace_javascript_semantics`, `verify_managed_native_boundaries`. Opened #1033 with a ratchet test pinning these counts (bounds only decrease) plus walker unit tests, no contract changes — the actual schema diet is maintainer scope per the repo's truncation guidance.
Author
Owner

@N0zoM1z0 commented on GitHub (Oct 8, 2026):

The catalog fixes are now merged in #995 (7425f70) and #1005 (6b55de0).

Actual stdio discovery reports all 134 tools, zero reachable reference cycles in both inputs and outputs, and maximum input depth ten under the documented object/array/composition profile. Regression checks cover every live SDK-converted and generated contract, including root # references, escaped pointers, shared definitions, dialect validity, and catalog/handler identity.

The deep comparison inputs now describe complete results from inspect_web_page and capture_browser_scenario to pass back unchanged. Scenario authoring fields and normalization options remain fully described, and the complete nested runtime validators are retained. Actual Chrome capture round trips, malformed deep-input rejection, CLI/MCP parity, and normal packed installation all passed. Exact-head CI passed on Windows, Linux x64/arm64, and macOS x64/arm64.

Muse Spark/opencode itself was unavailable here, so its exact undocumented depth rule and any additional API limits remain unverified. These commits establish the stated catalog compatibility profile across REA rather than a client-specific workaround.

The published rea-agents@5.0.0 predates these fixes. Until a release containing them is published, use a source checkout containing 6b55de0, run npm ci and npm run build:cached, and point the MCP command at node /path/to/rea/scripts/rea.mjs mcp. If Muse still rejects that catalog, please include the new error and tested commit so the remaining constraint can be investigated.

<!-- gh-comment-id:6052214032 --> @N0zoM1z0 commented on GitHub (Oct 8, 2026): The catalog fixes are now merged in #995 (`7425f70`) and #1005 (`6b55de0`). Actual stdio discovery reports all 134 tools, zero reachable reference cycles in both inputs and outputs, and maximum input depth ten under the documented object/array/composition profile. Regression checks cover every live SDK-converted and generated contract, including root `#` references, escaped pointers, shared definitions, dialect validity, and catalog/handler identity. The deep comparison inputs now describe complete results from `inspect_web_page` and `capture_browser_scenario` to pass back unchanged. Scenario authoring fields and normalization options remain fully described, and the complete nested runtime validators are retained. Actual Chrome capture round trips, malformed deep-input rejection, CLI/MCP parity, and normal packed installation all passed. Exact-head CI passed on Windows, Linux x64/arm64, and macOS x64/arm64. Muse Spark/opencode itself was unavailable here, so its exact undocumented depth rule and any additional API limits remain unverified. These commits establish the stated catalog compatibility profile across REA rather than a client-specific workaround. The published `rea-agents@5.0.0` predates these fixes. Until a release containing them is published, use a source checkout containing `6b55de0`, run `npm ci` and `npm run build:cached`, and point the MCP command at `node /path/to/rea/scripts/rea.mjs mcp`. If Muse still rejects that catalog, please include the new error and tested commit so the remaining constraint can be investigated.
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#368
No description provided.