← Back to Pull requests

fix(zai): propagate file listing errors when all requests fail #3721

Open
unknown opened this pull request with 319 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 24, 2026 07:58 UTC
Author

Why are these changes needed?

Z.AI file listing queries three purposes concurrently. Currently, if every request fails, AG2 filters out all errors and returns []. Authentication failures, service errors, and timeouts therefore look like a successful empty listing.

Raise the first original SDK error in purpose order when all requests fail. Keep the existing best-effort behavior when any request succeeds, even if that successful response is empty. The concurrent requests are still awaited together; there are no changes to retries, dependencies, or public parameters.

The regression tests exercise FilesAPI with a real Z.AI SDK client through ZAIConfig.http_client. They cover HTTP 401/429/500/503, timeouts, complete success, and partial success with empty and nonempty results. No AG2 internals or SDK methods are patched.

Validation (Python 3.12.13, Debian 12/WSL, zai-sdk 0.2.3):

  • The new tests fail on unchanged production code: 5 failed, 16 passed. With the fix: 21 passed.

  • A separate real-SDK/loopback-HTTP reproduction verifies the all-401/all-503 fix and unchanged successful and partial listings.

  • A public-API cancellation check passes before and after the change.

  • Default just test: 9,158 passed, 11 skipped, 2 xfailed, 453 deselected. The unchanged base has 9,145 passed and identical skipped/xfail outcomes; all 13 additional cases pass and every existing outcome matches.

  • Ruff lint/format and mypy pass for both changed files; git diff --check passes.
  • The 11 skips cover unavailable sounddevice/redis-server and Windows-only or google-genai 2.x-only tests; the two xfails are pre-existing markers. This used the locked test/optionals/types dependencies with CPU-only torch, not the full CI platform/version matrix or live provider tests.

    Related issue number

    Fixes #3720

    Checks

  • I've included any doc changes needed for https://docs.ag2.ai/. See https://docs.ag2.ai/latest/docs/contributor-guide/documentation/ to build and test documentation locally.

  • I've added tests (if relevant) corresponding to the changes introduced in this PR.

  • I've made sure all auto checks have passed.
  • The provider method's docstring now describes complete failure versus partial success. Remote CI is pending.

    AI assistance

  • I understand the changes in this PR and can explain them in my own words.

  • I have verified that the PR description accurately reflects the actual diff.

  • If AI assistance was used, I reviewed, tested, and validated the generated code/text before submitting.
  • Diff: 319 lines (+239 / -80) across 3 files Reviewer: chrikrah Review duration: 393m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 319 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3721"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.6% · Safe to merge
    21.6%
    Repository