Skip to content

Add on_complete callback to AG-UI functions to get access to AgentRunResult #2429

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChuckJonas
Copy link
Contributor

@ChuckJonas ChuckJonas commented Aug 5, 2025

Fixes #2398

@DouweM DouweM changed the title #2398 ag-ui on_complete callback Add on_complete callback to AG-UI functions to get access to AgentRunResult Aug 6, 2025
@DouweM DouweM self-assigned this Aug 6, 2025
@ChuckJonas ChuckJonas force-pushed the #2398-ag-ui-on-complete-callback branch 3 times, most recently from 7100b97 to a3ad970 Compare August 7, 2025 02:19
@ChuckJonas ChuckJonas force-pushed the #2398-ag-ui-on-complete-callback branch from a3ad970 to 73af2b7 Compare August 7, 2025 02:28
if _utils.is_async_callable(on_complete):
await on_complete(run)
else:
await _utils.run_in_executor(on_complete, run)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DouweM not sure this is what you meant...

if _utils.is_async_callable(on_complete):
    await on_complete(run)

"None" is not awaitable
"None" is incompatible with protocol "Awaitable[_T_co@Awaitable]"
"await" is not present

And

else:
     await _utils.run_in_executor(on_complete, run)

Is saying it's unreachable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, I just ran in my project with both a sync and async callback and it seems to work as expected... Maybe just a type issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Callback/Middleware for responses on run_ag_ui
2 participants