[PR #338] [MERGED] feat: add sandbox logs API #360

Closed
opened 2026-10-29 14:22:35 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/AgentENV/pull/338
Author: @zlzGithub-0801
Created: 10/2/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @yingdi-shan

Base: main ← Head: feat/sandbox-logs


📝 Commits (1)

  • 394f40a feat: add sandbox logs API

📊 Changes

23 files changed (+1715 additions, -80 deletions)

View changed files

📝 services/gateway/internal/server.go (+3 -0)
📝 services/gateway/internal/server_test.go (+3 -0)
📝 src/api/generated/src/apis/sandboxes.rs (+28 -0)
📝 src/api/generated/src/models.rs (+359 -0)
📝 src/api/generated/src/server/mod.rs (+170 -0)
📝 src/api/impls/image_build/tests.rs (+8 -11)
📝 src/api/impls/mod.rs (+22 -0)
📝 src/api/impls/sandbox.rs (+52 -0)
📝 src/api/impls/template.rs (+5 -23)
📝 src/api/openapi.yml (+91 -0)
📝 src/api/proxy.rs (+52 -0)
📝 src/api/server.rs (+26 -0)
📝 src/image/buildkit/history.rs (+13 -12)
📝 src/logging.rs (+11 -0)
📝 src/orchestrator/service.rs (+77 -1)
📝 src/orchestrator/tests.rs (+113 -0)
📝 src/sandbox/backend.rs (+15 -0)
📝 src/sandbox/envd.rs (+276 -4)
📝 src/sandbox/firecracker/sandbox.rs (+18 -0)
➕ src/sandbox/logs.rs (+315 -0)

...and 3 more files

📄 Description

What

Add the E2B-compatible GET /v2/sandboxes/{sandboxID}/logs API for querying logs from a running sandbox.

Why

AgentENV previously had no sandbox log query API compatible with E2B. This allows callers to inspect envd operational logs and stderr without storing sandbox logs in host memory or persistent files.

#5

Scope and non-goals

Included:

  • E2B-compatible v2 sandbox logs API and query parameters.
  • envd structured logs, including current and rotated files.
  • /var/log/agentenv/envd.stderr.log.
  • Cursor, direction, level, search, and limit handling.
  • Streaming downloads with a 32 MiB query limit.

Excluded:

  • Deprecated v1 logs API.
  • User process stdout/stderr.
  • Firecracker and control-plane logs.
  • Persisting logs across pause or restart.
  • Logs for paused sandboxes; these requests return an error.

Design and behavior changes

For a running sandbox, AgentENV uses its sandbox-specific EnvdInstance to query the guest filesystem.

Normal envd logs are read from:

/var/log/agentenv/envd/current
/var/log/agentenv/envd/@...s

These files contain structured envd logs collected by svlogd.

Envd stderr is read from:

/var/log/agentenv/envd.stderr.log

Compatibility and operations

  • Public API or generated protocol: Adds GET /v2/sandboxes/{sandboxID}/logs and corresponding generated server/models.
  • Configuration or defaults: N/A
  • Snapshot manifest, artifact layout, or storage format: N/A
  • Upgrade and rollback: N/A
  • Host requirements, permissions, ports, or dependencies: N/A

Validation

  • make fmt
  • make clippy
  • make test-unit
  • Relevant Rust integration tests
  • make -C services test (required when services/ changes)
  • Generated clients/server regenerated with the documented make target
  • Documentation updated
  • Benchmarks or performance comparison completed

Risks and reviewer notes

  • Log queries read at most 32 MiB per request and temporarily retain matching decoded entries for sorting.
  • Logs are unavailable after a sandbox is paused.

Checklist

  • The PR contains one coherent change and no unrelated formatting or refactoring.
  • New behavior is covered by tests, or I explained why testing is impractical.
  • Logs and examples contain no credentials, tokens, or private registry information.
  • I did not manually edit generated code without updating its source and regenerating it.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/kvcache-ai/AgentENV/pull/338 **Author:** [@zlzGithub-0801](https://github.com/zlzGithub-0801) **Created:** 10/2/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@yingdi-shan](https://github.com/yingdi-shan) **Base:** `main` ← **Head:** `feat/sandbox-logs` --- ### 📝 Commits (1) - [`394f40a`](https://github.com/kvcache-ai/AgentENV/commit/394f40aee009371a0cfe5afbb8acf11c760936b7) feat: add sandbox logs API ### 📊 Changes **23 files changed** (+1715 additions, -80 deletions) <details> <summary>View changed files</summary> 📝 `services/gateway/internal/server.go` (+3 -0) 📝 `services/gateway/internal/server_test.go` (+3 -0) 📝 `src/api/generated/src/apis/sandboxes.rs` (+28 -0) 📝 `src/api/generated/src/models.rs` (+359 -0) 📝 `src/api/generated/src/server/mod.rs` (+170 -0) 📝 `src/api/impls/image_build/tests.rs` (+8 -11) 📝 `src/api/impls/mod.rs` (+22 -0) 📝 `src/api/impls/sandbox.rs` (+52 -0) 📝 `src/api/impls/template.rs` (+5 -23) 📝 `src/api/openapi.yml` (+91 -0) 📝 `src/api/proxy.rs` (+52 -0) 📝 `src/api/server.rs` (+26 -0) 📝 `src/image/buildkit/history.rs` (+13 -12) 📝 `src/logging.rs` (+11 -0) 📝 `src/orchestrator/service.rs` (+77 -1) 📝 `src/orchestrator/tests.rs` (+113 -0) 📝 `src/sandbox/backend.rs` (+15 -0) 📝 `src/sandbox/envd.rs` (+276 -4) 📝 `src/sandbox/firecracker/sandbox.rs` (+18 -0) ➕ `src/sandbox/logs.rs` (+315 -0) _...and 3 more files_ </details> ### 📄 Description ## What Add the E2B-compatible `GET /v2/sandboxes/{sandboxID}/logs` API for querying logs from a running sandbox. ## Why AgentENV previously had no sandbox log query API compatible with E2B. This allows callers to inspect envd operational logs and stderr without storing sandbox logs in host memory or persistent files. ## Related issue #5 ## Scope and non-goals Included: - E2B-compatible v2 sandbox logs API and query parameters. - envd structured logs, including `current` and rotated files. - `/var/log/agentenv/envd.stderr.log`. - Cursor, direction, level, search, and limit handling. - Streaming downloads with a 32 MiB query limit. Excluded: - Deprecated v1 logs API. - User process stdout/stderr. - Firecracker and control-plane logs. - Persisting logs across pause or restart. - Logs for paused sandboxes; these requests return an error. ## Design and behavior changes For a running sandbox, AgentENV uses its sandbox-specific `EnvdInstance` to query the guest filesystem. Normal envd logs are read from: ```text /var/log/agentenv/envd/current /var/log/agentenv/envd/@...s ``` These files contain structured envd logs collected by `svlogd`. Envd stderr is read from: ```text /var/log/agentenv/envd.stderr.log ``` ## Compatibility and operations - Public API or generated protocol: Adds `GET /v2/sandboxes/{sandboxID}/logs` and corresponding generated server/models. - Configuration or defaults: N/A - Snapshot manifest, artifact layout, or storage format: N/A - Upgrade and rollback: N/A - Host requirements, permissions, ports, or dependencies: N/A ## Validation - [x] `make fmt` - [x] `make clippy` - [x] `make test-unit` - [x] Relevant Rust integration tests - [x] `make -C services test` (required when `services/` changes) - [x] Generated clients/server regenerated with the documented `make` target - [ ] Documentation updated - [ ] Benchmarks or performance comparison completed ## Risks and reviewer notes - Log queries read at most 32 MiB per request and temporarily retain matching decoded entries for sorting. - Logs are unavailable after a sandbox is paused. ## Checklist - [x] The PR contains one coherent change and no unrelated formatting or refactoring. - [x] New behavior is covered by tests, or I explained why testing is impractical. - [x] Logs and examples contain no credentials, tokens, or private registry information. - [x] I did not manually edit generated code without updating its source and regenerating it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 14:22:35 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/AgentENV#360
No description provided.