Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

refactor: renaming init_params and run_params to reflect their schema.#332

Merged
lucasgomide merged 1 commit intolg-package-dependenciesfrom
lg-type-json-schema
Jun 16, 2025
Merged

refactor: renaming init_params and run_params to reflect their schema.#332
lucasgomide merged 1 commit intolg-package-dependenciesfrom
lg-type-json-schema

Conversation

@lucasgomide
Copy link
Contributor

We’re currently using the JSON Schema standard for these fields

@joaomdmoura
Copy link
Collaborator

Disclaimer: This review was made by a crew of AI Agents.

Code Review Comment: Tool Specification Generation Refactoring

Overview

The recent refactor of the tool specification generation to utilize JSON Schema standards represents a critical enhancement that improves the maintainability and reliability of the codebase. This effort has transitioned from custom parameter extraction methods to a more standardized approach that leverages Pydantic's JSON Schema capabilities.

Key Findings:

  1. Schema Generation Approach:

    • Before: Manual parameter extraction was cumbersome and prone to errors.
    • After: The _extract_params method now retrieves schemas using model_json_schema, which is much more efficient and error-resistant. This establishes a strong foundation for future enhancements as it adheres to standardized JSON Schema practices.
    • Improvement suggestion: It may be beneficial to add comprehensive inline documentation within the _extract_params function to assist developers in quickly understanding the schema extraction logic.
  2. Custom Schema Generator:

    • The introduction of the SchemaGenerator class for handling invalid schemas is commendable. It provides a clear separation of concerns.
    • Specific Improvement: In error handling, consider using a more structured logging mechanism rather than print() statements, which can be improved by integrating with a logging framework to facilitate better issue tracking.
  3. Test Refactoring:

    • The tests now validate against JSON Schema output, leading to better assurance that the schema behaves as expected.
    • Improvement suggestion: Further expand test coverage by adding negative test cases that ensure the stability of the system against malformed input or edge cases.
  4. Documentation Enhancement:

    • The documentation on the ToolSpecExtractor class should be expanded to clearly define the schemas it generates.
    • Example for enhancement:
      """
      The extractor generates JSON Schema-compliant specifications.
      It covers three main areas: init_params_schema, run_params_schema, and required environment variables.
      """
  5. Schema Validation:

    • Adding a validation mechanism for schemas before returning them is critical. This would help catch issues earlier and ensure compliance with expected formats.
  6. Schema Version Control:

    • The implementation of versioning for the JSON schema brings robustness to your specifications and should be included in the JSON output.

Historical Context and Lessons Learned

The transition to using standardized schemas reflects a broader trend observed in related PRs, wherein teams are leaning towards more modern, maintainable approaches. Historical changes indicate a significant shift from arbitrary formats to formal standards with better support for serialization and validation.

  • Learning: Regular assessments of documentation and testing practices in tandem with code refactoring bolster overall code quality and team understanding.

Conclusion

The refactoring has substantially enhanced the code quality by standardizing the schema generation process, making it more robust and easier to maintain. The changes are expected to yield long-term benefits for the development team and enhance interoperability with other tools and frameworks.

The emphasis on error handling, structured documentation, and testing will pay dividends in both robustness and developer ease of use moving forward. Thank you for your important contributions to this process!

@lucasgomide lucasgomide force-pushed the lg-package-dependencies branch from 578016f to 8a322cb Compare June 16, 2025 13:58
@lucasgomide lucasgomide force-pushed the lg-type-json-schema branch from 5947804 to 339ac49 Compare June 16, 2025 14:00
@lucasgomide lucasgomide force-pushed the lg-package-dependencies branch from 8a322cb to ef06667 Compare June 16, 2025 14:00
We’re currently using the JSON Schema standard for these fields
@lucasgomide lucasgomide force-pushed the lg-type-json-schema branch from 339ac49 to 5f8cdbf Compare June 16, 2025 14:00
@lucasgomide lucasgomide merged commit 1cf412d into lg-package-dependencies Jun 16, 2025
4 checks passed
lucasgomide added a commit that referenced this pull request Jun 16, 2025
#332)

We’re currently using the JSON Schema standard for these fields
lucasgomide added a commit that referenced this pull request Jun 17, 2025
#332) (#333)

We’re currently using the JSON Schema standard for these fields
mplachta pushed a commit to mplachta/crewAI-tools that referenced this pull request Aug 27, 2025
crewAIInc#332) (crewAIInc#333)

We’re currently using the JSON Schema standard for these fields
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants