agentleFS
blaxel-aiblaxel-ai/cma-blaxel-sandbox/AGENTS.md

cma-blaxel-sandbox

AGENTS.md4 starsChanged 3 months agoMITView on GitHub

Orientation for an AI coding agent, or a human, working in this repo. Read this first for the fastest correct run. Run Claude Managed Agents (CMA) tool execution on Blaxel sandboxes. Anthropic hosts the agent loop and environment work queue; Blaxel provides the self-hosted execution layer. Two Blaxel sandbox roles: Public quickstart: README.md. Narrative guide source: GUIDE.md. Machine summary: llms.txt. Fast path: python3 bootstrap.py --plan shows the next action, and python3 bootstrap.py runs deterministic setup until the two Anthropic Console…

  • Reads credentials
  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Run Claude Managed Agents (CMA) tool execution on Blaxel sandboxes.

    line 7
  2. Very specific:

    Every tool call must produce non-empty output.

    line 94
  3. Very specific:

    Use one active work-claiming path per self-hosted environment during proof runs.

    line 104
  4. Very specific:

    Use one Anthropic environment per Blaxel workspace.

    line 105
  5. Very specific:

    Before running commands that create real Anthropic sessions/environments/agents, register webhooks, push sandbox images, create/delete …

    line 112
  6. Very specific:

    Do not push, open PRs, merge, change repo visibility, update Linear/GitHub/Slack, or publish docs without explicit human approval.

    line 113

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Orientation for an AI coding agent, or a human, working in this repo. Read this first for the fastest correct run.

What this is

Run Claude Managed Agents (CMA) tool execution on Blaxel sandboxes. Anthropic hosts the agent loop and environment work queue; Blaxel provides the self-hosted execution layer.

Two Blaxel sandbox roles:

  • orchestrator/: FastAPI webhook dispatcher with bounded worker starts, claim retries, and queued-work recovery.
  • worker/: Quickstart or full SDK EnvironmentWorker runtime. It runs tools in /workspace, synchronizes attached memory stores, and owns the work heartbeat.

Public quickstart: README.md. Narrative guide source: GUIDE.md. Machine summary: llms.txt.

Prerequisites

  • Blaxel workspace, bl CLI logged in with bl login, Docker running locally, BL_WORKSPACE, and a service-account BL_API_KEY. BL_API_KEY does not replace CLI login for bl push.
  • Claude Managed Agents beta access and an ANTHROPIC_API_KEY.
  • python3; create a venv and install locked deps with python3 -m venv .venv && source .venv/bin/activate && python -m pip install --require-hashes -r requirements-dev.lock.
  • Copy .env.example to .env, fill it in, then load it with set -a; source .env; set +a.

Setup, in order

Fast path: python3 bootstrap.py --plan shows the next action, and python3 bootstrap.py runs deterministic setup until the two Anthropic Console gates. Bootstrap reads .env directly and uses the default image publish names; use the manual commands below if you need custom bl push --name ... image names in a shared workspace.

  1. python3 scripts/preflight.py checks local tooling and CMA access.
  2. python3 scripts/create_environment.py prints export ANTHROPIC_ENVIRONMENT_ID=env_....
  3. Generate ANTHROPIC_ENVIRONMENT_KEY in the Anthropic Console environment page.
  4. (cd worker && bl push --workspace "$BL_WORKSPACE" --type sandbox) publishes sandbox/cma-worker:latest; with a custom BLAXEL_WORKER_IMAGE, publish with the matching bl push --name ....
  5. python3 scripts/create_agent.py prints export ANTHROPIC_AGENT_ID=agent_...; set ANTHROPIC_AGENT_MODEL first only if the default model is unavailable in the org.
  6. python3 example/run_session.py --direct-dispatch validates the worker path before webhook registration.
  7. (cd orchestrator && bl push --workspace "$BL_WORKSPACE" --type sandbox) publishes sandbox/cma-orchestrator:latest; with a custom ORCHESTRATOR_IMAGE, publish with the matching bl push --name ....
  8. python3 setup.py creates or reuses the orchestrator, restarts the webhook server, and prints the webhook URL.
  9. Register the Anthropic webhook for session.status_run_started, copy whsec_..., export ANTHROPIC_WEBHOOK_SIGNING_KEY, then rerun python3 setup.py.
  10. python3 example/run_session.py runs the full webhook path.

