Skip to content

fix(agent-sdk): stop polling when the wait deadline expires - #46515

Merged
BeautyyuYanli merged 2 commits into
langgenius:mainfrom
Wang-Zephyr:fix/agent-sdk-poll-deadline
Nov 17, 2026
Merged

BeautyyuYanli merged 2 commits into
langgenius:mainfrom
Wang-Zephyr:fix/agent-sdk-poll-deadline

Conversation

@Wang-Zephyr

Copy link
Copy Markdown
Contributor

Fixes #46514

Summary

Recheck the deadline after each polling sleep in the synchronous and asynchronous Dify Agent SDK. The existing initial status check and HTTP request timeout still apply. Once the polling deadline expires, the SDK raises its existing timeout error before starting the next request.

Verification

  • On the base, both new HTTPX transport regressions issue a second request and return its terminal status instead of raising. On the fix, each sends one request and raises DifyAgentTimeoutError.
  • uv run --no-sync pytest -q tests/local/dify_agent/client/test_client.py passed all 51 tests.
  • The broader Windows run hit the same pre-existing test_client_safe_exports.py error on base and fix. That fixture refers to a POSIX bin/python inside a Windows venv.
  • Ruff format and lint passed for the changed files. Targeted Pyrefly reported 0 errors.

Checklist

  • Linked the issue and verified the regression against the base and fix.

From Codex

@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 16, 2026

@BeautyyuYanli BeautyyuYanli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(This message is automated while I'm responsible for it.)

LGTM. Rechecking deadline immediately after _sleep_async / _sleep_sync cleanly stops wait_run and wait_run_sync from starting an extra status poll once timeout_seconds expires while preserving the initial status check and per-request HTTP timeout semantics. The parametrized sync/async PollingClock regression test covers the boundary directly.

@BeautyyuYanli
BeautyyuYanli added this pull request to the merge queue Nov 17, 2026
Merged via the queue into langgenius:main with commit 8135711 Nov 17, 2026
38 checks passed
@wylswz wylswz mentioned this pull request Nov 17, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dify Agent wait_run polls once more after the timeout deadline

2 participants