Skip to content

vllm_omni.engine.duplex.session.append_task

One append in flight, and what its failure owes the session.

An append is not a call: it is a task queued behind the previous append, which may be cancelled, may find the session closed before it starts, and on any of those paths has to give back what it reserved --- the PCM bytes it took from the input budget, the committed audio it was going to consume, and the response it precreated.

That compensation is the reason this is an object. The five steps of an append all need the same eleven values, so as closures over _start_append they read as one function with five entry points and no way to test any of them. Named fields make the captured state explicit and the compensation a method.

The precreated response has two other owners the compensation defers to. When the runner cancels the append on purpose (DuplexSessionTasks.cancel_append_tasks, for a response.cancel, a barge-in or a close), the runner ends that response itself right after, with the cancel status the client asked for. When the session is already closing, the close ends it. Everywhere else, the append is the last thing that knows the response will never be filled, and it fails it.

logger module-attribute

logger = init_logger(__name__)

AppendAttempt dataclass

One queued append to the model, with the rollback each failure path owes.

before_append class-attribute instance-attribute

before_append: Callable[[], bool] | None = None

ctx instance-attribute

epoch instance-attribute

epoch: int

fail_session instance-attribute

fail_session: Callable[[str], None]

final instance-attribute

final: bool

model instance-attribute

model: ModelChannel

on_append_accepted class-attribute instance-attribute

on_append_accepted: Callable[[float], None] | None = None

operation_id instance-attribute

operation_id: str | None

out instance-attribute

owns_request class-attribute instance-attribute

owns_request: bool = False

payload instance-attribute

payload: dict[str, object]

pcm_reservation instance-attribute

pcm_reservation: PcmAppendReservation | None

precreated_response_id instance-attribute

precreated_response_id: str | None

request_id instance-attribute

request_id: str

retained_committed_payload instance-attribute

retained_committed_payload: dict[str, object] | None

abandon

abandon(
    *,
    reason: str = "runtime_append_failed",
    response_taken_over: bool = False,
) -> None

Give back everything this append reserved but never used.

That includes the response it precreated: once the append is off, nothing will ever fill it, and a client that saw response.created is owed a response.done. It is left alone only when somebody else ends it: the runner that cancelled this append on purpose (response_taken_over) or the close already under way.

clear_pending_silence

clear_pending_silence(done: Task[bool]) -> None

Done-callback of a silence continuation: it is no longer pending.

discard_retained_audio

discard_retained_audio() -> None

Release the committed audio this append was going to consume.

Only if it is still the session's: a later commit may have replaced it, and that one belongs to the append that will carry it.

release_on_failure

release_on_failure(done: Task[bool]) -> None

Done-callback: a cancelled or failed append must not hold the audio.

run_in_wire_order async

run_in_wire_order(predecessor: Task[bool] | None) -> bool

Wait for the previous append, then submit this one if it still applies.

A cancellation is compensated here, wherever it lands (waiting for the predecessor or mid-submit): the reservations go back, and the precreated response is failed unless the runner cancelled the append itself, in which case it ends the response with the status the cancellation was for.