-
Notifications
You must be signed in to change notification settings - Fork 37
fix(toolbox-core): parse parameter default value from tool schema #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(toolbox-core): parse parameter default value from tool schema #538
Conversation
The ParameterSchema model was missing the default field, causing Pydantic to drop the default value provided in the tool schema. This resulted in the default value not being reflected in the tool's signature. Fixes googleapis#506
|
Hello @dishaprakash, I've pushed a fix for the syntax error (non-default argument follows default argument) that was causing the CI to fail. I also added the missing inspect.Parameter import and updated the Pydantic utility to ensure consistency across schema defaults. Local verification confirms that all 114 unit tests across the Core, LangChain, and LlamaIndex packages are now passing. Ready for re-review. |
|
/gcbrun |
|
Really appreciate the PR. Thanks! Would it be possible for you to take a look at the failling lint and the tests as well? |
|
Sure Anubhav ill try to fix it tomorrow
Happy to help 😄
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Just a request to fix the presubmits.
|
@anubhav756 take a look I think its resolved now |
Context
Issue #506 reported that default values defined in
tools.yamlwere not being parsed correctly by the Python SDK. Specifically, parameters with adefaultvalue were not reflecting this default in the tool's signature or execution logic. This caused tools to require arguments that should have been optional, or fail to use the configured defaults.Solution
The root cause was identified in
toolbox_core.protocol.ParameterSchema. The Pydantic model for parameter schema was missing thedefaultfield. Consequently, thedefaultvalue from the API response was being ignored during parsing.This PR:
default: Optional[Any] = Noneto theParameterSchemamodel inpackages/toolbox-core/src/toolbox_core/protocol.py.ParameterSchema.to_param()to explicitly useself.defaultif it is not None, falling back to existing logic (None or Empty) otherwise.packages/toolbox-core/tests/test_protocol.pyto verify that defaults are correctly parsed and applied to the generatedinspect.Parameterobjects.Verification
toolbox-core(tests/test_protocol.py,tests/test_tool.py) and verified they pass. Added new unit tests covering default value parsing.Alternatives Considered
ToolboxTool: Considered handling defaults inToolboxTool.__init__by iterating over params, but the issue was fundamentally in the data model parsing (ParameterSchema). Fixing it at the schema level ensures correctness whereverParameterSchemais used.