Skip to content

Add dynamic schema usage example#14

Open
konard wants to merge 3 commits intotool2agent:masterfrom
konard:issue-3-987722043bf7
Open

Add dynamic schema usage example#14
konard wants to merge 3 commits intotool2agent:masterfrom
konard:issue-3-987722043bf7

Conversation

@konard
Copy link
Copy Markdown

@konard konard commented Dec 27, 2025

Summary

  • Added a new usage example demonstrating the dynamicParameterSchema feature
  • The example shows a dynamic form submission scenario where the expected data structure depends on the selected form type
  • Updated README to include the new example in the examples list
  • Added npm script example:dynamic-schema to run the example

Implementation Details

The dynamic-schema.ts example demonstrates:

  1. Runtime schema discovery: The form data schema changes based on which form type (contact, feedback, or support) is selected
  2. dynamicParameterSchema usage: Returns a Zod schema at runtime to inform the LLM about the exact structure expected for a parameter
  3. Iterative refinement: The LLM learns the schema through validation feedback and retries with correct data structure

Example Scenario

A form submission system with three form types, each requiring different data structures:

  • contact: name, email, message
  • feedback: rating, category, comment (optional)
  • support: ticketId (TKT-XXXX format), priority, description, contactEmail

Test plan

  • Build all packages successfully
  • All unit tests pass (42/42)
  • Type tests pass
  • Lint checks pass
  • Formatting checks pass
  • CI passes on GitHub Actions

Closes

Fixes #3


🤖 Generated with Claude Code

konard and others added 2 commits December 27, 2025 11:49
Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: tool2agent#3
Closes tool2agent#3

This example demonstrates the `dynamicParameterSchema` feature of
tool2agent - a capability for runtime schema discovery where the
expected data structure depends on context.

The example shows a dynamic form submission scenario where:
- The tool validates form data where fields and types are dynamically
  determined based on the selected form type
- The `dynamicParameterSchema` field returns a Zod schema at runtime
  to inform the LLM about the exact structure expected

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Usage example needed: dynamic schema Add dynamic schema usage example Dec 27, 2025
@konard konard marked this pull request as ready for review December 27, 2025 10:57
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard
Copy link
Copy Markdown
Author

konard commented Dec 27, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $3.796955 USD
  • Calculated by Anthropic: $2.588601 USD
  • Difference: $-1.208354 (-31.82%)
    📎 Log file uploaded as GitHub Gist (672KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

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.

Usage example needed: dynamic schema

1 participant