<!-- zibby-template-version: 4 -->
# /zibby-tail — stream live logs from a Zibby agent

You are helping the user tail logs from an agent execution.

`zibby agent logs <jobId> -t` is the live-streaming variant (like `heroku logs --tail` or `docker compose logs -f`). Without `-t`, you get a one-shot fetch.

Canonical docs: **https://docs.zibby.app/workflows/logs**

## What `<jobId>` accepts

- A **agent UUID** (`2b1ea07f-...`) → tails ALL currently-active executions of that agent, plus any new ones triggered while the tail is open. Lines are interleaved by arrival time, prefixed with `(taskId)` so concurrent runs are distinguishable.
- An **execution ID** (`abc-...`) → tails just that single execution. Closes when the execution drains.

## Example flow

```
$ zibby agent trigger 2b1ea07f-3ede-4bfd-a51d-431f0bab008e
Job ID: 569ef1ee-15c8-4ee7-af30-933c8bec7ea7

$ zibby agent logs 2b1ea07f-3ede-4bfd-a51d-431f0bab008e -t
  Streaming logs for agent 2b1ea07f-...
  Press Ctrl+C to stop.

  ┌─ Execution: 569ef1ee...7ea7 (task: 9e61c690)
  └─ Streaming logs...

2026-05-04 06:16:27.621  (9e61c690) zibby v0.1.91
2026-05-04 06:16:27.997  (9e61c690)  Agent:  hello-world
2026-05-04 06:16:33.055  (9e61c690) │ Prompt sent to LLM:
...
2026-05-04 06:16:56.389  (9e61c690) ✓ Agent completed
```

## Tail behavior worth knowing

- **Auto-switch:** when the current execution drains and a new trigger lands, the tail seamlessly picks it up — no need to re-run the command.
- **Multi-attach:** if you trigger two agents in parallel, the tail attaches to both. Lines from each are interleaved by timestamp.
- **Reconnect:** transient network blips reconnect silently. Long quiet windows (3+ min) are kept alive via 5s keepalives.

## Steps for this command

1. Identify the jobId. If user gives an agent name (not UUID), look it up via `zibby agent list` and use the UUID.
2. **Run in the background** — `-t` is a long-running stream. If you call `Bash` without `run_in_background: true` it'll block the chat for minutes:
   ```
   Bash({ command: "zibby agent logs <jobId> -t", run_in_background: true })
   ```
   Then use `BashOutput` (or whatever your background-output tool is) to read new lines as they arrive.
3. If the user wants a **one-shot snapshot** (no follow), drop the `-t` flag and call Bash normally:
   ```
   Bash({ command: "zibby agent logs <jobId>" })
   ```
4. To stop the live tail: kill the background bash task. The CLI exits cleanly with `Stopped streaming.`
