Skip to main content

Mash

CI PyPI Python versions License: Apache-2.0

Mash is a self-hosted durable runtime for code-authored automations using workflows with agents. A workflow is an ordered pipeline of typed steps, a step is deterministic Python or one run of a harnessed agent, and control flow stays in code.

Mash gives you a Python AgentSpec contract for defining agents, a WorkflowSpec for authoring step pipelines, a HostBuilder that composes both into a deployable pool, a FastAPI server for deployment, and a CLI/API for interacting with a running host.

It's designed around Host-to-Agent Protocol (H2A) that standardizes interactions between user applications and agents.

What Mash Provides

  • Workflows: ordered pipelines of typed steps, durable and observable. A step is deterministic Python or one agent run; each step's output threads into the next step's input with schema checks at every edge. The pipeline is code you can read, diff, test, and replay.
  • Agent harness: the agent loop runs inside a durable request engine with tools, skills, memory, and structured output. Requests are recorded as replayable runtime events; retries, restarts, and long-running work just work.
  • Sandboxes: every request runs under a policy, a named resource many sessions share, and each policy gets a sandbox, a container where the code the model writes (Python, JavaScript, shell) runs as an unprivileged user. It holds a folder per agent, whose files and SQLite databases persist across requests, and only that policy's files: the agents' secrets and the database stay with the host. Pages, files and servers the code makes open at links the host serves.
  • Browsers: each policy also gets a browser, a Chromium in its own container whose profile keeps the sites the user signed in to. An agent that lists sites drives it with Playwright MCP's page tools, on those sites only. When a site needs a sign-in, the agent hands the browser to the user through a live-view link, and the profile keeps the session for later requests. Mash never sees the password, and code in the sandbox has no route to the browser.
  • Frontier and open-source models: built-in adapters for Anthropic, OpenAI, and Gemini, and any open-source model served over a Chat Completions endpoint, self-hosted with vLLM or Ollama or hosted on OpenRouter. Each agent picks its model in one line of build_llm().
  • Self-hosted interfaces: HTTP API with streaming, CLI, and interactive REPL, all on one Postgres. Deploy locally, in Docker, or on any cloud.
  • Multi-agent composition: put agents and workflows behind a host. The built-in companion routes each message to the right agents or workflow, continues an agent's earlier session on a follow-up, and writes the answer.
  • Human-in-the-loop: agents can pause for approval or ask users questions mid-execution. Interactions survive host restarts.
  • Observability: span trees, trace analysis, telemetry API, built-in dashboard, and CLI trace inspection. No external APM needed.
  • Synthetic evals: generate a test dataset and scoring rubric from a host's declared capabilities, run experiments that snapshot the live host, and compare quality and cost across runs before the first user message. Datasets, rubrics, and experiment results live in the built-in dashboard. Turn them on with HostBuilder.enable_evals().
                               api · cli · REPL
                                       ▲
                                       │
                                       ▼
┌─ Host ──────────────────────────────────────────────────────────────────────┐
│                                      │                                      │
│            ┌─────────────────────────┼─────────────────────────┐            │
│            ▼                         ▼                         ▼            │
│      ┌───────────┐            ┌─────────────┐            ┌───────────┐      │
│      │   agent   │            │  companion  │            │ workflow  │      │
│      │           │            │  (events)   │            │           │      │
│      └───────────┘            └─────────────┘            └───────────┘      │
│            │                         ▲                         │            │
│            │   approvals, questions  │ RunSubAgents: one or    │            │
│            │   and answers go back   │ more subagents          │            │
│            │           ┌─────────────┼─────────────┐           │            │
│            │           ▼             ▼             ▼           │            │
│            │      ┌─────────┐   ┌─────────┐   ┌─────────┐      │            │
│            │      │  agent  │   │  agent  │   │  agent  │      │ agent step │
│            │      └─────────┘   └─────────┘   └─────────┘      │            │
│            │           │             │             │           │            │
│            └───────────┴─────────────┼─────────────┴───────────┘            │
│                                      │ every agent request                  │
│                                      ▼                                      │
│                 ┌─────────────────────────────────────────┐                 │
│                 │          Durable Request                │                 │
│                 │                                         │                 │
│                 │   ┌─ context ─── memory ──┐             │                 │
│                 │   │                       │             │                 │
│                 │   │     Agent Loop        │ ─► response │                 │
│                 │   │ think → act → observe │       ┊     │                 │
│                 │   │                       │       ▼     │                 │
│                 │   └─ tools ───── skills ──┘  structured │                 │
│                 │      │                        output    │                 │
│                 │      │ ▲ user interaction               │                 │
│                 │      │ │ (approval / ask-user /         │                 │
│                 │      │ ▼  browser sign-in)              │                 │
│                 │      │                                  │                 │
│                 │      │  resumable · replayable · traced │                 │
│                 └──────┼──────────────────────────────────┘                 │
└────────────────────────┼────────────────────────────────────────────────────┘
            ┌────────────┴─────────────┬──────────────────────────┐
            │ run_code                 │ browser                  │ MCP tools
            ▼                          ▼                          ▼
