### Sandbox Agents This release adds **Sandbox Agents**, a beta SDK surface for running agents with a persistent, isolated workspace. Sandbox agents keep the normal `Agent` and `Runner` flow, but add workspace manifests, sandbox-native capabilities, sandbox clients, snapshots, and resume support so agents can work over real files, run commands, edit repositories, generate artifacts, and continue work across runs. Key pieces: - `SandboxAgent`: an `Agent` with sandbox defaults such as `default_manifest`, sandbox instructions, capabilities, and `run_as`. - `Manifest`: a fresh-workspace contract for files, directories, local files, local directories, Git repos, environment, users, groups, and mounts. - `SandboxRunConfig`: per-run sandbox wiring for client creation, live session injection, serialized session resume, manifest overrides, snapshots, and materialization concurrency limits. - Built-in capabilities for shell access, filesystem editing and image inspection, skills, memory, and compaction. - Workspace snapshots and serialized sandbox session state for reconnecting to existing work or seeding a fresh sandbox from saved contents. ### Sandbox clients and hosted providers Sandbox agents now support local, containerized, and hosted execution backends: - `UnixLocalSandboxClient` for fast local development. - `DockerSandboxClient` for container isolation and image parity. - Hosted sandbox clients for Blaxel, Cloudflare, Daytona, E2B, Modal, Runloop, and Vercel through optional extras. The release also adds provider-specific examples and mount strategies for common storage backends, including S3, Cloudflare R2, Google Cloud Storage, Azure Blob Storage, and S3 Files where supported by the selected backend. ### Sandbox memory Adds a sandbox memory capability that lets future sandbox-agent runs learn from prior runs. Memory stores extracted lessons in the sandbox workspace, injects a concise summary into later runs, and uses progressive disclosure so agents can search deeper rollout summaries only when useful. Memory supports: - Read-only or generate-only modes. - Live updates when the agent discovers stale memory. - Multi-turn grouping through `conversation_id`, SDK `Session`, `RunConfig.group_id`, or generated run IDs. - Separate memory layouts for isolating memory across agents or workflows. - S3-backed examples for persisted memory across runs. ### Workspace mounts, snapshots, and resume This release adds a full workspace entry and mount model for sandbox sessions: - Local files and directories. - Synthetic files and directories. - Git repository entries. - Remote storage mounts for S3, R2, GCS, Azure Blob Storage, and S3 Files. - Provider-specific mount strategies across Docker, Modal, Cloudflare, Blaxel, Daytona, E2B, and Runloop. - Portable snapshots with path normalization, symlink preservation, mount-safe snapshotting, and remote snapshot support. - Resume paths through runner-managed `RunState`, explicit `SandboxSessionState`, or saved snapshots. ### Examples and tutorials Adds a large `examples/sandbox/` suite covering: - Local Unix and Docker sandbox runners. - Docker mount smoke tests for S3, GCS, Azure Blob Storage, and S3 Files. - Sandbox coding tasks with skills. - Sandbox agents as tools and handoff patterns. - Memory examples, including multi-agent/multi-turn memory and S3-backed memory. - Tax-prep and healthcare-support workflows. - Dataroom QA and metric extraction tutorials. - Repository code review tutorial. - Vision website clone tutorial. - Provider examples for Blaxel, Cloudflare, Daytona, E2B, Modal, Runloop, Temporal, and Vercel. ### Runtime, tracing, and model plumbing The release includes the runtime plumbing needed to make sandbox agents work naturally inside the existing SDK: - Runner-managed sandbox preparation, capability binding, session lifecycle, state serialization, and resume behavior. - Sandbox-aware `RunState` serialization. - Unified sandbox tracing with SDK spans. - Token usage on tracing spans. - Runner-managed prompt cache key defaults. - OpenAI agent registration and harness ID configuration. - Safer redaction of sensitive MCP tool outputs when sensitive tracing is disabled. - Additional OpenAI client/model utilities and Chat Completions coverage. ## Documentation & Other Changes - docs: add Asqav to external tracing processors list. - docs: update translated document pages. Co-authored-by: Abdulrahman Alfozan <alfozan@openai.com> Co-authored-by: Aditya Singh <60082699+adityasingh2400@users.noreply.github.com> Co-authored-by: Andi Liu <andi@openai.com> Co-authored-by: Aron <263346377+aron-cf@users.noreply.github.com> Co-authored-by: ashwinnathan-openai <ashwinnathan@openai.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: cploujoux <cploujoux@blaxel.ai> Co-authored-by: elainegan-openai <168589666+elainegan-openai@users.noreply.github.com> Co-authored-by: Elias Freider <freider@users.noreply.github.com> Co-authored-by: Erik Dunteman <erik@erikds-macbook-air.local> Co-authored-by: Jason Liu <jasonliu@openai.com> Co-authored-by: Jason Steving <32336750+jasonsteving99@users.noreply.github.com> Co-authored-by: Kazuhiro Sera <seratch@openai.com> Co-authored-by: Lovre Pešut <lovre.pesut@gmail.com> Co-authored-by: Lucas Wang <lucas_wang@lucas-futures.com> Co-authored-by: Matt Brockman <matt.brockman@e2b.dev> Co-authored-by: Mish Ushakov <mishushakov@users.noreply.github.com> Co-authored-by: Naresh <ghostwriternr@gmail.com> Co-authored-by: nicholasclark-openai <nicholasclark@openai.com> Co-authored-by: qiyaoq-oai <qiyaoq@openai.com> Co-authored-by: Scott Trinh <scott@scotttrinh.com> Co-authored-by: tode-rl <tony@runloop.ai> Co-authored-by: Wendy Jiao <wendyjiao@openai.com>
315 lines
10 KiB
Python
315 lines
10 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import csv
|
|
import sys
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
from typing import TYPE_CHECKING, TypeAlias
|
|
|
|
if __package__ is None or __package__ == "":
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
|
if TYPE_CHECKING or __package__:
|
|
from .schemas import FinancialMetric, FinancialMetricBatch
|
|
else:
|
|
from schemas import FinancialMetric, FinancialMetricBatch
|
|
|
|
MetricKey: TypeAlias = tuple[str, str, str, str | None]
|
|
|
|
EXPECTED_SOURCE_METADATA: dict[str, str] = {
|
|
"data/10-k-mdna-overview.txt": (
|
|
"Part II, Item 7. Management's Discussion and Analysis of Financial Condition and "
|
|
"Results of Operations"
|
|
),
|
|
"data/10-k-mdna-liquidity.txt": (
|
|
"Part II, Item 7. Management's Discussion and Analysis of Financial Condition and "
|
|
"Results of Operations"
|
|
),
|
|
"data/10-k-note-segments.txt": ("Part II, Item 8. Financial Statements and Supplementary Data"),
|
|
"data/10-k-note-geography.txt": (
|
|
"Part II, Item 8. Financial Statements and Supplementary Data"
|
|
),
|
|
"data/10-k-note-balance-sheet.txt": (
|
|
"Part II, Item 8. Financial Statements and Supplementary Data"
|
|
),
|
|
"data/10-k-statements-of-operations.pdf": (
|
|
"Part II, Item 8. Financial Statements and Supplementary Data"
|
|
),
|
|
"data/10-k-balance-sheets.pdf": (
|
|
"Part II, Item 8. Financial Statements and Supplementary Data"
|
|
),
|
|
"data/10-k-statements-of-cash-flows.pdf": (
|
|
"Part II, Item 8. Financial Statements and Supplementary Data"
|
|
),
|
|
}
|
|
|
|
EXPECTED_ROWS: dict[MetricKey, tuple[float, str]] = {
|
|
("data/10-k-mdna-overview.txt", "Revenue", "FY2025", None): (1284.0, "USD millions"),
|
|
("data/10-k-mdna-overview.txt", "Revenue", "FY2024", None): (1008.0, "USD millions"),
|
|
("data/10-k-mdna-overview.txt", "Gross margin", "FY2025", None): (71.4, "percent"),
|
|
("data/10-k-mdna-overview.txt", "Gross margin", "FY2024", None): (68.2, "percent"),
|
|
("data/10-k-mdna-overview.txt", "Operating income", "FY2025", None): (186.0, "USD millions"),
|
|
("data/10-k-mdna-overview.txt", "Operating income", "FY2024", None): (118.0, "USD millions"),
|
|
(
|
|
"data/10-k-mdna-liquidity.txt",
|
|
"Net cash provided by operating activities",
|
|
"FY2025",
|
|
None,
|
|
): (248.0, "USD millions"),
|
|
(
|
|
"data/10-k-mdna-liquidity.txt",
|
|
"Net cash provided by operating activities",
|
|
"FY2024",
|
|
None,
|
|
): (192.0, "USD millions"),
|
|
("data/10-k-mdna-liquidity.txt", "Capital expenditures", "FY2025", None): (
|
|
86.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-mdna-liquidity.txt", "Capital expenditures", "FY2024", None): (
|
|
73.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-mdna-liquidity.txt", "Free cash flow", "FY2025", None): (
|
|
162.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-mdna-liquidity.txt", "Free cash flow", "FY2024", None): (
|
|
119.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-note-segments.txt", "Platform segment revenue", "FY2025", "Platform"): (
|
|
942.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-note-segments.txt", "Platform segment revenue", "FY2024", "Platform"): (
|
|
711.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-note-segments.txt", "Services segment revenue", "FY2025", "Services"): (
|
|
342.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-note-segments.txt", "Services segment revenue", "FY2024", "Services"): (
|
|
297.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-note-geography.txt", "Americas revenue", "FY2025", "Americas"): (
|
|
764.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-note-geography.txt", "EMEA revenue", "FY2025", "EMEA"): (
|
|
343.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-note-geography.txt", "APAC revenue", "FY2025", "APAC"): (
|
|
177.0,
|
|
"USD millions",
|
|
),
|
|
(
|
|
"data/10-k-note-balance-sheet.txt",
|
|
"Cash and cash equivalents",
|
|
"2025-12-31",
|
|
None,
|
|
): (422.0, "USD millions"),
|
|
(
|
|
"data/10-k-note-balance-sheet.txt",
|
|
"Cash and cash equivalents",
|
|
"2024-12-31",
|
|
None,
|
|
): (351.0, "USD millions"),
|
|
("data/10-k-note-balance-sheet.txt", "Deferred revenue", "2025-12-31", None): (
|
|
402.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-note-balance-sheet.txt", "Deferred revenue", "2024-12-31", None): (
|
|
337.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-operations.pdf", "Net revenue", "FY2025", None): (
|
|
1284.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-operations.pdf", "Net revenue", "FY2024", None): (
|
|
1008.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-operations.pdf", "Gross profit", "FY2025", None): (
|
|
917.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-operations.pdf", "Gross profit", "FY2024", None): (
|
|
687.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-operations.pdf", "Operating income", "FY2025", None): (
|
|
186.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-operations.pdf", "Operating income", "FY2024", None): (
|
|
118.0,
|
|
"USD millions",
|
|
),
|
|
(
|
|
"data/10-k-balance-sheets.pdf",
|
|
"Cash and cash equivalents",
|
|
"2025-12-31",
|
|
None,
|
|
): (422.0, "USD millions"),
|
|
(
|
|
"data/10-k-balance-sheets.pdf",
|
|
"Cash and cash equivalents",
|
|
"2024-12-31",
|
|
None,
|
|
): (351.0, "USD millions"),
|
|
("data/10-k-balance-sheets.pdf", "Accounts receivable", "2025-12-31", None): (
|
|
211.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-balance-sheets.pdf", "Accounts receivable", "2024-12-31", None): (
|
|
187.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-balance-sheets.pdf", "Deferred revenue", "2025-12-31", None): (
|
|
402.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-balance-sheets.pdf", "Deferred revenue", "2024-12-31", None): (
|
|
337.0,
|
|
"USD millions",
|
|
),
|
|
(
|
|
"data/10-k-statements-of-cash-flows.pdf",
|
|
"Net cash provided by operating activities",
|
|
"FY2025",
|
|
None,
|
|
): (248.0, "USD millions"),
|
|
(
|
|
"data/10-k-statements-of-cash-flows.pdf",
|
|
"Net cash provided by operating activities",
|
|
"FY2024",
|
|
None,
|
|
): (192.0, "USD millions"),
|
|
("data/10-k-statements-of-cash-flows.pdf", "Capital expenditures", "FY2025", None): (
|
|
86.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-cash-flows.pdf", "Capital expenditures", "FY2024", None): (
|
|
73.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-cash-flows.pdf", "Free cash flow", "FY2025", None): (
|
|
162.0,
|
|
"USD millions",
|
|
),
|
|
("data/10-k-statements-of-cash-flows.pdf", "Free cash flow", "FY2024", None): (
|
|
119.0,
|
|
"USD millions",
|
|
),
|
|
}
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class EvalSummary:
|
|
row_count: int
|
|
|
|
|
|
def load_metrics(artifact_path: Path) -> FinancialMetricBatch:
|
|
if artifact_path.suffix == ".jsonl":
|
|
metrics = [
|
|
FinancialMetric.model_validate_json(line)
|
|
for line in artifact_path.read_text(encoding="utf-8").splitlines()
|
|
if line.strip()
|
|
]
|
|
return FinancialMetricBatch(metrics=metrics)
|
|
|
|
if artifact_path.suffix == ".csv":
|
|
with artifact_path.open(encoding="utf-8", newline="") as input_file:
|
|
reader = csv.DictReader(input_file)
|
|
metrics = []
|
|
for row in reader:
|
|
row["segment"] = row["segment"] or None
|
|
row["value"] = float(row["value"])
|
|
metrics.append(FinancialMetric.model_validate(row))
|
|
return FinancialMetricBatch(metrics=metrics)
|
|
|
|
raise ValueError(f"Unsupported artifact type: {artifact_path}")
|
|
|
|
|
|
def validate_outputs(metrics: FinancialMetricBatch) -> EvalSummary:
|
|
rows = metrics.metrics
|
|
duplicate_keys: list[MetricKey] = []
|
|
seen_keys: set[MetricKey] = set()
|
|
rows_by_key: dict[MetricKey, FinancialMetric] = {
|
|
(
|
|
row.source_file.strip(),
|
|
row.metric_name.strip(),
|
|
row.fiscal_period,
|
|
row.segment.strip() if row.segment else None,
|
|
): row
|
|
for row in rows
|
|
}
|
|
|
|
for row in rows:
|
|
row_key = (
|
|
row.source_file.strip(),
|
|
row.metric_name.strip(),
|
|
row.fiscal_period,
|
|
row.segment.strip() if row.segment else None,
|
|
)
|
|
if row_key in seen_keys:
|
|
duplicate_keys.append(row_key)
|
|
seen_keys.add(row_key)
|
|
|
|
if duplicate_keys:
|
|
raise AssertionError(f"Duplicate metric rows found: {sorted(set(duplicate_keys))}.")
|
|
|
|
if len(rows) != len(EXPECTED_ROWS):
|
|
raise AssertionError(
|
|
f"Expected exactly {len(EXPECTED_ROWS)} metric rows, found {len(rows)}."
|
|
)
|
|
|
|
for source_file, expected_section in EXPECTED_SOURCE_METADATA.items():
|
|
source_rows = [row for row in rows if row.source_file.strip() == source_file]
|
|
if not source_rows:
|
|
raise AssertionError(f"Missing rows from {source_file}.")
|
|
bad_sections = {
|
|
row.filing_section for row in source_rows if row.filing_section != expected_section
|
|
}
|
|
if bad_sections:
|
|
raise AssertionError(
|
|
f"{source_file} filing_section mismatch. Expected {expected_section}, found {bad_sections}."
|
|
)
|
|
|
|
missing_rows = [
|
|
key
|
|
for key, (expected_value, expected_unit) in EXPECTED_ROWS.items()
|
|
if key not in rows_by_key
|
|
or rows_by_key[key].value != expected_value
|
|
or rows_by_key[key].unit != expected_unit
|
|
]
|
|
if missing_rows:
|
|
observed = sorted(rows_by_key)
|
|
raise AssertionError(
|
|
f"Missing or mismatched expected metric rows: {missing_rows}. Observed keys: {observed}."
|
|
)
|
|
|
|
unexpected_rows = sorted(set(rows_by_key) - set(EXPECTED_ROWS))
|
|
if unexpected_rows:
|
|
raise AssertionError(f"Unexpected metric rows found: {unexpected_rows}.")
|
|
|
|
return EvalSummary(row_count=len(rows))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
"--artifact-path",
|
|
default=str(Path(__file__).resolve().parent / "output" / "financial_metrics.jsonl"),
|
|
help="Path to the generated JSONL or CSV artifact.",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
summary = validate_outputs(load_metrics(Path(args.artifact_path)))
|
|
print(f"Eval checks passed for {summary.row_count} metric row(s).")
|