Skip to content

Fix Gradio Playground MCP argument parsing - #1081

Merged
burtenshaw merged 1 commit into
huggingface:mainfrom
lakshayxi:fix-gradio-mcp-arguments
Sep 16, 2026
Merged

burtenshaw merged 1 commit into
huggingface:mainfrom
lakshayxi:fix-gradio-mcp-arguments

Conversation

@lakshayxi

@lakshayxi lakshayxi commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #1080.

Summary

  • Parse JSON string arguments for MCP call_tool actions at the web preprocessing boundary.
  • Preserve strict deserialization for normal typed payloads.
  • Keep invalid, non-object, and malformed JSON subject to existing Pydantic validation.
  • Add regression coverage for both serialization behavior and the /web/step path.
  • Remove the stale Gradio MCP workaround from AGENTS.md.

Tests

  • PYTHONPATH=src:envs uv run pytest tests/core/ -q
  • PYTHONPATH=src:envs uv run pytest tests/ -q
  • uv run usort check src/openenv/core/env_server/serialization.py tests/core/test_mcp/test_mcp_types.py tests/core/test_web_interface_mcp.py
  • uv run ruff format src/openenv/core/env_server/serialization.py tests/core/test_mcp/test_mcp_types.py tests/core/test_web_interface_mcp.py --check
  • uv run ruff check src/openenv/core/env_server/serialization.py tests/core/test_mcp/test_mcp_types.py tests/core/test_web_interface_mcp.py

Full suite: 1641 passed, 129 skipped.


Note

Low Risk
Scoped to the web preprocessing deserialization path with clear validation boundaries and broad test coverage; no auth or data-model changes.

Overview
Fixes Gradio Playground and POST /web/step failures when MCP call_tool actions send arguments as a JSON string (textbox) instead of an object.

deserialize_action_with_preprocessing now JSON-decodes string arguments for type: call_tool into a dict on a copy of the payload (input is not mutated). deserialize_action stays strict—string arguments still fail validation. Malformed JSON, arrays, and scalar JSON strings still raise ValidationError.

Regression tests cover serialization edge cases and an integration test on /web/step. AGENTS.md drops the old workaround note about the broken Playground Step form.

Reviewed by Cursor Bugbot for commit 9b765f8. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Reviewed at 9b765f8e2e1dbf2319db74395a4cc94552964c2b: JSON-dict preprocessing fixes the MCP Playground form while preserving strict validation for malformed, list, and scalar inputs; the regression coverage is appropriate and no alignment issue was found. Before merge, refresh onto current main, approve the first-contributor workflow run, and require green exact-head CI. The required workflows are currently action_required and never executed.

Open in Web View Automation 

Sent by Cursor Automation: Release

@cursor
cursor Bot requested a review from burtenshaw September 10, 2026 06:22

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Refresh review vs main b12450f2 (Ben ask):

Verdict: LGTM after rebase. Exact head 9b765f8e is ~66 behind main. Preprocessing-only JSON parse of Gradio string arguments for call_tool is correct; strict deserialize_action still rejects strings; tests cover dict/valid JSON/malformed/array/scalar and non-mutation. AGENTS.md gotcha removal matches the fix. Please rebase + refresh CI (Approve-and-run if needed), then squash-merge.

View PR

Open in Web View Automation 

Sent by Cursor Automation: Release

@burtenshaw burtenshaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@burtenshaw
burtenshaw merged commit cdcd41a into huggingface:main Sep 16, 2026
1 check passed

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refresh review (Wed 2026-09-16)

Still BEHIND main (9b765f8e), but content is still correct: JSON-decode string arguments for Gradio call_tool in deserialize_action_with_preprocessing, with focused tests.

No conflict with #1169. This exact change is already included in #1172 (cdcd41a5). Prefer landing via #1172 (after #1172 drops the unrelated #1000 commit); then close this PR as superseded.

If #1172 is split differently, an on-repo replacement of these four files onto current main is fine.

View PR

Open in Web View Automation 

Sent by Cursor Automation: Release

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.

[Minor Bug] Gradio Playground Step rejects MCP arguments JSON as a string

2 participants