Environment variables

VariableWhere it livesWhat it is
ANTHROPIC_API_KEYlocal shell onlyControl-plane key. Creates environments, agents, sessions, and reads events. Never put it on the worker.
BL_API_KEY, BL_WORKSPACElocal shell and orchestratorBlaxel service-account auth so the orchestrator can spawn workers.
ANTHROPIC_ENVIRONMENT_IDlocal shell, orchestrator, worker processThe self-hosted environment id.
ANTHROPIC_ENVIRONMENT_KEYorchestrator and worker fallbackScoped work-queue auth required by the SDK worker; agent-run bash receives a scrubbed environment.
ANTHROPIC_AGENT_ID, ANTHROPIC_AGENT_VERSIONlocal shellAgent and exact version used by examples and the AG-UI adapter.
ANTHROPIC_AGENT_MODELlocal shellOptional override used by scripts/create_agent.py; default is claude-sonnet-5.
ANTHROPIC_INFERENCE_GEOlocal shellOptional global or us model inference geography used during agent creation.
ANTHROPIC_ADVISOR_MODELlocal shellOptional advisor model added to a coordinator roster during agent creation.
ANTHROPIC_AGENT_SKILLSlocal shellOptional comma-separated Anthropic skill names or custom skill_* ids.
ANTHROPIC_WEBHOOK_SIGNING_KEYorchestratorWebhook signature verification secret from the Anthropic Console.
AG_UI_BUDGET_CENTS, AG_UI_TURN_TIMEOUT_MSoptional application settingsPer-session spend ceiling and cold-start-aware turn timeout for example/ag-ui/.
BL_REGION, BLAXEL_WORKER_IMAGE, BLAXEL_WORKER_TTL, ANT_MAX_IDLE, ANT_KEEPALIVE_TIMEOUT, ANT_DISPATCHER_*, ANT_MAX_CONCURRENT_WORKER_STARTS, ANTHROPIC_*_WORKER_ID, ANT_RUN_START_ATTEMPTS, BLAXEL_WORKER_READY_*, ORCHESTRATOR_*, BLAXEL_WORKER_VOLUME_*, BLAXEL_WORKER_PROXY_*optionalRuntime tuning and optional Volume/public-preview Proxy paths; see .env.example.

Commands

CommandWhat it doesSide effects
.venv/bin/python -B -m compileall -q bootstrap.py cookbook.py setup.py orchestrator example scriptssyntax checklocal, safe
.venv/bin/python -m pytestsetup, script, and orchestrator testslocal, safe
docker build --platform linux/amd64 --build-arg WORKER_PROFILE=quickstart -t cma-worker:quickstart worker && docker run --platform linux/amd64 --rm --entrypoint /worker/smoke.sh cma-worker:quickstartquickstart worker smoke testlocal Docker only
python3 bootstrap.py --planshows the next setup action without mutationlocal, safe
python3 bootstrap.pyguided setup; stops at Anthropic Console gatescreates real Anthropic/Blaxel resources after preflight
python3 scripts/preflight.pychecks local tooling and Anthropic accessread-only external API call
python3 example/run_session.py --direct-dispatchreal session, direct worker spawncreates a budgeted Anthropic session + Blaxel sandbox
python3 setup.pycreate/reuse orchestrator, restart webhook server, and print preview URLcreates persistent Blaxel sandbox if missing
python3 example/run_session.pyfull webhook flowcreates real session; needs webhook/orchestrator
(cd example/ag-ui && npm ci && npm run dev)local CopilotKit/AG-UI chat over the configured environmenteach new thread creates a budgeted session; needs webhook/orchestrator
python3 example/demo_preview_resume.pypreview URL + standby/resume behavior democreates real resources
python3 example/validate_long_session.pylong keep-alive + filesystem-containment probecreates real resources
python3 cookbook.py statusqueue, agent, session receipt, worker, and Volume statusread-only external API calls
python3 cookbook.py cleanup --session sesn_...exact cleanup planlocal, safe
bl push --workspace "$BL_WORKSPACE" --type sandboxbuilds and publishes sandbox imagepublishes to the workspace loaded from .env
bl get sandbox <worker> process --workspace "$BL_WORKSPACE" -o jsoninspect exact worker processesread-only Blaxel check
bl logs sandbox <worker> <cma-run-process> --workspace "$BL_WORKSPACE" --period 1hinspect exact CMA worker process logsread-only Blaxel check

