feat(sandbox): Add stream_logs() and logs command#61
feat(sandbox): Add stream_logs() and logs command#61iiilisan wants to merge 5 commits intoexian/cli-corefrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds live log streaming capabilities to the Aviato SDK and CLI, enabling researchers to tail sandbox output in real time. The implementation follows established patterns from the existing exec streaming functionality and includes comprehensive test coverage.
Changes:
- Added
StreamReader.close()method to cleanly stop streaming operations by canceling the background producer task - Implemented
Sandbox.stream_logs()SDK method wrapping the StreamLogs gRPC RPC with support for follow mode, tail_lines, since_time, and timestamps options - Added
aviato logsCLI command with --follow, --tail, --since, and --timestamps flags - Introduced bounded response queue (
STREAMING_RESPONSE_QUEUE_SIZE = 256) for backpressure in long-lived streams - Added comprehensive documentation including new logging guide and updated existing guides
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/aviato/_types.py |
Added close() method to StreamReader with optional cancel callback support |
src/aviato/_sandbox.py |
Implemented stream_logs() public API and _stream_logs_async() internal streaming logic with line buffering and error handling |
src/aviato/_defaults.py |
Added STREAMING_RESPONSE_QUEUE_SIZE constant for backpressure |
src/aviato/cli/logs.py |
New CLI command with all streaming options and graceful error handling |
src/aviato/cli/__init__.py |
Registered logs command |
tests/unit/aviato/test_types.py |
Unit tests for StreamReader.close() behavior including idempotency and cancel callback |
tests/unit/aviato/test_sandbox.py |
Comprehensive unit tests for stream_logs including partial lines, error handling, and option validation |
tests/unit/aviato/test_cli_logs.py |
CLI tests covering all options, error scenarios, and signal handling |
tests/integration/aviato/test_sandbox.py |
Integration test verifying log streaming doesn't disrupt sandbox operation |
docs/guides/logging.md |
New comprehensive guide for sandbox logging |
docs/guides/*.md |
Updated existing guides to reference log streaming |
examples/interactive_streaming_sandbox.py |
Demonstrates log streaming with exec interaction |
| Various AGENTS.md files | Documentation updates for AI agents |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3b91b0e to
3e75067
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3e75067 to
bfa8efe
Compare
bfa8efe to
794d0c2
Compare
794d0c2 to
4818f32
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4818f32 to
54d0998
Compare
064541b to
7d6a258
Compare
54d0998 to
5a5835e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5a5835e to
cb9e2ee
Compare
cb9e2ee to
921b0ec
Compare
921b0ec to
4a8a0ab
Compare
52dd03e to
648c7f9
Compare
4a8a0ab to
3ec8f84
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3ec8f84 to
0ce07ce
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4f8bbf2 to
0dcc0de
Compare
0dcc0de to
23efa22
Compare
23efa22 to
9398b37
Compare
Add close() method to StreamReader for tearing down background producers. Accepts an optional cancel callback invoked on first close; subsequent calls are idempotent.
Use StreamReader.close() to unblock the stderr drain thread when stdout iteration raises, preventing the thread from hanging.
Add stream_logs() for streaming container logs via gRPC bidirectional streaming. Supports follow mode, tail lines, since-time filtering, and server-side timestamps. Uses bounded queues for backpressure in long-lived follow streams.
Add `cwsandbox logs <sandbox-id>` for streaming container logs. Supports --follow, --tail, --since, and --timestamps options.
Add docs/guides/logging.md covering stream_logs() usage patterns. Update CLI quickstart with logs command examples and cross-references.
9398b37 to
154832d
Compare
Summary
Adds live log streaming to the SDK and CLI, enabling researchers to tail sandbox output in real time.
StreamReader.close()— Cancel the background producer and mark the stream as exhausted, enabling callers to stop follow-mode streams cleanlySandbox.stream_logs()— New SDK method wrapping theStreamLogsgRPC RPC. Returns aStreamReader[str]that yields log lines. Supportsfollow,tail_lines,since_time, andtimestampsoptionscwsandbox logs— CLI command wrappingstream_logs()with--follow,--tail,--since,--timestampsflagsStreamReader.close()to unblock the stderr drain thread on exec failureSTREAMING_RESPONSE_QUEUE_SIZE(256) to propagate backpressure, preventing unbounded memory growth in follow modeDesign decisions
stream_logs()returnsStreamReaderdirectly (not wrapped inOperationRef) since iteration is the blocking operationcancelmethod is wired intoStreamReader.close()so stopping iteration cancels the gRPC stream--sinceacceptsclick.DateTime()default formats (YYYY-MM-DD,YYYY-MM-DD HH:MM:SS), not full ISO 8601 with timezone designatorsTest plan
StreamReader.close()cancellation behaviorcwsandbox logs— all options, iteration errors, not-found handling