Letting a Small Local Model Choose the Video Tools

Published on
•
10 mins read
•
--- views

The question

Could a relatively small model run a useful video workflow if the work were divided into clear tools? I built a small TypeScript prototype to find out. The input was an English video; the intended outputs were a transcript, Traditional Chinese translations, subtitles, vocabulary cards, and a finished video.

The model did not edit video by inventing commands. I gave it a short goal and a list of named tools. A program around the model executed each tool and returned the result. That surrounding program is the agent harness.

This was a focused experiment, not a general-purpose video editor or a replacement for the larger AI Media Production System I use for making episodes. It tested whether a model could coordinate a known set of operations.

What is a harness?

Think of the model as a dispatcher. It can choose the next job from a menu, but it cannot do the work until the surrounding program connects that choice to a real tool. The harness provides that menu, runs the selected tool, gives the result back to the model, and checks whether the workflow is done.

From the user's research request to the final answer: a Skill guides the AI, tools perform actions, and the Harness coordinates and checks the work

In short: a Skill is a how-to guide, a tool performs an action, and the Harness coordinates the work and checks whether it is complete.

In this prototype, the loop looked like this:

  1. The harness sent the model the goal and descriptions of the available tools.
  2. The model chose a tool and supplied its arguments.
  3. The harness ran the corresponding TypeScript function and returned its result.
  4. The model chose what to do next, or reported that it was finished.
  5. The harness checked for the expected output files and could tell the model what was still missing.
The agent loop: send goal and instructions, let the model choose a tool, run it, return the result, and check completion before accepting the final answer

The model chose the next action. The harness and tools performed it. That distinction matters: a tool description alone does not edit a video. It is the executable function behind the description that does the work.

The harness also kept the model's response inside its loop. When the model stopped with a normal text reply, the program checked the required output files before treating the run as complete. If a file was missing, it sent that result back to the model and continued. This check could catch an early stop, although it only checked that files existed.

The tools I gave it

The first version exposed five tools. Each one represented a meaningful step rather than asking the model to write arbitrary shell commands.

ToolWhat it did
transcribeExtracted audio with FFmpeg, then used MLX Whisper to produce a timestamped transcript.
translateTranslated transcript segments into Traditional Chinese while keeping their timing.
generate_subtitlesTurned the timed text into a styled ASS subtitle file.
add_vocab_cardsSelected useful vocabulary and expressions, then rendered timed learning cards.
burn_videoCombined the source video, subtitles, and cards into an MP4 with FFmpeg.

The tools also had prerequisites. For example, subtitle generation needed transcript and translation data. If the model called a step too early, the tool returned a useful error explaining what needed to happen first. That gave the model a chance to recover instead of silently producing an incomplete result.

Why give the model a choice?

A fixed script could have called all five tools in a hard-coded order. I wanted to test a different question: could the model work out which tool to use next from the goal, tool descriptions, and the results it had already received?

The loop had a maximum of 15 model turns. The completion check looked for the expected files, including the final video and subtitle file. In one recorded run, Qwen 2.5 7B completed the workflow in five tool calls without a tool error.

That is an encouraging result for this narrow task, but it is not proof that a 7B model can edit any video reliably. The completion check confirmed that files existed; it did not judge whether every subtitle was accurate, every translation was natural, or the final video looked good. A person still needs to review the output.

What ran locally, and what did not

The agent loop used Ollama with Qwen 2.5 7B on the local machine. Transcription used MLX Whisper locally. Translation and vocabulary selection used Gemini, so the whole workflow was not local-only. FFmpeg assembled the media on the machine.

Keeping these boundaries clear is useful when describing an AI system. “Local model” describes the model that chose tools; it does not automatically mean every service in the workflow ran locally.

When does a harness help?

A harness is useful when a task has several repeatable steps, each step can be expressed as a reliable tool, and the model needs to choose or adapt the order. It can make a smaller model more useful by keeping each decision concrete: choose one of a few actions, get a result, and continue.

It works best when:

  • tools have narrow responsibilities and clear inputs and outputs;
  • prerequisites and failure cases are explained to the model;
  • the harness can check measurable completion conditions;
  • a person can review results where quality is subjective.

