Skip to content

bug(cli): --no-keep discards the sandbox audit logs; OCSF lines also flush 1-2 s after exit #4295

Open

Description

@anthonychung

Version. OpenShell 0.1.2, Docker driver. Observed 2026-09-29.

Observed. After a sandbox created with --no-keep exits, openshell logs <name> answers "sandbox not found" and the sandbox's OCSF lines are gone. Separately, OCSF lines arrive 1–2 s after the sandboxed process exits, so a logs call issued immediately after exit misses the tail even on a kept sandbox.

Why it matters. --no-keep is the natural setting for an ephemeral agent run, and the audit log is the one artefact a security review needs from that run. As shipped, the convenient flag and the audit trail are mutually exclusive, and nothing warns about it.

Repro.

openshell sandbox create --no-keep --name t1 -- sh -c 'echo hello'
openshell logs t1   # sandbox not found

Ask.

  1. Retain logs for a configurable period after a --no-keep sandbox is deleted, or at minimum print a warning on --no-keep that logs will not be retrievable.
  2. A logs --wait (or documented flush latency) so a caller can collect the complete stream before teardown.

Related: #4297 asks for the retention and on-disk location of sandbox/OCSF logs to be documented.

Activity

  1. github-actions commented on Oct 22, 2026

    @github-actions

    This issue has had no activity for 14 days and is now marked stale. It may be closed in 14 days if there is no further activity. Comment or remove the state:stale label to keep it open.

  2. krishicks commented on Oct 23, 2026

    @krishicks
    Collaborator

    Thanks for the report. We're treating this as a feature request rather than a bug, with the scope reframed as follows.

    Retaining logs after a sandbox exits. --no-keep deleting the sandbox and its gateway-side log buffer is expected today, but we think the gateway should retain, or at least be able to retain, a sandbox's logs for some period after it exits. The gateway already holds the human-readable OCSF shorthand for the sandbox in memory, so serving it for a while after the sandbox is gone is a natural extension of what openshell logs already does. How long to retain is not clear yet (a fixed default, a configurable period, size caps) and needs a design decision.

    Why not just a collector. Configuring [openshell.gateway.otlp.ocsf] is the supported way to keep a durable audit trail, and the supervisor flushes the exporter on exit. But a collector receives the OCSF JSONL, not the shorthand, so it does not give the readable view this issue asks for.

    The 1-2 s tail. Retention depends on this. The OTLP exporter flushes on shutdown, so the late lines are most likely on the gateway log-stream path that openshell logs reads. If the tail is lost there, retained logs will be incomplete, so the flush-on-exit behavior needs to be investigated and fixed as part of this work. Until then, a logs call right after exit can miss the last lines.

    Smaller pieces that can land independently:

    Open question: what retention period and limits make sense for retained logs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:triage-neededOpened without agent diagnostics and needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions