Skip to content

[fix] correct output formatting for async tool call results#6633

Open
hztBUAA wants to merge 6 commits intoagno-agi:mainfrom
hztBUAA:fix/async-tool-output-formatting
Open

[fix] correct output formatting for async tool call results#6633
hztBUAA wants to merge 6 commits intoagno-agi:mainfrom
hztBUAA:fix/async-tool-output-formatting

Conversation

@hztBUAA
Copy link
Contributor

@hztBUAA hztBUAA commented Feb 19, 2026

Summary

Fixes three formatting inconsistencies between sync run_function_call and async arun_function_calls paths in the model base class.

Fixes #6361

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Code complies with style guidelines
  • Ran ./scripts/format.sh and ./scripts/validate.sh
  • Self-review completed
  • Tests added/updated (9 new tests)

Additional Notes

Bugs fixed:

  1. Non-generator result used function_call.result instead of function_execution_result.result and missed None guard (str(None) -> "None" instead of "")
  2. WorkflowCompletedEvent check was incorrectly nested inside CustomEvent block in async generator processing
  3. Sync generator path in async context was missing WorkflowCompletedEvent handling entirely

@hztBUAA hztBUAA requested a review from a team as a code owner February 19, 2026 21:03
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 706bd27394

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

uzaxirr and others added 3 commits February 25, 2026 20:23
Deduplicate generator item processing and non-generator result
formatting logic across sync/async paths in Model.

- Add _process_generator_item() static method to handle RunContentEvent,
  CustomEvent, WorkflowCompletedEvent, and plain items uniformly
- Add _format_non_generator_result() static method for ToolResult
  extraction and plain value formatting
- Refactor all 3 generator loops and both non-generator paths to use
  the shared helpers
- Fix falsy value bug: use `is not None` instead of truthiness check
  so 0, False, [] format correctly instead of becoming ""
- Move WorkflowCompletedEvent and ToolResult imports to top-level,
  removing 5 inline imports
- Add 7 new tests for helper edge cases and falsy value consistency
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes inconsistencies in how tool-call outputs are accumulated and formatted between the sync run_function_call(s) and async arun_function_calls paths in Model, and adds unit tests to prevent regressions.

Changes:

  • Refactors generator/non-generator tool result handling into shared helpers (_process_generator_item, _format_non_generator_result) to unify formatting behavior.
  • Fixes async tool-call output formatting for None / falsy values and aligns workflow completion event handling across generator paths.
  • Adds a dedicated unit test suite covering sync/async formatting parity and edge cases (None, 0, False, empty list, ToolResult media).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
libs/agno/agno/models/base.py Introduces shared formatting helpers and updates sync/async tool-call result processing to use them.
libs/agno/tests/unit/agent/test_async_tool_formatting.py Adds unit tests to validate consistent formatting and edge-case behavior across sync/async paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Ensures subclass overrides are respected via dynamic dispatch.
@uzaxirr uzaxirr requested a review from Copilot March 5, 2026 16:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

[Bug] Improper output formatting when async tool calls are made.

3 participants