It is a weaker fit when success depends mostly on taste or visual judgment that cannot be checked by the available tools. The model may coordinate the steps, but that does not make its creative judgment reliable by itself.

Agent loop or fixed workflow?

If the order can vary, an agent loop can let the model choose the next tool from the current goal and results. If every stage is mandatory, such as search → read sources → validate claims, a program-defined workflow is a stronger fit: the code advances to the next stage only after the current one succeeds, and it does not accept completion until validation passes.

These approaches can be combined. Code can enforce the required stages, while the model makes decisions inside a stage—for example, which search query to try or how to summarize a source. A prompt can encourage the model to continue, but the code's state checks and completion gate are what prevent a skipped required stage from being counted as done.

My prototype used the more flexible agent-loop approach: Qwen chose the next tool, and each tool checked some prerequisites. The final gate checked for the video, subtitle, and card files. It did not record a separate pass/fail result for every operation or validate the content of those files. A fixed workflow with a validation record would provide a stronger guarantee when every step must run.

Could I use Pi or Codex instead?

Partly. The original prototype did not use Pi or Codex; it had its own small model-and-tool loop. That gave me direct control over the local Qwen model call, the available tool list, and the exact feedback loop I wanted to test. Codex can be extended with video tools, but that is not the same as taking control of the harness inside Codex.

The right integration depends on what I want to build:

GoalA fitting approach
Add video tools to the existing Pi CLIWrite a Pi extension that registers tools with pi.registerTool().
Build a custom Node.js harness using Pi's agent runtimeUse the Pi TypeScript SDK; your program coordinates workflow stages and completion checks, while Pi handles model-and-tool turns within a session.
Let Codex call the video operationsExpose them through a local MCP server; a Skill can give Codex workflow instructions.
Install and share a ready-made set of instructions and toolsPackage the relevant extension or MCP configuration with a Skill/plugin.
Comparison of workflow control in a custom Harness, a Pi SDK application, and Codex with MCP tools and a Skill

Pi's extension documentation describes adding tools and behavior to the existing Pi CLI. Its SDK provides in-process access to Pi's agent runtime, sessions, tools, models, and resources. I could build my own Node.js harness using that runtime: my program would decide which workflow stage is active, what tools are available at that stage, and whether the completion checks pass. Pi's runtime would handle the model-and-tool turns within a session. A Skill provides instructions, while extensions or MCP servers provide executable tools. For simply adding tools to the existing Pi CLI, an extension is more direct. For building my own app and coordinating the workflow, the SDK is a suitable foundation.

Codex CLI owns its agent loop and built-in tools. You can add external tools through a local MCP server, and a Skill can describe the workflow. A plugin can package MCP configuration and Skills for reuse. But these extension points do not replace Codex's loop with my own, nor do Skills force a precise execution sequence: they guide the agent, while Codex remains in charge of deciding how to act. Codex CLI also documents connecting to local model providers such as Ollama in its advanced configuration; using a local model does not by itself give me control over the CLI's orchestration.

So the precise answer is: Codex can call video tools that I expose, but it does not let me replace its internal agent loop with the custom Qwen-driven loop from this experiment. If the goal is simply to give Codex video capabilities, MCP is suitable. If the goal is to test how a particular small model autonomously selects from my exact tool list under my own loop and checks, I need to keep or build an agent harness I control. With Pi, an extension adds tools to the existing CLI; the SDK can also provide Pi's agent runtime to a custom harness. My program can control the larger workflow and completion gates, while the Pi runtime handles model-and-tool turns within a session.

What this experiment showed

The useful idea was not that a small model suddenly became a video editor. It was that a small model could make a sequence of bounded choices when the available actions, prerequisites, and feedback were made explicit. The code around the model did the reliable media operations, and the model chose among them.

The prototype showed one workable way to organize that experiment. It did not yet include Pi or Codex integrations, and its file-existence check was only a basic completion check. The tool implementations could be reused behind a Pi extension or MCP server, but only the original/custom loop gives me direct ownership of the model-and-tool orchestration being evaluated here. Stronger checks for subtitle timing, content, and the rendered video would also be needed.

This prototype is separate from my AI Media Production System, a broader workflow I use to create and review English-learning video episodes.

References

Letting a Small Local Model Choose the Video Tools | ChunHao's Blog - Coding Journey