Skip to content

fix(sandbox): report a missing sandbox context apart from a runner outage - #835

Open
hakarrr wants to merge 3 commits into
BaaRai:mainfrom
hakarrr:fix-sandbox-missing-context
Open

hakarrr wants to merge 3 commits into
BaaRai:mainfrom
hakarrr:fix-sandbox-missing-context

Conversation

@hakarrr

@hakarrr hakarrr commented Dec 2, 2026

Copy link
Copy Markdown

Problem

In ARTEX_SANDBOX=required mode, a standalone chat agent (e.g. the built-in Penetration Testing agent) has no SandboxRunInfo on its context, so every Bash call fails closed. Correct behavior - but the error is "sandbox runner unavailable: missing task sandbox context", wrapping ErrRunnerUnavailable. The runner is healthy and was never called; the misclassification sends operators debugging their Docker/runner install, and the model retries Bash, burning LLM turns (both called out in the issue).

Behavior change

Error-reporting slice only; no execution semantics change, fail-closed preserved:

  • sandbox/types.go: new typed sentinel ErrMissingSandboxContext, documented as deliberately NOT runner-unavailable (IsUnavailable unchanged).
  • agent/sandbox.go ExecInSandbox: missing/empty task context now returns that sentinel instead of wrapping ErrRunnerUnavailable. Real runner failures keep the runner-unavailable classification. Only IsUnavailable consumer is the OnUnavailable hook inside ExecInSandbox itself, and missing-context correctly never triggers a runner-outage callback.
  • agent/sandbox.go sandboxBashTool: the missing-context case now returns an explicit, actionable message - no execution context in this standalone conversation, do not retry Bash here, run the work as a task (or set ARTEX_SANDBOX=off) - instead of the generic "sandbox execution failed" the model kept retrying.

Out of scope by design: Option A (standalone sandbox execution lifecycle), hiding execution-capable tools from standalone agents - both are maintainer decisions named in the issue.

What was tested

New agent/sandbox_missing_context_test.go (unit, no PG needed):

  1. Missing context: error matches ErrMissingSandboxContext and IsUnavailable is false.
  2. Context present, runner nil: error is still runner-unavailable and does NOT match ErrMissingSandboxContext (categories stay distinguishable).
  3. sandboxBashTool with missing context: result names the missing context, points at run-as-task, and never says "runner unavailable".

Fail-first evidence: on the clean tree the tests fail to build (undefined sandbox.ErrMissingSandboxContext). With the implementation they pass. Mutating ExecInSandbox back to wrapping ErrRunnerUnavailable makes both tests fail with exactly the old misleading text; restored, green.

Validation run locally (Go): go test ./agent/ ./sandbox/ -count=1 all pass; go vet ./agent/ ./sandbox/ ./server/ clean; go build ./... clean; patch applies cleanly on a pristine worktree of e38f58d.

Contributes to #805.

hakarrr and others added 3 commits December 2, 2026 17:47
…tage

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…tage

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
…tage

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
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.

1 participant