Mohammad Ausaf Logo Image
Mohammad Ausaf

MIRO

The creative agent in G5 AI Studio at Galleri5. It plans, generates and edits image, video and audio work, and checks what it made before it answers. I built its base, co-built its core agent runtime, and built the infrastructure it runs on.

an agent harness for creative production


MIRO is the agent inside G5 AI Studio, which Galleri5 runs on Azure in partnership with Microsoft. People describe a piece of work in plain language. MIRO picks a playbook, plans the steps, generates and edits image, video and audio across 50+ tools, builds small apps in the chat to review the work, and checks the result before it answers. It makes 300K+ tool calls a month.

My role
  • Agent runtimeBuilt MIRO's base and co-built its core runtime: the turn loop across replicas, steering, compaction, spend approval, background wakes and the in-chat apps.
  • Inference gatewayBuilt from an empty repo: scheduling, crash-safe intake, billing settlement and the ops control plane. Every generation in AI Studio goes through it.
  • Code executionBuilt MIRO's code execution capability on Daytona: screening, SSRF-safe inputs, session boxes and their lifecycle.
  • Quality and opsTracing, LLM judges and the content-safety eval; design docs, incident write-ups and on-call for all of it.
Stack
Python
FastAPI
MongoDB
Redis (Lua)
MCP
OpenTelemetry
Daytona
Azure
What I Built
Agent loop
Steering
Compaction
In-chat apps
Evals
Safety gate
Sandbox
Gateway
Scheduling
Metering

brief to finished film


One chat, start to finish: a brief for a 10-second Tokyo ramen shot, the plan MIRO lays out, the takes it compares side by side, and the finished film.

MIRO in AI Studio, 46 seconds. Turn the sound on in the player.
How a turn works

brief, plan, act, check

A turn is a tool loop driven by the model and bounded by the harness, at most 40 steps and two hours. Multi-step work runs through a plan the harness enforces step by step.

Stage 01
brief
Picks the playbook that fits from a growing library, with org rules taking precedence over personal choice, and reads it before the first generation.
Stage 02
plan
Lays out the steps and the model for each. Anything that costs credits shows an approval card and waits for a yes, unless the person has turned on auto-execute.
Stage 03
act
Calls its tools: generates, edits and analyses media, builds apps in the chat, searches the web and runs code in a sandbox.
Stage 04
check
A step cannot close without a usable output. When background generations finish, the agent is woken to review them, retry or hand back.

long turns across replicas


A turn can run for minutes while video renders. In that time the person sends corrections, the context outgrows the model's window, generations finish or fail in the background, and the replica running the turn can restart. Production runs several replicas and a request can land on any of them, so all coordination between them (steers, wakes, live updates, summaries) goes through MongoDB. It survives a replica dying, at the cost of about a second of polling delay.

steers land mid-turn
A message sent mid-turn goes into the turn's inbox. The replica that owns the turn picks it up within a second and hands it to the loop, either after the current tool calls or by cutting off the in-flight model call and keeping its partial text. Before a paid dispatch, the turn checks for unread steers, so a correction always lands before money is spent.
compact on real token counts
When a chat nears the model's window, the middle is summarised while the opening and a recent tail stay word for word, and a cut never separates a tool call from its result. The first version estimated tokens from character counts, which came out at about half the real number, so one long chat hit the model's limit before compaction fired. It now uses the provider's own token counts.
wake on results, one tool list
When approved generations finish, success or failure, a durable wake starts a turn on any replica so the agent reviews the results instead of going quiet. Wake turns first had a slightly different tool list from user turns, which broke the prompt cache on about half of consecutive turns. Both now share one list, and restrictions are checked when a tool is called.
resume freely, never spend unattended
If a replica dies mid-turn, its lease runs out and the turn can be resumed, automatically only if it had not yet submitted paid work. Turns nobody started, such as wakes, cannot approve a plan, delete anything or start helpers, and the gate refuses whenever it cannot tell who started the turn.

apps the agent builds


For production work MIRO builds small apps in the conversation: review boards to compare and approve shots, and trackers that follow a plan step by step.