Where to look

PathResponsibility
scripts/local setup helpers; create scripts print exports and never mutate .env
orchestrator/app.pywebhook verification, fast dispatch scheduling, SDK work claiming, worker sandbox/process launch
worker/Dockerfilequickstart and full agent runtime profiles
setup.pycreate/reuse orchestrator, restart webhook server with current env, print preview URL
example/run_session.pyprimary E2E example; --direct-dispatch proves the worker before webhook registration
example/ag-ui/one-process CopilotKit/AG-UI chat; one UI thread maps to one managed session
example/session_runtime.pySDK streaming, pagination, terminal errors, budgets, timeouts, and receipts
cookbook.pyread-only status and exact per-session cleanup
tests/local behavior tests

Invariants

  • File tools may use relative paths or absolute paths that resolve inside /workspace; paths outside the workdir remain rejected. Bash can access other paths inside the container.
  • Every tool call must produce non-empty output. For silent shell commands, append && echo ok.
  • Launch /worker/worker.py with keep_alive: True plus a timeout cap, or the sandbox can standby while the worker is making outbound calls.
  • Launch the orchestrator webhook server with keep_alive: True, or background dispatch can freeze after the fast webhook response returns.
  • The SDK EnvironmentWorker owns the work heartbeat. Do not send a dispatcher heartbeat before starting it; the worker's first heartbeat must own the lease handoff.
  • The dispatcher readies the session sandbox before claiming work and bounds process-start retries so the ack-to-run gap stays short.
  • ANT_MAX_IDLE controls when the SDK worker exits after the session goes idle with stop_reason=end_turn.
  • A hard session budget stops new model calls with stop_reason=budget_reached. Raise the ceiling above consumed list cost to resume; do not treat it as end_turn.
  • Self-hosted sessions support memory-store resources through the SDK worker. Use metadata plus explicit staging for file and repository inputs.
  • BLAXEL_WORKER_TTL is max age from sandbox creation. It is not idle deletion and should be longer than expected sessions.
  • Worker sandbox names must be lowercase alphanumerics and hyphens; sanitize Anthropic session ids.
  • Use one active work-claiming path per self-hosted environment during proof runs. Environment-polling workers, --direct-dispatch, webhook dispatchers, and other cookbook workers all compete for the same Anthropic queue; a transcript only proves this path when the matching Blaxel worker sandbox shows the expected cma-run-* process.
  • Use one Anthropic environment per Blaxel workspace. The winning claimant creates the worker with its own Blaxel credentials, so BL_WORKSPACE does not pin where a shared environment's work lands; in webhook mode example/run_session.py verifies the worker sandbox and reports when another claimant ran it.
  • example/run_session.py refuses to create a proof session only while queue depth or pending claims are nonzero. workers_polling is recent activity, not proof of contention.
  • Duplicate webhook deliveries are safe because SDK work claiming is durable. A recovery loop handles delayed webhooks and standby resume.

Safe vs. company-facing

  • Local edits and local checks are allowed.
  • Before running commands that create real Anthropic sessions/environments/agents, register webhooks, push sandbox images, create/delete Blaxel sandboxes or Volumes, or otherwise mutate live Anthropic/Blaxel resources, get explicit human approval and name the side effect.
  • Do not push, open PRs, merge, change repo visibility, update Linear/GitHub/Slack, or publish docs without explicit human approval.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.