Build a coding agent harness: tools, budgets and context

Tejas Kumar turns a chat loop into an agent, then swaps the model and tools to show which pieces can be reused.

TKTejas KumarIntervenant · IBM
Chaîne
AI Engineer
Publié
3 déc. 2026
Vidéo
1:01:19
Lecture
9 min
Diapositives
5
Original
anglais
Ouvrir sur YouTube
En faisant défiler, la vidéo se réduit en bas à droite et continue. Les sous-titres suivent votre langue de lecture.
Langue de lectureDisponible en 2 langues
Cet article n’est pas encore disponible en français ; il s’affiche dans l’original en anglais.
RÉSUMÉ

En 30 secondes

A coding model becomes useful when a surrounding program can run tools, return their results, manage context and enforce limits, says IBM’s Tejas Kumar. Starting with a terminal chat loop, he adds file access, a tool registry, permission gates and token budgets. He then demonstrates caching, compaction and a local model, before replacing coding tools with browser tools. For long tasks, he reports that splitting one test into phases improved completion, though the result is specific to his experiment.

  1. 1A model cannot inspect a repository until the harness exposes a toolKumar defines a file-reading tool and adds an inner loop that executes requested tools and returns results to the model.
  2. 2An unrestricted coding agent can remove the projectAfter a destructive demonstration, he adds a 25-step and 300,000-token budget plus a user approval gate for selected tools.
  3. 3Limit large tool outputs and compact before costs riseThe example truncates oversized results and configures a 90,000-token compaction trigger based on the pricing Kumar describes for his chosen model.
  4. 4One long task improved when split into phasesKumar reports 29% success for a single 120-step loop versus 85% for ten phases of twelve tasks in his own experiment.
  5. 5The same harness can run a local model and switch to browser toolsAfter correcting a branch mistake, Kumar runs IBM Granite through Ollama offline, then changes the tool set for a browser-based task.
  6. 6Keep business rules in-house when considering a managed harnessKumar suggests owning domain-specific tools, permission gates, phases and budgets while considering managed infrastructure for durable execution.

À retenir

  1. A model requests a tool; the harness executes it and returns the result before the next model step.
  2. Set per-task step and token budgets, and gate sensitive tools with user approval.
  3. Cap oversized tool results and tell the agent how to request a smaller piece.
  4. Choose caching and compaction thresholds based on workload and provider pricing, not just the largest context window.
  5. Kumar reports better completion on one long task when he split it into phases with fresh contexts.
  6. Reuse the loop and context machinery across domains, but change the tools and permissions to fit the work.
  7. Evaluate agent behavior before relying on a harness in production.
TEXTE INTÉGRAL

Lire le texte remanié, chapitre par chapitre

Transcription seule
01

A harness supplies tools, context and guardrails

Kumar describes the loop around a model and why an application needs more than generated text. Different domains require different tools and rules.

I work in AI research and development at IBM, where we build the Bob coding agent and train Granite models. Today I want to start with an empty loop and build the surrounding program—the harness—that turns model responses into useful work.

A conversation is a repeated exchange: receive input, process it and respond. A coding agent is also built around a loop, but the software surrounding the model must supply the capabilities and constraints that turn that loop into an application.

I group the harness components into three categories: tools, context management and guardrails. Tools let the system act; context mechanisms manage what the model sees; guardrails limit dangerous actions and runaway usage.

Context includes decisions about when to compact a long conversation or reuse cached input. Guardrails can include step and token limits as well as asking a person before a consequential action. We will build each piece as a practical problem appears.

Without the surrounding machinery, a model can lose relevant earlier context, continue generating at high cost or act without a permission check. I describe a simple canary: ask it to include a marker in each response and watch when that instruction stops being followed during a long conversation.

A permission failure can be as simple as interpreting “clean up this file” as deletion rather than refactoring. The harness is the layer intended to keep the system connected to the user’s task and enforce the rules around its actions.

Coding agents, general assistants and computer-use systems all have harnesses, but their tool sets differ. A coding agent might read and edit files or run tests; a browser agent might take screenshots and click. A financial workflow would require its own tools and rules.

The model generates a response to a request; the harness performs the surrounding work, including tool execution, context management and enforcement. That separation helps us see which parts can be reused and which depend on a domain.

02

A chat loop cannot yet inspect or edit files

The initial TypeScript loop keeps messages in memory but loses state when restarted. A file-reading tool and inner agent loop let it use repository data.

We start with a TypeScript terminal program: repeatedly ask for input, add the user message to an array, call a model and append its response. Empty input simply returns to the prompt. The particular SDK is a choice of implementation, not the core idea.

The initial terminal conversation loop
DIAPOSITIVE 1 / 5The initial terminal conversation loopThe TypeScript example collects user messages, calls the model and appends responses without tools or persistent state.

