Skip to content

sandbox: do not flag expected not-found reads as errored spans#3890

Closed
knQzx wants to merge 1 commit into
openai:mainfrom
knQzx:fix/skill-read-span-expected-error
Closed

sandbox: do not flag expected not-found reads as errored spans#3890
knQzx wants to merge 1 commit into
openai:mainfrom
knQzx:fix/skill-read-span-expected-error

Conversation

@knQzx

@knQzx knQzx commented Jul 20, 2026

Copy link
Copy Markdown

summary

fixes #3889. LocalDirLazySkillSource.load_skill() probe reads a not yet materialized SKILL.md. the inner session correctly raises WorkspaceReadNotFoundError, load_skill catches it and proceeds, but the sandbox.read trace span was already marked errored by the instrumentation decorator, so a normal first time skill load surfaces a spurious errored span

this adds an expected_errors tuple to instrumented_op and _annotate. when a raised exception matches, the audit finish event still records it (retryability included) but the trace span is not flagged as errored, and the exception is re-raised unchanged. read declares WorkspaceReadNotFoundError as expected

one scope decision worth confirming: declaring this on the read op means it applies to every read, so a direct session.read() of a missing file also stops producing an errored span, though the audit event still records it. that felt right to me since a not found read is an expected, recoverable condition rather than a sandbox failure, but if you would rather keep direct reads visibly errored and only silence the load_skill probe i can switch to a per-call opt-in instead

test plan

  • new test drives a first time load_skill against a not yet materialized file and asserts the single sandbox.read span has error is None and the skill loads
  • updated test_sandbox_session_error_events_and_traces_include_retryability so a not found read no longer flags the span while the audit event still carries error_retryable
  • ruff, ruff format, mypy, and the full tests/sandbox suite pass

closes #3889

Let instrumented ops declare expected exceptions via expected_errors so a
raised expected error is still recorded on the audit finish event but does
not mark the trace span as errored. Apply it to read for
WorkspaceReadNotFoundError, which a first-time lazy load_skill probe read
triggers by design.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9cd5523f14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@instrumented_op(
"read",
data=_read_start_data,
expected_errors=(WorkspaceReadNotFoundError,),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep direct read failures visible in traces

By putting WorkspaceReadNotFoundError on the read decorator, every failed session.read() that raises this error is treated as a non-error span, not just the lazy-skill existence probe. In a caller trace around await session.read(Path("missing.txt")) (and Docker also maps any non-zero cat read, such as permission denied, to this error), the operation still raises and the audit finish event has ok=False, but the trace contains no error, so direct sandbox read failures disappear from trace-based debugging. Make the suppression a per-probe/per-call opt-in instead of global to read.

Useful? React with 👍 / 👎.

@seratch

seratch commented Jul 20, 2026

Copy link
Copy Markdown
Member

Thanks for sharing this idea. The issue was resolved by #3893

@seratch seratch closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lazy skill first load records expected WorkspaceReadNotFoundError as a failed span

2 participants