The hard part was that the agent could not see them. In early tests it reported font cards as rendered when they were blank. Now each app reports what actually rendered (images loaded or broken, script errors, missing fonts) back to the server. Every write waits for that report, and a small model reviews it before the agent answers.

Approvals form a dependency graph. An approved item is locked and only a person can unlock it. Changing it marks everything built on it as stale and clears those approvals.

tracing and evals


Every turn is exported as one trace: each model call with its token and cache counts, each tool call with its error if it failed. Export runs off the request path behind a bounded queue and a circuit breaker, so tracing can lose data but can never slow down or break a turn. LLM judges label turns for intent, outcome, failure cause and frustration, so failure rates can be tracked on a dashboard.

The content-safety check on generation prompts has a 600+ case eval suite, built from labelled cases and real production runs, and it gates every push. Adding a second-opinion model halved false positives, from 7.8% to 3.9%, while catching 98.6% of unsafe cases. Playbook selection has its own eval.

running agent-written code


Agents write code to do real work: process media, build documents, make charts. That code is untrusted. I built MIRO's code execution capability on Daytona sandboxes, and it handles 80K+ runs a month.

screen before a box exists
Every step is screened before a sandbox exists: known abuse signatures first, then a model that reads the code alongside the conversation. It only sees what the person and the agent wrote, never tool output, so text from fetched pages or files cannot sway its decision. It passed an internal red-team suite without blocking legitimate work, and if screening is down the step is refused.
no credentials inside the box
The service fetches inputs itself, with SSRF checks: every DNS answer is checked, private and cloud metadata addresses are refused, and each redirect is checked again. Outputs leave through the service as well, so the sandbox never holds a credential.
one box per chat, never shared
Each chat gets its own sandbox, kept between steps so files persist, stopped after ten idle minutes and archived later. Boxes are never shared across users, or across trust levels within a chat.
a box lives only while its command runs
Early on, a long idle timer let abandoned background boxes pile up until they saturated a 250 vCPU quota. A supervisor now keeps a box alive only while its command is confirmed running, and a sweeper clears boxes stuck between states.

Sandboxes start in under two seconds, because dependencies are baked into a prebuilt image instead of installed on every run.

the inference gateway


Every generation in AI Studio, MIRO's included, goes through the inference gateway I built from an empty repo: 190K+ jobs a month, 1M+ since launch, routed to 170+ models from 10+ providers: fal, Google, BytePlus, ElevenLabs and self-hosted GPUs. Each model is a catalog entry that names its adapter, pricing and limits, so most new models need no code.

fair share by weight, capacity on leases
Each org has its own queue. A Redis Lua script runs deficit weighted round robin across them, weighted by plan, so one tenant's burst cannot starve the rest. Concurrency is capped per org, per org and model, per model and per provider. Capacity is held as Redis keys with a lease, so a crashed worker's slots expire on their own, a design that grew out of a GPU dispatcher I wrote earlier.
write ahead before queueing
An accepted job is written to Redis before it is queued, and a reconciler re-queues anything accepted but not queued, running or leased. In one incident that write-ahead copy reset a job's retry count on every dispatch, so three jobs hit a provider once a minute for two and a half hours. It now never overwrites state the queue owns.
at most once after a provider accepts
The worst-case price is held when a job is accepted and settled on actual output, duration or tokens. Once a provider has a job, the gateway never resubmits it after a timeout or crash: it waits for the result, or fails and refunds. The cost is that an unknown outcome is refunded rather than retried. Treating a slow submit as spare capacity once caused about 115 duplicate renders an hour, which is why the rule exists.
drain or cap anything, live
A control plane on-call engineers use to drain or cap a provider or a single model, pause by org or job, and watch contention, provider health and queue ETA. When a provider rate-limits, that model's concurrency halves and recovers one step per success. Design docs, incident write-ups and on-call for all of it.

the canvas planner


Before MIRO I built AI Studio's canvas planner. It turned a brief into a plan of image, video and audio steps that people could see, edit, approve and run, and it validated every plan before anything was spent. MIRO keeps the same rule: check the work before showing it.

Built with AI Studio


Production content generated using this platform.

Chiranjeevi Hanuman: The Eternal

First look: 24M+ views on YouTube

Mahabharat: Ek Dharmayudh

Streaming on JioHotstar