┌───────────────────────┐  ┌───────────────────────┐  ┌───────────────────────┐
│ Sandbox: per policy   │  │ Browser: per policy   │  │ MCP servers: your own │
│ workspaces/<agent_id> │  │ Chromium, own profile │  │ remote tools          │
│ files persist         │  │ listed sites only     │  │ web search            │
│ no secrets · no db    │  │ sign-in via live view │  │ listed at startup     │
└───────────────────────┘  └───────────────────────┘  └───────────────────────┘

Every input to a host is an event in a session, such as a Slack thread. Events in a session run one at a time, in arrival order, and the user can keep sending while one runs; the rest wait in the session's queue. Each event runs as a request on the companion, which runs the host's agents as child requests, each in its own session, or starts a workflow, and then writes the answer. When one of those agents needs an approval or an answer, the companion relays it to the user. A workflow run skips the companion. Whichever way a request reaches an agent, it rides the same durable loop, and the code it runs lands in the sandbox of the policy it runs under. An agent that lists sites drives that policy's browser, and remote tools call the MCP servers the agent connects to.

See Mash under the hood for a deeper look at each capability, and the product brief for the pitch.

Quick Start

Install:

# install the library
uv add mashpy

# install the `mash` CLI on your PATH
uv tool install mashpy 

Define your agents:

Each agent is an AgentSpec subclass. It names itself, picks an LLM, and declares a system prompt, tools, skills and agent config.

## my_app/agents.py

from mash import AgentSpec
from mash.core.config import AgentConfig
from mash.core.llm import AnthropicProvider
from mash.skills import SkillRegistry
from mash.tools.registry import ToolRegistry


class SupportAgent(AgentSpec):
    def get_agent_id(self):
        return "support"

    def build_tools(self):
        return ToolRegistry()

    def build_skills(self):
        return SkillRegistry()

    def build_llm(self):
        return AnthropicProvider(agent_id="support")

    def build_agent_config(self):
        return AgentConfig(
            agent_id="support",
            system_prompt="You answer product and account questions.",
        )


class ResearchAgent(AgentSpec):
    def get_agent_id(self):
        return "research"

    def build_tools(self):
        return ToolRegistry()

    def build_skills(self):
        return SkillRegistry()

    def build_llm(self):
        return AnthropicProvider(agent_id="research")

    def build_agent_config(self):
        return AgentConfig(
            agent_id="research",
            system_prompt="You handle research-heavy questions in depth.",
        )

Author the workflow:

The workflow is the automation: an ordered pipeline of typed steps that code owns end to end. Use a CodeStep for deterministic Python and an AgentStep when the work needs an agent.

## my_app/workflows.py

from pydantic import BaseModel

from mash import AgentStep, CodeStep, StepContext, WorkflowSpec


class ResearchRequest(BaseModel):
    topic: str


class ResearchPlan(BaseModel):
    topic: str
    questions: list[str]


class ResearchBrief(BaseModel):
    summary: str
    sources: list[str]


def plan_research(
    request: ResearchRequest,
    _context: StepContext,
) -> ResearchPlan:
    return ResearchPlan(
        topic=request.topic,
        questions=[
            f"What are the key facts about {request.topic}?",
            f"What should a reader understand about {request.topic}?",
        ],
    )


RESEARCH_BRIEF = WorkflowSpec(
    workflow_id="research-brief",
    input_model=ResearchRequest,
    steps=[
        CodeStep(
            step_id="plan",
            run=plan_research,
            input=ResearchRequest,
            output=ResearchPlan,
        ),
        AgentStep(
            step_id="research",
            agent_id="research",
            input=ResearchPlan,
            output=ResearchBrief,
        ),
    ],
)

