session_id.
episode.py
- Call
set_observation()on every camera tick. It never waits, and it may run on your camera’s thread.get_action()sends the frames the model needs: one per camera for most models, the frames taken while the last chunk ran for models with memory. - Keep the task the same for the whole episode. A new task needs
reset_episode()first. - An idle episode ends after 60 seconds, and its next chunk is refused with
410 session_expired.
Episode resets
An episode lives on one engine. It can end under you: the session moves to another engine, an engine restarts, or the weights behind the model change. The API never answers a chunk from an episode it does not hold. In Python,get_action() raises abstract.EpisodeResetError, with the reason in .reason. Nothing ran and nothing is billed. Drop what you kept from the old episode, such as the rows still to run or an IK seed, and call get_action() again.
Over HTTP, every answer carries episode.id. Send episode: {"id": <that id>} with each chunk that continues it. If its engine does not hold that episode, the chunk is refused with 410 episode_reset, and error.reason is worker_changed, episode_lost, model_swapped or session_resumed. Begin again with one frame per camera, expected_step: 0, a new observation_id, and episode: {"reset": <the reason>}.
Retrying an observation
The Python client does all of this for you. A client of your own:- Chooses a
session_id, and sends a newobservation_idand the nextexpected_step, from 0, with each observation. One call at a time per session. - Resends a lost answer’s request as the same bytes, under the same
observation_id. A replay never runs or bills a second chunk. - On
409 observation_in_progress, waitsRetry-After, then retries the same id. - On
observation_lost, runs nothing for that id and sends the next observation under a new id. - On
observation_outcome_unknown, retries only that id until its outcome is known. - On
409 keyframe_required, sends the frames again under a new id, each named camera’s stream starting at a keyframe.
Idempotency-Key can stand in for observation_id. If both are sent, they must match.
End the episode
reset_episode() ends it, and so does leaving the with block. Over HTTP, POST /v1/end_session with model and session_id. Ending an episode is free.