Skip to content

fix: keep polling wait_for_result on call_not_ready - #40

Open
Arshgill01 wants to merge 1 commit into
CALLE-AI:mainfrom
Arshgill01:fix/wait-call-not-ready
Open

Arshgill01 wants to merge 1 commit into
CALLE-AI:mainfrom
Arshgill01:fix/wait-call-not-ready

Conversation

@Arshgill01

Copy link
Copy Markdown

What

CalleCalls.wait_for_result continues polling when GET /v1/calls/{id} returns CalleAPIError with code == "call_not_ready", until the existing deadline. Other API errors still raise.

Why

https://docs.heycall-e.com/errors.md says: "call_not_ready means the call task has not reached a terminal state." That is a poll-again signal. The waiter had no special case, so any 4xx from get() ended the loop after one request.

This touches the same wait_for_result loop as #30 (status vs result predicate, and polling-argument validation). This PR does not change those. It only treats the documented call_not_ready code as non-terminal.

Does not touch non-JSON JSONDecodeError handling (#39).

Evidence

Offline, httpx/respx only. No live API request and no phone call.

Before: mocked GET 409 {error:{code:"call_not_ready", message:"The call task has not reached a terminal state."}} then a completed body.

wait_for_result(..., interval_seconds=0.001, timeout_seconds=0.5)
# raised CalleAPIError code == "call_not_ready"
# route.call_count == 1

After:

uv run --locked pytest -q tests/test_calls.py
.........                                                                [100%]
9 passed in 0.25s

uv run --locked ruff check src/calle/calls.py tests/test_calls.py
All checks passed!

uv run --locked mypy src/calle
Success: no issues found in 6 source files

test_wait_for_result_retries_call_not_ready asserts the completed call and route.call_count == 2.

Test

uv run --locked pytest -q tests/test_calls.py and ruff / mypy as above.

Source

From the CALL-E hackathon feedback lab: https://github.com/Arshgill01/ExactRef/blob/main/docs/feedback/lab/XR-806-call-not-ready-aborts-wait.md

Made with Cursor

Docs define call_not_ready as not terminal yet, so the waiter
should poll again until the deadline instead of raising after one GET.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant