Skip to content

Add Tool Schema Flatness (TSF) constraint#28

Merged
tylerpayne merged 2 commits intomainfrom
constraint/tool-schema-flatness
Oct 11, 2025
Merged

Add Tool Schema Flatness (TSF) constraint#28
tylerpayne merged 2 commits intomainfrom
constraint/tool-schema-flatness

Conversation

@tylerpayne
Copy link
Collaborator

The "flatness" (i.e. lack of nested structured objects/lists) of a tool's inputSchema can dramatically impact an agent's tool-calling accuracy.

This constraint reports a warning if any of your server's tools have nested inputSchemas.

See: https://composio.dev/blog/gpt-4-function-calling-example

To check flatness, uses the jsonschema library to parse the inputSchema and check for

  1. Nested objects
  2. Nested arrays
  3. Nesting via refs

Tyler Payne added 2 commits October 11, 2025 11:14
The "flatness" (i.e. lack of nested structured objects/lists) of a tool's inputSchema can dramatically impact an agent's tool-calling accuracy.

This constraint reports a warning if any of your server's tools have nested inputSchemas.

See: https://composio.dev/blog/gpt-4-function-calling-example
@tylerpayne tylerpayne requested a review from Copilot October 11, 2025 15:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a Tool Schema Flatness (TSF) constraint that validates tool input schemas are "flat" without nested objects or arrays. This constraint aims to improve agent tool-calling accuracy by preventing complex nested structures that can confuse agents.

  • Added ToolInputSchemaFlatnessConstraint class with comprehensive schema flatness validation
  • Integrated the constraint into the existing constraint system with CLI support
  • Added comprehensive test coverage for various schema patterns including edge cases

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/mcp_interviewer/constraints/tool_schema_flatness.py Implements the core constraint logic with nested structure detection and JSON Schema reference resolution
tests/constraints/test_tool_schema_flatness.py Comprehensive test suite covering flat schemas, nested objects, arrays, references, unions, and edge cases
src/mcp_interviewer/constraints/__init__.py Registers the new constraint in the constraint system
src/mcp_interviewer/cli.py Updates CLI help text to include the new TSF constraint code
pyproject.toml Adds required dependencies for jsonschema and pytest

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tylerpayne tylerpayne merged commit f5d866f into main Oct 11, 2025
5 checks passed
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