[fix] correct output formatting for async tool call results#6633
[fix] correct output formatting for async tool call results#6633hztBUAA wants to merge 6 commits intoagno-agi:mainfrom
Conversation
There was a problem hiding this comment.
💡 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".
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
There was a problem hiding this comment.
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.
Summary
Fixes three formatting inconsistencies between sync
run_function_calland asyncarun_function_callspaths in the model base class.Fixes #6361
Type of change
Checklist
./scripts/format.shand./scripts/validate.shAdditional Notes
Bugs fixed:
function_call.resultinstead offunction_execution_result.resultand missed None guard (str(None)->"None"instead of"")WorkflowCompletedEventcheck was incorrectly nested insideCustomEventblock in async generator processingWorkflowCompletedEventhandling entirely