Skip to content

fix(tools): harden fenced and embedded tool selection JSON (#115) - #120

Closed
wxai-space wants to merge 2 commits into
mainfrom
codex/fix-pr115-json-selection
Closed

wxai-space wants to merge 2 commits into
mainfrom
codex/fix-pr115-json-selection

Conversation

@wxai-space

Copy link
Copy Markdown
Collaborator

Summary

  • Preserve the original contributor commits from feat(tools): parse fenced and embedded JSON in filter_tools #115.
  • Parse complete JSON before inspecting fences, preserving fences inside JSON strings.
  • Decode embedded objects structurally, skip unrelated context objects, and reject conflicting selections.
  • Validate selection shapes, preserve empty selections, and never add unregistered tools.
  • Add regression tests and document the parsing contract.

Testing

  • Full tracked suite with locked MCP 1.12.4: 387 passed, 1 opt-in backend test skipped.
  • Focused schema/filter tests: 28 passed.
  • git diff --check passed.

Review

This is a main-repository follow-up with contributor attribution retained. It is submitted for review only; no automatic merge or release is requested. Supersedes the unresolved review gaps in #115.

wjl8636 and others added 2 commits October 7, 2026 17:40
filter_tools only stripped an exact ```json ... ``` fence before
json.loads(). LLM tool-reflection output commonly wraps the payload in a
plain ``` fence (no language tag) or embeds it between prose, which made
the call raise ValueError and abort tool filtering.

Add a best-effort _extract_json_payload() that pulls the payload out of a
fenced block (with or without the json tag), or from the first JSON object,
before falling back to the raw text. Truly invalid input still raises
ValueError, preserving documented behavior.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wxai-space

Copy link
Copy Markdown
Collaborator Author

The combined #120/#121/#122 regression suite passes 420 tests with one opt-in backend test skipped on both locked and modern MCP environments. All four Python-version CI checks on #120 are green. This remains an unmerged review PR, preserving the contributor commits from #115.

@wxai-space

Copy link
Copy Markdown
Collaborator Author

All fixes have now been fast-forwarded directly into the original PR #115 at 0cb40e0. Its new CI run passed all 4 checks: https://github.com/wanxingai/LightAgent/actions/runs/40616538629 . Closing this supplemental PR as redundant, without merging or deleting its branch. Continue review in #115; main is unchanged.

@wxai-space wxai-space closed this Oct 28, 2026
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.

2 participants