fix: re-raise InputCheckError/OutputCheckError in non-streaming run functions#7636
Closed
VANDRANKI wants to merge 1 commit intoagno-agi:mainfrom
Closed
fix: re-raise InputCheckError/OutputCheckError in non-streaming run functions#7636VANDRANKI wants to merge 1 commit intoagno-agi:mainfrom
VANDRANKI wants to merge 1 commit intoagno-agi:mainfrom
Conversation
…un functions Previously, `_run`, `_arun`, `_continue_run`, and `_acontinue_run` caught `InputCheckError` / `OutputCheckError`, logged the error, performed session cleanup, and then returned the run response silently. This made the try/except pattern shown in the documentation completely ineffective - callers had no way to distinguish a validation failure from a normal successful run. The fix replaces `return run_response` with `raise` in the four non-streaming entry points. Session cleanup and storage happen before the re-raise, so persistence is unaffected. The streaming variants (`_run_stream`, `_arun_stream`, `_continue_run_stream`, `_acontinue_run_stream`) already surface the error via a `RunErrorEvent` yielded to the caller, which is the appropriate contract for a generator-based API. Fixes agno-agi#7414 Co-Authored-By: Waston-Li <[email protected]>
Contributor
PR TriageA few things to address before this PR can be reviewed: Missing tests: This PR modifies source code but does not include any test changes. Please add or update tests to cover your changes. Possible duplicate: The following open PRs also reference the same issue(s):
If this is intentional, please explain in your PR description why this approach is preferred. Otherwise, consider collaborating on the existing PR instead. This PR has been automatically closed. There is already an open PR addressing this issue. If you believe your contribution is valuable, please comment on the original issue explaining your approach and why it might be preferred. A maintainer can reopen this PR if appropriate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The documentation shows callers using
try/except OutputCheckErroraroundagent.run()andagent.arun()to handle output validation failures. This pattern was silently broken: the four non-streaming entry points (_run,_arun,_continue_run,_acontinue_run) caught the exception, logged it, and returned the run response as if nothing went wrong - the caller's except block was never reached.Root cause: the except clause ended with
return run_responseinstead ofraise.Changes
libs/agno/agno/agent/_run.py: In theexcept (InputCheckError, OutputCheckError)block of each non-streaming function, replacereturn run_responsewithraise.def _run(~line 659)async def _arun(~line 1754)def _continue_run(~line 3064)async def _acontinue_run(~line 3862)Session cleanup and storage are performed before the re-raise, so persistence is unaffected.
What stays the same
The streaming variants (
_run_stream,_arun_stream,_continue_run_stream,_acontinue_run_stream) already surface the error correctly by yielding aRunErrorEventto the caller's event loop. Those are unchanged.Reproduces fix for issue #7414
Before:
After:
Fixes #7414