The response contains more than the text printed to the terminal, so the example retains the complete content in the message history. This is still a basic chat loop, not a useful coding harness.

After working around a network problem, I show a limitation: restarting the process loses its in-memory conversation. When I ask it to read package.json, the model says it cannot access the repository. It needs a tool.

I define a read-file tool with a name, description and input schema, plus a separate implementation that reads the requested file. The model sees what the tool is for; the harness, not the model itself, executes the function.

A file-reading tool definition
DIAPOSITIVE 2 / 5A file-reading tool definitionThe model receives a name, description and input schema; the separate function executes the file read.

Inside the outer interaction loop, a second loop calls the model. If the response requests tool use, the harness runs the tool, adds its result to the conversation and calls the model again. When the model stops for another reason, that inner loop ends.

A tool request must be followed by a corresponding tool result in the conversation. The pattern can repeat several times before the model produces a final answer, giving the agent access to observations from the environment.

With file reading in place, the example can inspect package.json and explain the project. But when asked to create an AGENTS.md file, it can only offer text for the person to paste because it does not yet have a writing tool.

03

A registry scales tools—and exposes risky actions

Kumar adds file and shell tools, then demonstrates an unguarded destructive request. Budgets and permission gates constrain subsequent actions.

To scale beyond a single tool, I create a registry. Each entry contains a name, description, input arguments and an execution function. The dispatcher finds a requested tool by name and either runs it or reports that it does not exist.

Finding and running a registered tool
DIAPOSITIVE 3 / 5Finding and running a registered toolThe tool registry looks up a requested tool by name and invokes its implementation.

The expanded set can list files, read, write and use a shell. Now the agent can identify that AGENTS.md is missing and create it. The model makes its choices using the tool definitions included in the request.

I ask the agent to rewrite the project in Python and it starts acting. The demonstration becomes chaotic, illustrating the next gap: tools that can change files or run commands need constraints, not only a way to execute.

A further request to delete the repository contents demonstrates the problem directly. I recover the project and introduce guardrails: a per-task budget and a permission gate for selected tools.

The example caps a task at 25 model steps and 300,000 input and output tokens. It tracks usage from zero for each task. Separately, a set of tool names identifies actions for which the harness should ask the user first.

Per-task limits and approval gates
DIAPOSITIVE 4 / 5Per-task limits and approval gatesThe demonstration sets example step and token limits and identifies tools that require user confirmation.

When a requested tool is on that list, the gate asks for confirmation; a refusal is returned as an error the model can see, with an instruction to ask what to do next. This is a message from the harness to the agent as well as a protection for the user.

I repeat the deletion request and decline the shell operation. The agent receives the refusal and reports that it did not delete anything. I also try to exercise the step budget with repeated file reads, but do not complete a controlled limit test on stage.

04

Manage context and compare caching costs

The harness limits tool results and configures caching and compaction. Kumar runs a small cached-versus-uncached demonstration and discusses pricing thresholds.

The next problem is context. A growing conversation contains the system prompt, user messages, tool requests and tool results. Sending a long history repeatedly can become expensive, so the harness needs a strategy for caching, truncation and compaction.

Context limits and compaction threshold
DIAPOSITIVE 5 / 5Context limits and compaction thresholdThe sample caps tool-result size and sets a compaction trigger for the chosen model and workload.

I set a maximum size for tool results: a tool could otherwise return an enormous document and fill the context. If a result is too long, the example cuts it and tells the agent to ask for a smaller part.

I configure automatic compaction at 90,000 input tokens because of the pricing threshold I describe for the particular model used in the workshop. The useful threshold depends on the provider and workload, not simply the model’s maximum advertised context.

The example enables prompt caching through the provider’s API. Reusing a stable prefix allows repeated requests to benefit from cached material rather than paying the same processing cost for all prior context each time.

The example also configures a provider compaction feature. An audience member asks where the logic lives: the configuration shown is client-side, while the provider implements the cache and associated machinery on its backend.

I run a task reading files, including a long lockfile, first without caching and then with it. The logger reports token usage and estimated cost. The agent does not follow the requested file-by-file process identically in each run, so the demonstration illustrates the mechanism rather than a strict benchmark.

The cached run shows a lower cost in the example. My broader point is to measure the whole conversation and its repeated input, then use caching where a stable context can be reused.

05

Break long tasks into phases

Kumar reports the results of one long-task experiment and demonstrates a phase tool that returns notes to a lead agent.

For long tasks, I have experimented with dividing work into phases or subagents. A single conversation can succeed at individual steps yet fail the overall objective; a fresh context for each part can make the work more manageable.

