Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions docs/async-orchestrators.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,31 @@ The dispatch-local loop supports FIFO ready callbacks, local futures and tasks,
`asyncio.create_task`, `asyncio.gather`, `asyncio.sleep`, `asyncio.TaskGroup`,
and `asyncio.timeout` / `timeout_at`.
`asyncio.wait_for` uses the same task/future scheduling and durable timers.
On Python 3.11, `asyncio.wait_for` can swallow a cancellation: if the awaited
operation completes and the waiting task is cancelled before it resumes,
`wait_for` returns the result instead of raising `CancelledError`. The
cancelled branch keeps running and can schedule more durable work. Python 3.12+
raises `CancelledError`. On Python 3.11, use `asyncio.timeout()` when
cancellation must stop the branch.
Third-party async libraries are not part of this compatibility contract, even
when individual code paths happen to use supported asyncio primitives.

Create branches from ordered inputs. Ready work follows FIFO scheduling;
history completions are delivered in history order, draining ready work after
each completion. Task-group cancellation wakeups are ordered by local task
creation, not set/object-hash iteration. Local tasks are dispatch resources,
not new durable instances.
creation, not set/object-hash iteration, and keep their FIFO position relative
to other ready callbacks. Local tasks are dispatch resources,
not new durable instances. Create them with `asyncio.create_task` or a task
group; do not construct `asyncio.Task` directly, because such tasks are not
tracked by the dispatch and are not cancelled or cleaned up with it.

`loop.time()` uses seconds from a fixed UTC epoch and the current orchestration
clock, never machine monotonic time. `loop.call_at` and `call_later` schedule
durable timers for future finite deadlines. Timer conversion rounds up when
necessary so a durable timer does not precede its floating-point deadline.
durable timers for future finite deadlines. `call_at` rounds its
floating-point deadline up to the next microsecond when necessary, so a durable
timer never precedes it. `call_later` (and so `asyncio.sleep`) rounds a
positive relative delay up to whole microseconds and adds it to the exact
orchestration time.
Core/Functions long timers reuse the existing chunking; Azure Managed retains
its native long timers. Past deadlines are ready callbacks. `sleep(0)` yields
to ready coroutines without a durable timer. Clock advancement and timers
Expand Down Expand Up @@ -351,6 +363,12 @@ automatic recording or interception of arbitrary await expressions.
`is_replaying` is not a substitute for recording results. Activities remain
at-least-once work: side effects require appropriate idempotency/deduplication.

Successive orchestration dispatches and their activities can run on different
workers. Replay reconstructs local tasks and futures from ordered durable
history; it does not rely on task identities or memory retained by a previous
worker. Activity completion order is the order recorded in history, not worker
placement.

Framework adapters can compose supported durable operations using async
helpers. Adapters remain responsible for registering ordinary model/tool
activities, encoding/decoding framework payloads, and supplying replay-stable
Expand All @@ -369,8 +387,9 @@ construction order is not execution order.

Supporting several Python versions does not guarantee recorded-history
portability between them. Pin the runtime and dependencies for active
instances and validate histories before upgrades; see the Python version
warning above.
instances and validate histories before upgrades. All workers processing an
instance must use that pinned environment; see the Python version warning
above.

The Functions `orchestrator_generator_wrapper` helper drives generator
orchestrators only. Use the real replay executor/provider or the in-memory
Expand Down
Loading