Skip to content

Conversation

@yuancu
Copy link
Contributor

@yuancu yuancu commented Aug 8, 2025

Description

The PR opensearch-project/ml-commons/pull/4053 introduced a change to parameter handling of tools. This leads to several IT failures.

This PR fixes these failures by updating the implementation. It standardizes parameter handling across all Tool implementations:

  • Updates all Tool interface implementations to use the new extractInputParameters utility
  • Updates release notes with these improvements

Related Issues

Resolves #617

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

yuancu added 3 commits August 8, 2025 17:03
- Add utilities for extracting required parameters and JSON input parameters
- Apply parameter extraction in AbstractRetrieverTool and RAGTool
- Define TOOL_REQUIRED_PARAMS constant for consistent parameter handling

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
- Update all Tool interface implementations to use extractInputParameters utility

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
@yuancu yuancu changed the title Issues/617 Update parameter handling of tools Aug 8, 2025
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
* @param attributes The tool attributes containing required parameter information
* @return A map containing only the required parameters or all parameters if no required parameters are specified
*/
public static Map<String, String> extractRequiredParameters(Map<String, String> parameters, Map<String, ?> attributes) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not copy the code, skills has dependency to ml-commons, re-use the method directly, if the module is not introduced, try introduce it or change the code in ml-commons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with library method.

public static final String ALERTING_CONFIG_INDEX = ".opendistro-alerting-config";
public static final String ALERTING_ALERTS_INDEX = ".opendistro-alerting-alerts";

public static final String TOOL_REQUIRED_PARAMS = "required_parameters";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use the constant from ml-commons if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing out. Fixed.

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
@codecov
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.97%. Comparing base (2b76e3c) to head (eec38d6).
⚠️ Report is 87 commits behind head on main.

Files with missing lines Patch % Lines
...a/org/opensearch/agent/tools/utils/ToolHelper.java 68.00% 7 Missing and 1 partial ⚠️
...java/org/opensearch/agent/tools/WebSearchTool.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #618      +/-   ##
============================================
- Coverage     81.78%   74.97%   -6.82%     
- Complexity      193      404     +211     
============================================
  Files            11       24      +13     
  Lines           961     2162    +1201     
  Branches        137      302     +165     
============================================
+ Hits            786     1621     +835     
- Misses          121      438     +317     
- Partials         54      103      +49     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
@zane-neo zane-neo merged commit addf057 into opensearch-project:main Aug 11, 2025
12 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 11, 2025
* Add parameter extraction utilities for tool inputs

- Add utilities for extracting required parameters and JSON input parameters
- Apply parameter extraction in AbstractRetrieverTool and RAGTool
- Define TOOL_REQUIRED_PARAMS constant for consistent parameter handling

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

* Standardize parameter handling in all Tool implementations

- Update all Tool interface implementations to use extractInputParameters utility

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

* Update release note

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

* Declare origin of helper method extractInputParameters

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

* Remove displaced comment in javadoc

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

* Fix failed test in AbstractRetrieverToolTests

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

* Replace copied tool utils to library ones

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>

---------

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
(cherry picked from commit addf057)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@yuancu yuancu deleted the issues/617 branch August 11, 2025 02:34
zane-neo pushed a commit that referenced this pull request Aug 11, 2025
* Add parameter extraction utilities for tool inputs

- Add utilities for extracting required parameters and JSON input parameters
- Apply parameter extraction in AbstractRetrieverTool and RAGTool
- Define TOOL_REQUIRED_PARAMS constant for consistent parameter handling



* Standardize parameter handling in all Tool implementations

- Update all Tool interface implementations to use extractInputParameters utility



* Update release note



* Declare origin of helper method extractInputParameters



* Remove displaced comment in javadoc



* Fix failed test in AbstractRetrieverToolTests



* Replace copied tool utils to library ones



---------


(cherry picked from commit addf057)

Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@yuancu yuancu mentioned this pull request Aug 11, 2025
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AUTOCUT] Integration Test Failed for skills-3.2.0

2 participants