mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #353] bug(logs): Log pagination cursor is inclusive in both directions, duplicating the boundary entry on every page, with no unique entry IDs to dedupe #89
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#89
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tm-worker on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/353
Originally assigned to: @zlzGithub-0801 on GitHub.
Affected component
Sandbox logs API pagination (
GET /v2/sandboxes/{sandboxID}/logs) —src/sandbox/logs.rs,src/api/openapi.ymlAgentENV version
main@34cdc80("feat: add sandbox logs API")Host environment
src/sandbox/logs.rs(git-archive copy ofmain@34cdc80) is compiled via#[path]into a minimal harness that mirrors onlycrate::logging::LogLevel(verbatim fromsrc/logging.rs), so the exercised code path is the actual file. The same test appended to the file's owntestmodule also passes.Operation and configuration
Default configuration; any client that pages through logs using the
cursorparameter. The response (SandboxLogsV2Response,src/api/openapi.yml:413-422) carries no next-token field, so clients must use the last entry's timestamp as the next page's cursor — the natural E2B SDK pattern.Steps to reproduce
Simulate the natural client paging loop against the real
log_query_window+LogPage::push/finish:Observed pages (ms timestamps, last digits shown for clarity):
Page 1's last entry (
…078) is page 2's first entry; page 2's last (…048) is page 3's first — every page boundary entry is served on two consecutive pages, in both directions (forward is symmetric).Expected behavior
Either:
ts < cursor), so consecutive pages never repeat an entry; orThe chosen semantics should be documented in
openapi.yml(the cursor description currently does not mention inclusivity).Actual behavior
src/sandbox/logs.rs:86-99:push()keeps entries withtimestamp < self.start || timestamp > self.end— both bounds inclusive; every page boundary entry is served twice across pages in both directions.SandboxLogsV2Response(src/api/openapi.yml:413-422) contains onlylogs— nonextToken/nextCursorfield; log entries have no unique IDs.src/sandbox/logs.rs:109), so a client cannot distinguish "cursor duplicated this entry" from "the guest really logged this twice".src/sandbox/logs.rs:303-313,sandbox_logs_cursor_is_inclusive_and_handles_int64_max) — so this may be intentional; if so, the cross-page duplication and the lack of a dedupe mechanism should at least be documented.Logs and diagnostics
(One note from the same run: when the dataset spans far less than the 7-day window — as in the test data — the oldest entry repeats until the client's "short page" heuristic stops the loop, since the inclusive window never drops it. With logs spanning the full window, termination happens once
cursor - 7dpasses the oldest entries.)Reproduction frequency
Always, for any query that returns a full page and is paged further (both directions).
Regression information
Not a regression — the pagination semantics shipped with the new logs API (
34cdc80).Additional context
Fix sketch: make the continuation bound exclusive (backward:
ts < cursor; forward:ts > cursor) and updatelogs.rs:303-313accordingly, or add an explicit opaquenext_cursortoSandboxLogsV2Response. Note timestamps are millisecond-truncated, so exclusivity alone still collapses entries sharing the same millisecond — worth deciding explicitly (e.g. tie-break by file/sequence in the cursor). I'm happy to open a PR with the fix and the accompanying test.Pre-submission checklist
src/sandbox/logs.rs).@zlzGithub-0801 commented on GitHub (Oct 14, 2026):
Thanks for reporting this. We’ll keep the current behavior to maintain compatibility with the E2B SDK’s semantics.
@tm-worker commented on GitHub (Oct 14, 2026):
Thanks for the clarification. Would you mind documenting the inclusive cursor
semantics in the OpenAPI
cursordescription for the logs endpoint? Clientspaging with the last entry's timestamp currently have no way to know that the
boundary entry repeats on the next page.