The CodeStep output becomes the AgentStep input. Mash validates both edges, runs each step durably, and uses the last step's output as the workflow result.

Build the pool:

The pool is the unit of deploy: agents and workflows registered together.

## my_app/host.py

from mash import AgentMetadata, HostBuilder

from .agents import ResearchAgent, SupportAgent
from .workflows import RESEARCH_BRIEF


def build_pool():
    pool = (
        HostBuilder()
        .agent(
            SupportAgent(),
            metadata=AgentMetadata(
                display_name="Support",
                description="Answers product and account questions.",
                capabilities=["product questions", "account help"],
                usage_guidance="Questions about the product or a user's account.",
            ),
        )
        .agent(
            ResearchAgent(),
            metadata=AgentMetadata(
                display_name="Research",
                description="Handles research-heavy questions in depth.",
                capabilities=["research", "analysis"],
                usage_guidance="Use for questions that need digging.",
            ),
        )
        .workflow(RESEARCH_BRIEF)
        .build()
    )
    return pool

A pool can also be workflows alone. A workflow of pure CodeSteps references no agents, and the resulting pool serves only workflow runs:

def build_pool():
    # EXPORT_METRICS is a WorkflowSpec of pure CodeSteps; no agents needed.
    return HostBuilder().workflow(EXPORT_METRICS).build()

Configure the environment:

The host needs an LLM key, a Postgres URL for its durable runtime, and a secret it derives agent and sandbox tokens from. Put them in a .env file in the directory you run mash host serve from; the CLI loads it on start:

# .env
ANTHROPIC_API_KEY=sk-ant-...
MASH_DATABASE_URL=postgresql://user:pass@localhost:5432/mash
MASH_HOST_SECRET=...   # openssl rand -hex 32

Start the host:

The host runs each agent as its own subprocess. For agents to get the sandbox tools, it also needs a Docker daemon; it pulls Mash's sandbox image, ghcr.io/imsid/mash-sandbox, on first start. Without Docker the host still runs, and its agents get no sandbox tools. Agents whose specs list sites with browser_sites() also get the browser tools, and the host pulls Mash's browser image, ghcr.io/imsid/mash-browser, the first time one opens a page.

mash host serve --host-app my_app.host:build_pool --host 127.0.0.1 --port 8000

Create a policy, connect, and browse available agents. Every message is an event that names the app posting it and the policy it runs under, so the connection saves both:

echo '{"sandbox": true}' | mash policy put dev --file - \
  --api-base-url http://127.0.0.1:8000
mash connect --api-base-url http://127.0.0.1:8000 --app-id my-app --policy-id dev
mash browse

Compose an assistant host from agents and a workflow. Every event to it runs on the built-in companion, which routes it:

mash compose --host assistant --agents support,research \
  --workflows research-brief

Talk to the host or execute / commands using Mash repl:

mash repl --host assistant

Key Concepts

Concept What it is
AgentSpec Abstract contract defining one agent (id, tools, skills, LLM, config)
HostBuilder Fluent builder that composes agents, workflows, and hosts into a Pool
Pool The deployed pool of agents the API server runs; each agent runs as a subprocess of the host
App The application posting events, named by the app_id every event carries; it scopes Cortex and conversation search
Policy A named, durable resource many sessions share; it owns the sandbox and the browser profile and sets whether agents get the sandbox, which sites they may open, and how long an interaction may wait
Session and event Every input to a host is an event in a session; a session's events run one at a time, each as one request on the companion
Sandbox A container per policy where agents' code runs, holding that policy's workspaces and nothing else
Browser A Chromium per policy, in its own container, whose profile keeps the sites the user signed in to; agents that list sites with browser_sites() drive it on those sites
Host A composition over the pool (agents + workflows), defined in code or dynamically over the API; the built-in companion runs every event posted to it
ToolRegistry Register callable tools; built-ins include AskUser and the companion's RunSubAgents and RunWorkflow, and the host adds run_code and edit_file when it has sandboxes, sandbox_put and sandbox_get for specs that declare file roots, and the browser tools for specs that list sites
SkillRegistry Markdown instruction bundles loaded on demand via a meta-tool
LLMProvider Adapters for Anthropic, OpenAI, and Gemini
OSSCompatibleProvider Runs open-source models (Gemma, Qwen, DeepSeek) over any Chat Completions endpoint, self-hosted (vLLM, Ollama) or hosted (OpenRouter); chosen in build_llm() like any provider
WorkflowSpec Ordered pipeline of typed steps (CodeStep / AgentStep); runs are durable and observable
Eval / Experiment A generated dataset and rubric bound to a host; an experiment runs the dataset against the host, snapshots its composition, and scores results with an LLM judge
Cortex Opt-in per-app memory kept by the host and shared by every agent; each request reads its app's, the cortex-build workflow builds it on demand, and apps edit it over the API

