Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: improve decorated tool output #499

Merged
merged 7 commits into from
Mar 6, 2025
Merged

Conversation

michael-desmond
Copy link
Contributor

  1. Replaces to_string on tool output with python str override
  2. Tool results are now printed in agents notebook
  3. Decorated tools that return str can now work with Agent (output is wrapped as StringToolOutput)
  4. Error checking in notebooks for search tool failures

Checklist

  • I have read the contributor guide
  • I have signed off on my commit
  • Linting passes: yarn lint or yarn lint:fix
  • Formatting is applied: yarn format or yarn format:fix
  • Unit tests pass: yarn test:unit
  • E2E tests pass: yarn test:e2e
  • Tests are included
  • Documentation is changed or added
  • Commit messages and PR title follow conventional commits

@michael-desmond michael-desmond requested a review from a team as a code owner March 6, 2025 03:36
Signed-off-by: MICHAEL DESMOND <mdesmond@us.ibm.com>
Signed-off-by: MICHAEL DESMOND <mdesmond@us.ibm.com>
@ajbozarth ajbozarth added the python Python related functionality label Mar 6, 2025
else:
return tool_function(**tool_input_dict)
return StringToolOutput(result=str(result))
Copy link
Contributor

Choose a reason for hiding this comment

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

should this also check if result is dict then use JSONToolOutput else default to StringToolOutput?

@@ -46,7 +46,7 @@ class OpenMeteoToolInput(BaseModel):
)


class OpenMeteoTool(Tool[OpenMeteoToolInput, ToolRunOptions]):
class OpenMeteoTool(Tool[OpenMeteoToolInput, ToolRunOptions, StringToolOutput]):
Copy link
Contributor

Choose a reason for hiding this comment

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

now that we have JSONToolOutput isnt the output from OpenMeteo more accurately a JSONToolOutput instead of StringToolOutput?

@michael-desmond michael-desmond merged commit 0dbacf9 into main Mar 6, 2025
5 checks passed
@michael-desmond michael-desmond deleted the fix/tool_outputs branch March 6, 2025 14:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
python Python related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants