vlmrun-orion-2) write and execute Python code in a secure,
sandboxed environment. Instead of invoking tools one at a time (Orion-1),
Orion-2 composes CV operations into multi-step pipelines — detect, crop,
annotate, measure, and transform — all within a single execute_code call.
When to Use Orion-2
How It Works
Orion-2 is a visual agent harness: a planner and a code runtime wrapped around a vision-language model. It accepts text, images, video, and documents, compiles each request into an executable program, and dispatches visual tools and code execution from a single harness.- Prompt → Spec: An ambiguous request is compiled into an exact, executable program written in a visual DSL that reads like idiomatic Python.
- Execution: The program runs in a sandboxed runtime with async-native parallelism — independent operations dispatch concurrently via
asyncio, with no per-step model round-trips. - Self-correction: Execution results return to the harness, which repairs and re-executes until the program runs to completion.
Read the full Orion-2 blog post for architecture details, benchmarks, and live examples.
Orion-1 vs. Orion-2
The difference is clearest on a concrete task. Consider a virtual try-on that composes detection, cropping, and image generation across two input images. Orion-1 — sequential tool-calling, one LLM round-trip per tool:Available Libraries
Inside the sandbox, the agent accesses libraries throughctx.import_lib(...):
Standard library modules (
json, math, re, pathlib, asyncio, etc.) are
available via normal import statements.
VLM Run Proxy API
Thevlmrun proxy provides access to the full suite of CV capabilities:
vlmrun.llm.extract
Runs a text-only LLM extraction inside the sandbox. With ajson_schema, it returns a
validated dict matching the schema; without one, it returns free-form JSON parsed from
the model response. When a skill has a schema.json file, the pipeline can read and pass
it directly:
Example: Chat Completion with Orion-2
Skills with Orion-2
When skills are attached to an Orion-2 request, the skill workspace is materialized into the session directory at<workspace>/skills/<skill-name>/. The agent can
read skill resources (SKILL.md, schemas, templates) directly using vlmrun.io.read_file
or cv2.imread — no special API calls needed.
Program Execution
When an Orion-2 skill has been run at least once, the agent’s authoredpipeline.py is
cached inside the skill bundle. On subsequent executions, the platform can run that
pipeline directly through the code-execution sandbox, bypassing the LLM agent loop
entirely. This is called program execution: the cached pipeline is the compiled
program that you built once and now just run.
How it works
- First run (authoring): The agent plans and writes
pipeline.py. The code is persisted into the skill’s stored bundle for reuse. - Subsequent runs (replay): The cached
pipeline.pyexecutes directly viaCodeExecutionRunner. If execution fails or no cached pipeline exists, the system falls back to the full agent loop automatically.
Controlling execution mode
Usemode in your execution config. It accepts program (default) or agent:
execution_mode indicating which path was taken:
Program execution preserves structured output validation, grounding metadata, and billing accuracy. Billing for program runs captures sandbox and tool costs only: zero LLM orchestration tokens.
Performance
Program execution can be an order of magnitude faster than the full agent loop. In testing, a medical-referral document extraction skill completed in ~13s in program mode vs. ~160s with full agent orchestration.Security
The code execution sandbox enforces strict security boundaries:- Import restrictions: Only allowlisted libraries (
cv2,numpy,matplotlib,vlmrun,ffmpeg) viactx.import_lib(), plus Python stdlib. Dangerous modules (os,io,shutil,importlib) are blocked at AST parse time. - Workspace confinement: All file operations are restricted to the session workspace. Symlink traversal and absolute path escapes are rejected.
- Introspection blocking: Builtins like
eval,exec,compile,getattr, and__import__are blocked to prevent sandbox escape.
Model Variants
Orion-2 is model-agnostic — the same harness and runtime work with any multimodal model that has strong code generation. The defaultvlmrun-orion-2:auto routes each request to the best backbone for the job.