Skip to content

Graceful fallback from update-task-v2 to v1 when server doesn't support it#385

Merged
v1r3n merged 2 commits intomainfrom
v2_compatiblity_mode
Apr 21, 2026
Merged

Graceful fallback from update-task-v2 to v1 when server doesn't support it#385
v1r3n merged 2 commits intomainfrom
v2_compatiblity_mode

Conversation

@v1r3n
Copy link
Copy Markdown
Contributor

@v1r3n v1r3n commented Mar 11, 2026

Summary

  • Auto-detect when the server doesn't support the POST /tasks/update-v2 endpoint (HTTP 404 or 501) and seamlessly fall back to the standard POST /tasks endpoint for the lifetime of the runner
  • On fallback, the tight execute loop exits and the worker resumes normal poll-based operation — no task results are lost
  • Detection happens once per runner on the first failed v2 call; all subsequent updates go directly to v1 with no overhead
  • Added unit tests (11) covering both sync TaskRunner and async AsyncTaskRunner: fallback on 404/501, subsequent calls skip v2, v2 success path unchanged, non-404 errors don't trigger fallback, v1 retry on
    fallback failure
  • Added integration test that runs real workflows against the server and verifies completion regardless of v2 availability

Test plan

  • Unit tests: python -m pytest tests/unit/automator/test_v2_fallback.py -v (11 passed)
  • Existing tests: python -m pytest tests/unit/automator/ -v (235 passed, no regressions)
  • Integration perf test: python -m pytest tests/integration/test_update_task_v2_perf.py -v -s (1000 workflows, p50 queue wait 26ms)
  • Integration fallback test: python -m pytest tests/integration/test_v2_fallback_intg.py -v -s (against server without v2 support)

- Take main's version for task_runner.py and async_task_runner.py
  (includes transient error handling, 404/405 detection)
- Update test_v2_fallback.py: _v2_available -> _use_update_v2,
  501 -> 405, fix e2e test infinite loop (mock batch_poll to return
  empty on second call)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 57 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@v1r3n v1r3n merged commit 4ae0014 into main Apr 21, 2026
2 checks passed
@v1r3n v1r3n deleted the v2_compatiblity_mode branch April 21, 2026 00:28
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.

2 participants