Mushy / Thoughts

See the agent's original exposed thought summaries in Admin → Activity → Thoughts. Filter by Agent and scroll the latest 50 traces with nonempty summaries. Underlined phrases bring out the language's personality; selecting one moves Mushy beside the passage. Each trace links to its Admin logs.

Capture is always enabled for runtime agents when their provider supports it (currently Gemini). The trace sidebar in Logs links directly to that trace's thoughts, including older traces. There is no separate interpreter, GIF generation API, or public sharing surface. See Mushy and Pilot.

Mash Pilot

Pilot is a command-line guide to the Mash codebase, built on the Mash SDK and shipped in this repo at src/pilot/. Its pilot agent answers questions from the source and searches the docs site and GitHub in the policy's browser, and its builder agent builds Mash apps in the policy's sandbox. It also ships the pilot-changelog workflow. Run it from a checkout, with GEMINI_API_KEY, OPENROUTER_API_KEY, MASH_HOST_SECRET and MASH_API_KEY in .env:

docker compose -f docker-compose.pilot.yml up -d --build

curl -fsSL https://raw.githubusercontent.com/imsid/mashpy/main/install.sh | sh
echo '{}' | mash policy put me --file - --api-base-url http://127.0.0.1:8000
mash connect --api-base-url http://127.0.0.1:8000 --app-id pilot --policy-id me
pilot repl --host guide

See src/pilot/README.md for the agents, the keys and model overrides, the shipped workflow, and building your own app.

Build with a Coding Agent

This repo includes CLAUDE.md so coding agents like Claude Code, Codex, and Cursor can scaffold a Mash-powered agent from a natural language prompt. Copy it into your project or point your agent at this repo to get started. The Pilot guide (above) also carries the build-mash-agent, build-mash-workflow, and build-mash-host skills for interactive scaffolding from the REPL.

Documentation

An app can ship its own terminal client with mash.cli.App: set its name, default host, deployment URL, app and policy, then expose app.main as a console entrypoint. It includes the live REPL and one-shot commands. See the CLI README for the app kit.

Contributing

Contributions are welcome. See CONTRIBUTING.md for setup, tests, and the pull request flow, and SECURITY.md for reporting vulnerabilities. Release notes live in CHANGELOG.md.

License

Mash is licensed under the Apache License 2.0.

Metadata

Release files for mashpy 0.40.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mashpy 0.40.0
File Size Uploaded Provenance Actions
mashpy-0.40.0.tar.gz 1.1 MB With provenance Details for mashpy-0.40.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mashpy 0.40.0
File Interpreter ABI Platform Actions
mashpy-0.40.0-py3-none-any.whl Python 3 none any Details for mashpy-0.40.0-py3-none-any.whl

Total release size: 2.3 MB

Release files / mashpy-0.40.0.tar.gz

Download URL mashpy-0.40.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
b290cc0c77b1c7020ab628f12cfe6ac69daa02cbd1d3e93f16ee6c94bf835d40
BLAKE2b-256 checksum
How to use checksums
77efee5960d0f7a408cc8f5405e9c788df7882556828025f49074bbf733cad50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / mashpy-0.40.0-py3-none-any.whl

Download URL mashpy-0.40.0-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ee6f850172c75605f617506b1e9d23539c64dd3c53216dee6484278f2cae4ec0
BLAKE2b-256 checksum
How to use checksums
891cb5487a45cd9697ec37b542e54c758413ad0ebb7a4807a8f6b21c51b60f59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for mashpy 0.40.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mashpy-0.40.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.40.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page