> ## Documentation Index
> Fetch the complete documentation index at: https://platform.autumn.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Live messages

> Stream events as the agent plans and executes.

Stream messages as the agent works: planning, tool calls, and progress. Each message has
a `type`, a `summary`, and `data`.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from autumn_sdk import AutumnClient

  client = AutumnClient()

  run = client.stream("Find the top story on Hacker News")
  for msg in run:
      print(f"[{msg.type}] {msg.summary}")

  print(run.result.output)
  ```

  ```python Python (async) theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from autumn_sdk import AsyncAutumnClient

  client = AsyncAutumnClient()

  run = client.run("Find the top story on Hacker News")
  async for msg in run:
      print(f"[{msg.type}] {msg.summary}")

  print(run.result.output)
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { AutumnClient } from "autumn-sdk";

  const client = new AutumnClient();

  const run = client.run("Find the top story on Hacker News");
  for await (const msg of run) {
    console.log(`[${msg.type}] ${msg.summary}`);
  }

  console.log(run.result?.output);
  ```
</CodeGroup>

<Note>
  `run.result` is only available **after** the iterator finishes. In the async Python and
  TypeScript SDKs the same `run` object is both awaitable (`await run` → result) and
  async-iterable (stream messages).
</Note>

## Polling instead of streaming

The blocking `client.run()` (sync Python) or `await client.run()` (async / TypeScript)
already runs to completion and returns the result. Use it when you don't need live
messages:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  result = client.run("Find the top story on Hacker News")
  print(result.output)
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const result = await client.run("Find the top story on Hacker News");
  console.log(result.output);
  ```
</CodeGroup>

## Manual control

For full control over the loop, drive the resources directly:

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import time
from autumn_sdk import AutumnClient
from autumn_sdk.types import is_terminal

client = AutumnClient()
task = client.tasks.create("Find the top story on Hacker News")

while not is_terminal(task):
    time.sleep(2)
    task = client.tasks.get(task.id)

print(client.tasks.output(task.id)["rows"])
```

A finished task returns to `status: "plan"` with `activity: "idle"`. The SDK's
`is_terminal()` accounts for this, so don't poll on `status` alone.

## Raw SSE

Both `POST /task/stream` and `GET /task/{task_id}/stream` emit Server-Sent Events with the
same event names as the dashboard. See the [Task API](/docs/api-routes#stream-events) for the
raw HTTP interface.
