Skip to content

Conversation

brandonmcconnell
Copy link
Contributor

@brandonmcconnell brandonmcconnell commented Oct 2, 2025

TL;DR:

Adapts AG-UI tool result messages for LlamaIndex by converting empty results to a canonical value ("ok").

Prevents unnecessary re-invocation of tools in LlamaIndex workflows when tools return no meaningful payload.

Explanation

I did some testing and found that whenever I returned a value from the useCopilotAction hook's handler, the big wouldn't occur (had to do a ton of testing to avoid false positives).

This leads me to think that LlamaIndex handles empty tool result values as falsy in a sense, or a failure, and reattempts the request, tool call and all. Returning a value prevents this.

To patch this in @ag-ui/llamaindex, I reconfigured the LlamaIndexAgent class to intercept those empty values and return content: "ok" in place of the empty or undefined value.

Possible gotcha ⚠️

If there are cases where a failed tool call would result in an undefined/empty value, we would need to be able to distinguish them from these successful tool calls that return the same value.

Adapts AG-UI tool result messages for LlamaIndex by converting empty results to a canonical value ("ok").

Prevents unnecessary re-invocation of tools in LlamaIndex workflows when tools return no meaningful payload.
@brandonmcconnell
Copy link
Contributor Author

I cut a prerelease version (@ag-ui/[email protected]) for this branch to test before releasing. I'll un-draft this PR and merge once it's approved and the fix is verified.

attn @tylerslaton @ranst91

@brandonmcconnell brandonmcconnell marked this pull request as ready for review October 2, 2025 20:13
Copy link
Contributor

@tylerslaton tylerslaton left a comment

Choose a reason for hiding this comment

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

Nice catch.

@brandonmcconnell brandonmcconnell merged commit 1b34f9a into main Oct 2, 2025
18 checks passed
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.

2 participants