container_logs
Retrieve container logs as a one-shot snapshot or bounded live tail, using line and time limits to prevent memory exhaustion and avoid blocking indefinitely.
Instructions
Get the logs of a container: a one-shot snapshot by default, or a bounded live tail with follow=True.
Follow mode returns when limit_lines lines are collected, timeout_seconds elapses, or the
container exits, whichever comes first - so the agent can watch live output without blocking
forever. limit_lines/timeout_seconds apply only in follow mode; until only in snapshot mode.
Snapshot mode is capped at 32 MiB and raises ToolInputError past it, so a noisy container can't
exhaust the server's memory; service_logs caps the same way and lets the caller raise it.
Prefer an integer tail, or since, over tail="all" on a long-running container: "all" is
safe but will abort on the cap rather than returning a partial answer, and a large result can
still exceed the agent's context.
Caveat for ssh:// daemons: docker-py can't cancel an SSH stream, so in follow mode the
timeout_seconds watchdog can't interrupt a fully silent container - use the snapshot mode
there if you need a hard time bound.
Args: tail: Number of lines from the end, or the literal "all" for everything since: Only return logs created after this unix timestamp until: Only return logs created before this unix timestamp (snapshot mode only) follow: Follow the live log stream instead of returning a snapshot limit_lines: Follow mode: max lines to collect before returning timeout_seconds: Follow mode: max wall-clock seconds before returning what was collected
Returns:
str: Decoded log output (up to limit_lines lines in follow mode). Raises ToolInputError in snapshot mode if
the logs exceed 32 MiB.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tail | No | ||
| since | No | ||
| until | No | ||
| follow | No | ||
| stderr | No | ||
| stdout | No | ||
| id_or_name | Yes | ||
| timestamps | No | ||
| limit_lines | No | ||
| timeout_seconds | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |