Skip to content

fix(runtime): preserve failed sandbox terminal outcomes in streamAgentTurn #781

Description

@drewstone

Reproduction

Create a sandbox executor whose stream emits:

  • { type: "error", data: { message: "sandbox failed" } }
  • { type: "done", data: { status: "failed" } }

Drain it through streamAgentTurn.

Actual

The final Runtime event has status: "completed", reason: "turn completed", and a structurally valid verdict.

Expected

The final event remains failed and preserves any measured token and cost receipt from the stream.

Cause

The sandbox executor treats any parsed output as a valid winner. streamAgentTurn then assigns completed whenever executor execution resolves. Neither layer reads the terminal sandbox outcome.

Downstream evidence

Braid reproduced this against agent-runtime 0.131.7 and added a boundary guard so failed sandbox events cannot appear successful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions