Python: Preserve the AG-UI RUN_ERROR code in AGUIChatClient - #8830
Open
Gabriel (gabe-santana) wants to merge 1 commit into
Open
Gabriel (gabe-santana) wants to merge 1 commit into
Gabriel (gabe-santana) wants to merge 1 commit into
Conversation
AGUIEventConverter built RUN_ERROR error content with a hard-coded "RUN_ERROR" code, so AGUIChatClient callers could not tell apart the specific codes the AG-UI server sends, such as APPROVAL_INVOCATION_DISABLED or APPROVAL_RESUME_NOT_FOUND. Use the event's code when present and keep "RUN_ERROR" as the fallback. Fixes microsoft#8828
Gabriel (gabe-santana)
deployed
to
github-app-auth
September 29, 2026 13:00 — with
GitHub Actions
Active
Gabriel (gabe-santana)
deployed
to
github-app-auth
September 29, 2026 13:00 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation matches the protocol behavior and includes appropriate regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Preserves server-provided AG-UI RUN_ERROR codes while retaining the existing fallback.
Changes:
- Maps event
codetoContent.error_code. - Adds converter and streaming-client regression coverage.
| File | Description |
|---|---|
python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py |
Preserves server error codes. |
python/packages/ag-ui/tests/ag_ui/test_event_converters.py |
Tests converter behavior. |
python/packages/ag-ui/tests/ag_ui/test_ag_ui_client.py |
Tests streaming propagation. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
Please fix the failing CI/CD checks. |
This branch was successfully deployed
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.
Motivation & Context
The AG-UI server in this package sends a specific
codewith eachRUN_ERRORevent so clients can tell failures apart. Examples areAPPROVAL_INVOCATION_DISABLED(the approved tool stays pending for an explicit retry),APPROVAL_RESUME_NOT_FOUND,WORKFLOW_CHECKPOINT_LOAD_FAILED, and the exception type name for unexpected failures.AGUIChatClientdiscarded that code.AGUIEventConverter._handle_run_errorcreated the error content with a hard-codederror_code="RUN_ERROR", so a Python caller got"RUN_ERROR"for every failure and couldn't decide whether to retry, re-submit a resume, or give up. The hard-coded value dates from the first version of the client (#2072), before the server sent specific codes.Description & Review Guide
_handle_run_errornow uses the event'scodeas the error content'serror_code, falling back to"RUN_ERROR"when the event has no code.AGUIChatClientcallers now see the server's error code. Events without a code produce the same result as before. There are no public API changes.error_codeitself or kept elsewhere, for example inadditional_properties. Usingerror_codematches what the AG-UI event means and keeps the existing fallback.Validation:
test_run_error_event_preserves_server_code(converter) andtest_get_response_streaming_preserves_run_error_code(AGUIChatClientstreaming). Both fail on currentmainand pass with this change. The existingtest_run_error_event, which has nocode, still passes.AGUIChatClient, now reportsTimeoutErrorinstead ofRUN_ERROR.uv run poe test -P ag-ui: 1395 passed, 14 skipped.uv run poe syntax -P ag-uianduv run poe test-typing -P ag-uipass.ag_ui_a2ui_toolkitimport errors as on unchangedmain.Related Issue
Fixes #8828
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.