Skip to content

fix(utils): improve JSON schema tool input prompting#28

Open
syf2211 wants to merge 2 commits into
wong2:mainfrom
syf2211:fix/anyof-json-schema-inputs
Open

fix(utils): improve JSON schema tool input prompting#28
syf2211 wants to merge 2 commits into
wong2:mainfrom
syf2211:fix/anyof-json-schema-inputs

Conversation

@syf2211

@syf2211 syf2211 commented Jun 27, 2026

Copy link
Copy Markdown

Summary

Improves interactive tool argument prompting for JSON Schema edge cases in readJSONSchemaInputs.

Motivation

Changes

  • Extract buildJSONSchemaQuestions with deduplication via normalized property keys
  • Fix required detection by walking the root schema instead of the anyOf variant parent
  • Add resolvePromptType to handle multi-type arrays and prompt for JSON values when needed
  • Re-prompt with a clear error when JSON parsing fails
  • Add node:test coverage and a pnpm test script

Tests

  • node --test src/utils.test.js — 3 tests, all pass
  • pnpm test — all pass

Notes

  • JSON fields show a (JSON) hint in the prompt message
  • Optional fields left blank are still omitted from the tool args (existing behavior)

Fixes #24
Fixes #2

syf2211 added 2 commits June 27, 2026 18:11
Normalize property paths from anyOf/oneOf variants and deduplicate
prompts by property key. Resolve required flags from the owning object
schema so anyOf variants still honor required fields.

Fixes wong2#24
Handle properties whose type is an array of JSON Schema types (e.g.
object/array/string/number/boolean/null) by prompting for a JSON value,
validating parse errors, and parsing it before calling the tool.

Also add a package test script for node:test.

Fixes wong2#2
@syf2211 syf2211 changed the title fix(utils): prompt once for anyOf JSON schema properties fix(utils): improve JSON schema tool input prompting Jun 27, 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.

readJSONSchemaInputs behaves incorrectly for anyOf CLI not asking for all tools arguments

1 participant