In one of my own tests, a 120-step task succeeded 29% of the time as one long loop and 85% when split into ten phases of twelve tasks. That is the result I report for this particular setup; the phases pass notes back for the lead to check and combine.

The sample phase tool gives a subagent the context needed for one part of a larger job and asks it to return a note. I demonstrate two phases that count lines in two project files, with the lead collecting their results.

06

Switch models and domains

A local Granite model runs offline after a configuration fix. Browser tools then reuse much of the same harness for a different task.

To test model portability, I disconnect from the network and switch to a small IBM Granite model through Ollama. The first attempt fails because I have not checked out the correct branch; after fixing that, the local model reads a file and writes another offline.

The local model initially needs a clearer instruction about which file to read, but the demonstration shows the harness can be used with a different model endpoint. A team can choose a model and environment appropriate to its constraints.

Next I change domains from coding to browser use. Much of the context and loop machinery remains, but I replace the tool set with actions such as opening a workspace, navigating and reading or interacting with a page; the permission rules also need to fit the new domain.

The browser example searches for open calls for papers. It navigates and reports that it did not find one. My point is the reuse of the surrounding machinery, not the specific search result.

An audience member asks how the model knows which tool to use. The tool set supplies names, descriptions and input schemas in the model request; the model returns a requested name and arguments, and the harness looks up and runs the matching function.

07

Decide what to build and what to buy

Kumar separates domain-specific tools and rules from durable infrastructure that can be managed. He closes with evaluations and a prediction about future agent systems.

Should a team build this or use a managed service? I show an API example that accepts a model, system prompt and tools while the provider runs the loop and supplies an environment. This delegates infrastructure and some control to the provider.

I expect teams to keep domain-specific tool registries, approval gates, phases and budgets close to their own business logic. For a browser agent, for example, long URLs and tracking parameters create context and budget considerations that differ from a coding task.

Durable execution is one area where a team might buy infrastructure: the loop may need to survive failures and network interruptions. I frame the decision around which operational guarantees a provider can offer and which rules the application must own.

My practical takeaway is that builders can construct these systems themselves, even if they also use existing coding agents. A good harness can change the outcomes available from a smaller model; my earlier workshop compared approaches using different model sizes.

Be deliberate about compaction, costs and approvals before actions that are difficult to undo. A large context window does not mean it is economical to let every task fill it. The application’s distinctive value remains its domain rules and the problem it solves.

Before putting a harness in front of users, evaluate whether its agents behave reliably. I point to a separate workshop on evaluations and connect that testing to the confidence needed for longer, less supervised workflows.

Looking ahead, I imagine reliable harnesses supporting “software factories” and a higher-level system that selects or creates specialized harnesses as needed. I present this as a prediction, dependent on those systems becoming reliably testable and controllable.

Sur la même chaîne

5 diapositives26:34EN
AI Engineer· 3 déc. 2026Joe Zein: Turn private-equity archives into context AI agents can useJoe Zein · Soal LabsA low-cost-first pipeline extracts, reconciles and traces decades of fund records before agents can rely on them.Data quality & curationAI agentsKnowledge graphs+1
4 diapositives17:31EN
AI Engineer· 3 déc. 2026Natalie Serrino: Faster AI changes what agents can doNatalie Serrino · Gimlet LabsA two-minute agent turn breaks a builder’s flow. Faster inference can help, but tool calls and the speed–throughput tradeoff still matter.InferenceAI cost & performanceAgents de code+2
8 diapositives1:02:59EN
AI Engineer· 2 déc. 2026Kent C. Dodds: build a feedback loop before letting agents shipKent C. Dodds · KodyMaps of reusable components, verifiable pull requests and tested recovery help coding agents work with less human review.Agents de codeIngénierie d’agentsWorkflows de développement et tests+2
4 diapositives15:43EN
AI Engineer· 2 déc. 2026Use Fast Decisions for the Routine Parts of Agent WorkflowsChibi Vikram, Kevin Bernstein · UiPathUiPath combines fixed steps, Jev decisions, and deeper agents, then uses evaluations to discover faster reranking and email-classification designs.Workflow automationIngénierie d’agentsÉvaluations+2
4 diapositives27:21EN
AI Engineer· 1 déc. 2026George Fraser: Give AI Agents a Map of Your Business DataGeorge Fraser · FivetranFivetran’s CEO argues that AI agents need the cleaned data and business definitions already maintained by data teams.Natural-language database queriesData quality & curationAI agents+2
4 diapositives29:13EN
AI Engineer· 1 déc. 2026Mihail Eric: Building Sales Judgment Into AgentsMihail Eric · MonacoMonaco pairs sales data and evolving memory with expert-guided evaluations, then embeds salespeople in the product team to refine its agents.IA en entrepriseAgent memoryIngénierie d’agents+2