Skip to content

add content info when validate tool paras' schema error#729

Open
sinberCS wants to merge 2 commits intoagentscope-ai:mainfrom
sinberCS:fix/issue#727
Open

add content info when validate tool paras' schema error#729
sinberCS wants to merge 2 commits intoagentscope-ai:mainfrom
sinberCS:fix/issue#727

Conversation

@sinberCS
Copy link

@sinberCS sinberCS commented Feb 5, 2026

fix issue #727

before
image

after
image

Change-Id: Ib2b920ace1e76356737b2915db72e966f9e42a74
@sinberCS sinberCS requested a review from a team February 5, 2026 03:13
@cla-assistant
Copy link

cla-assistant bot commented Feb 5, 2026

CLA assistant check
All committers have signed the CLA.

@gemini-code-assist
Copy link

Summary of Changes

Hello @sinberCS, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the debugging experience for developers working with tools by providing more informative error messages. When tool parameters fail schema validation, the error message will now include the actual content that was passed, making it much easier to diagnose and correct parameter-related issues. This directly addresses issue #727, as demonstrated by the 'before' and 'after' images in the PR description.

Highlights

  • Enhanced Error Messages: Improved the clarity of error messages for tool parameter validation failures by including the actual content that caused the validation issue, making debugging easier.
  • Code Formatting: Reordered import statements in ToolExecutor.java for better code organization and consistency.
Changelog
  • agentscope-core/src/main/java/io/agentscope/core/tool/ToolExecutor.java
    • The error message for tool parameter validation failures now includes the Actual content of the toolCall, providing more context for debugging.
    • Import statements were reordered.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@cla-assistant
Copy link

cla-assistant bot commented Feb 5, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the error message for tool parameter validation failures by including the actual content that failed validation. While this is beneficial for debugging, it introduces a potential security risk by exposing raw input data in the returned error message. My review includes a suggestion to log the detailed error for debugging purposes while returning a less verbose, secure error message to the caller, mitigating the risk of sensitive data exposure.

Comment on lines 149 to 158
String errorMsg =
String.format(
"Parameter validation failed for tool '%s': %s\n"
+ "Actual content: %s\n"
+ "Please correct the parameters and try again.",
toolCall.getName(), validationError);
toolCall.getName(),
validationError,
toolCall.getContent());
logger.debug(errorMsg);
return Mono.just(ToolResultBlock.error(errorMsg));

Choose a reason for hiding this comment

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

security-high high

Including the raw toolCall.getContent() in the error message that is returned can lead to sensitive data exposure. If the tool's input contains secrets like API keys, passwords, or personal data, they would be leaked into the ToolResultBlock, which might be propagated to other systems or logs with higher visibility than debug logs.

To mitigate this, it's better to include the Actual content only in the debug log message and not in the error message returned to the caller.

            String baseError = String.format("Parameter validation failed for tool '%s': %s", toolCall.getName(), validationError);
            logger.debug(baseError + "\nActual content: " + toolCall.getContent() + "\nPlease correct the parameters and try again.");
            return Mono.just(ToolResultBlock.error(baseError + "\nPlease correct the parameters and try again."));

Change-Id: I9ee09aa574c4e9b16f729514fad4d4d00d2cfd88
@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ain/java/io/agentscope/core/tool/ToolExecutor.java 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant