Skip to Content
Docs

Turns

How a call to Awen's agent runs, how to follow it, and how to get the files it made.

create_with_awen starts a turn: Awen's agent reads your prompt, answers, and starts the generations it needs. It answers at once with a turn_id, while the turn runs.

  1. create_with_awen answers a turn_id at once.
  2. get_turn answers each change while status is working.
  3. Once it is completed, get_turn with include_downloads gives a download_url for each file.

Statuses

statusMeansWhat to do
workingThe agent or one of its generations still runs.Call get_turn again at once.
completedEvery file the turn will make is saved.Read files, or download them.
failedThe turn could not finish. failure says why.Tell your user. Do not retry on your own.
stoppedSomeone stopped the turn, with cancel_turn or in Awen.Nothing more will come.

A turn can end with a question from the agent. Show it to your user and send the answer as a new turn in the same conversation, with conversation_id.

Following a turn

get_turn waits up to wait_seconds (0 to 30) and answers as soon as something changes. Pass back the cursor of the last answer, so you never miss a change between two calls. To follow several turns at once, call get_turns.

  • text is the agent's reply. It is written once, when generations start.
  • tasks and files list what the turn makes, each file with its mime_type, size and dimensions.
  • cost_usd is what the turn cost, once nothing of it still runs.

Downloading files

Call get_turn with include_downloads: true once the turn is completed. Each file then has a download_url that works for 5 minutes. Fetch it with no header: the link itself grants access to that one file.

To download files later, or files from elsewhere in a project, use download with their ids.

Stopping a turn

cancel_turn stops a turn that is still working. What it already made stays in the project.

On this page