Tools that assumed one repository
Part 9 of 9 in Agents on large codebases
Contents
More and more of my agent work doesn’t happen inside a repository. It happens over all of them at once. Most of my tools were never told that, and they failed in the quietest way available: by answering as if nothing was wrong.
I keep about eighty repositories under one workspace directory. Sessions there start from ggh, a macOS app of mine that gives each repository a tab with an embedded agent and terminal, and serves the whole portfolio’s state (git status, CI runs, open pull requests) to agents over MCP. A maintenance run, a dependency sweep or a “which of these would benefit from X” question starts a session at the workspace root. The agent there plans, and hands each repository to a subagent of its own. That’s the shape of the work now. One agent session spans the portfolio, and the unit of work is a set of repositories, not one.
This week’s changes started with an ordinary question. Which of my projects would benefit from sending traces to habit, the local OpenTelemetry service that records how I use my tools? The answer was five tools: ggh itself; sustain, which keeps project dependencies current with a local-model fix loop; emx, a terminal editor; teleplot, which renders dashboards, including habit’s own; and tropism, a dependency analyser for polyglot repositories. That turned into instrumenting the five in parallel, rebuilding how habit stores traces, and fixing two assumptions that only showed up because the work spanned repositories. Here is what I learnt.
The session root is not the project
symgraph is the code-intelligence server my agents use instead of grep: who calls this, what breaks if it changes, what’s in this file. Claude Code starts one symgraph server per session, rooted at the directory the session started in. That design assumes the session directory is the project.
Over a workspace it isn’t. The workspace isn’t a git repository, nothing had indexed it, and indexing it whole would be pointless: eighty unrelated codebases in one graph. So when I fanned out five agents to instrument five repositories, every symgraph call they made went to an empty index. They reported it accurately, buried in their hand-back reports: “index is empty here (0 files)”, “No symbols found”, “not indexed”. Then they did the sensible thing and used grep. Nobody failed. The tool just quietly stopped being used.
When I spot-checked one repository by hand, symgraph worked fine. That was the clue. Started in the repository, the server had the right root. When I looked more closely there were three separate problems, and only one of them was the root:
| Problem | What it looked like |
|---|---|
| Wrong root | The workspace server had 0 files indexed, and its tools took no path argument, so there was no way to point a call at a repository |
| No index | tropism: 0 of 45 source files indexed |
| Stale index | teleplot 44 of 65, sustain 35 of 53: partial results that looked complete |
The stale one is the worst of the three. An empty answer at least looks suspicious. An answer with 44 of 65 files looks like an answer.
The fixes follow the failure modes:
- A root per call. Every tool takes an optional
root, either relative to the server’s directory ("emx") or an absolute path. A file or directory inside a repository means that repository’s git root. The server keeps one index per root, opened on first use, so a single server answers for every repository in the workspace, and for repositories outside it. - Refuse rather than answer from nothing. Without a
root, a server started over a workspace no longer returns “No symbols found”. It says the directory is a workspace of 83 repositories, not one project, and lists them. An agent that gets that error addsroot. An agent that gets an empty result reaches for grep. - Index on first query. The first call against a root builds its index if it’s empty, and rebuilds it if an older version built it. Nobody has to remember an index step, and in a fan-out nobody would.
- Refresh on every query. Each call first drops files deleted from disk, re-indexes changed and new ones, and re-resolves references only if something changed. On a 135–260 file repository a no-change refresh costs 25–46 ms in a debug build. Calls less than a second apart share one refresh and take about 1 ms, which matters because agents tend to fire several tools at once.
Two of those changes fixed bugs that predate the workspace problem. The incremental index never removed files deleted from disk, so a renamed file kept its old symbols until a full rebuild. And every incremental pass re-resolved every reference, even when nothing had changed. Neither mattered much when indexing was something a person ran occasionally. Both matter once it runs on every query.
The lesson generalises. I’ve written before about a tool admitting what it doesn’t know, and this is the same failure at a different scale. A tool built for one project that’s asked about a portfolio shouldn’t guess which project you meant. It should say it was asked the wrong question, and say how to ask the right one.
A switch for every process reaches the tests too
The second assumption came from the telemetry work itself, and it was mine.
Claude Code passes its OpenTelemetry settings neither to the MCP servers it starts nor to the commands its Bash tool runs. So a tool started by an agent never sees an endpoint in its environment and reports nothing. The obvious fix was a machine-wide file, ~/.config/habit/client.toml, which every instrumented tool reads when the environment has no endpoint. I added it, and from then on every tool on the machine reported to habit.
Including every test run. Within an hour habit held about two hundred records that weren’t real work:
- 52 from a tool called
brakethat I hadn’t run that day: it was the fake name in a library test; - 46 ggh spans from its test suite;
- 61 tropism MCP spans from its stdio tests;
- 35 teleplot spans from its router tests;
- one sustain run, from an agent checking a command before it had pointed at a throwaway server.
The brake records gave it away. habit-otel, the small tracing library the tools share, has a test that nests spans under a root, and the root exported. It exported to a port nothing listens on, so the export failed and went to the spool habit keeps for when it’s down, which is the real spool. habit drained it into the live store a minute later. Every make check in every repository that carries the library added more.
The fixes:
- The library’s own tests never export. Their roots discard their trace.
- Tests that start a tool’s binary set
HABIT_TELEMETRY=offin the child’s environment. - ggh reports nothing from a test process. Its suite runs in-process. I first tried detecting that with
Bundle.allBundles, which missed it: swift-testing runs the suite in a helper process that loads the test bundle without listing it there. The check now looks at the loaded images. habit forget --tool <name> --since <time>deletes one tool’s records. That’s what cleaned up the two hundred.
The general point: a machine-wide switch is a decision about every process on the machine, and test processes are processes. If a tool reads configuration from the user’s home directory, its test suite needs a way to say “not me”, and its own library tests have to use that way before anyone else’s do.
What the traces were for, and what they found
The original problem was in habit’s Time dashboard. Its trace timeline listed bare span names, and with more tools reporting, a span called scan or run could belong to anything. The causes were in how habit stored spans. It labelled a span with its name alone, gave it no type, and dropped the child spans of CLI runs entirely, so a run was a single bar with nothing inside it. habit now keeps every span, labels a run <tool> · <step> and a request <step> → <host>, works out a span type from standard OpenTelemetry attributes, and records each span’s own time: its duration minus the time covered by its children. A new “Slowest steps” table ranks steps across all traces by own time, and the timeline became the drill-down.

That’s the table for the first 55 minutes after ggh was restarted with tracing switched on. Each row is one kind of step, across every trace it appeared in. Own time is what puts the work itself at the top rather than whatever happens to wrap it.
Own time needs a whole trace in one request, because a parent’s own time depends on all of its children. The standard SDK exporters send spans in batches and can split a trace across them. So each tool carries a copy of habit-otel, a single std-only Rust file of about a thousand lines, tests included, that sends a trace in one request when its root ends. habit isn’t published, so each Rust tool vendors the file, and ggh has a Swift port. That’s a trade: five copies to keep in step, in exchange for exact own time and no SDK dependency in tools that start in milliseconds.
Then the traces started showing things nobody had instrumented for:
- ggh started nine login shells at once. ggh’s MCP calls are the slowest on my machine, with a p95 of about 7.5 seconds. Its first trace showed nine
resolve login PATHspans in a single call. The PATH cache is an actor, the actor suspended before storing its result, and every concurrent first caller started its own shell. That’s fixed now; concurrent callers share one resolution. The traces also showed eachghcall taking 0.4–1.2 seconds, against 2 ms or less for ggh’s own work. - ggh’s biggest cost is a poll nobody asked about. Its first hour of real use put a background job at the top of the table, not an MCP call. ggh polls CI every 60 seconds, once per open repository tab, and that came to 316
gh run listcalls and 4.25 minutes of GitHub time in 55 minutes. The timeline shows one poll: 82% of its own time is the GitHub call. Twogh searchcalls had medians of 27 and 10 seconds, which makes them the first place to look for that 7.5-second p95.

- sustain spends its time in the model and in cargo’s lock. In test runs, local-model calls took 91 seconds and
cargo build23. Holding cargo’s package cache from another process showed up as a 15.5-secondcargo lock waitstep, a name nobody would think to grep a log for. - sustain checks its libraries one at a time. A dry run over two small repositories took 5.4 seconds, and 3.8 of them were its last step, which asks whether any of my libraries have unreleased changes. That step is five
git ls-remotecalls, each about 0.7 seconds of network round trip, run one after another. git was 67% of the run’s own time. Nothing in sustain’s output says so, but the bar chart does at a glance. Running the five calls together took the step from 3.8 seconds to 1.0, and the same dry run from 5.4 to 2.6.

- teleplot asks Elasticsearch for field lists on every request. It does this even when the dashboards it’s serving don’t use Elasticsearch, as none of habit’s do: each request makes a
_field_capscall to a server that isn’t running, and the failure is never cached. - tropism repeats work. Its
workspacescommand runs discovery and workspace resolution twice.analyzeparses its own config file twice. - ggh reported repositories without a remote as errors.
git remote get-url originexits with code 2 when there is no origin, which is an answer, not a failure. The span recorded it asexit_2on every poll, for every such repository. The fix lets a caller say which exit codes are answers.
None of these was the question I set out to answer. Telemetry that only measures what you already suspect confirms the suspicion. The value came from tracing the steps, not just the totals, and putting every tool’s steps in one ranked table where an outlier has nowhere to hide. Even the test pollution was spotted this way: habit showed records for a tool I hadn’t run.
Other things worth keeping
- Agents in a fan-out need the facts their tools don’t have. The subagents did good work, and their reports were candid about what didn’t work. But each one hit the empty symgraph index on its own, worked round it on its own, and mentioned it in a footnote. A fan-out multiplies a tool’s blind spot by the number of agents. The brief is the only context a subagent has, so it now carries the
rootto pass, and the user-level instructions say to include it. - Shared scratch space is shared. Parallel agents wrote to one scratch directory, overwrote each other’s helper scripts, and one agent’s verification run spooled into another’s throwaway server. Each worker gets its own directory now.
- Verify against a throwaway server, never the live one. Every agent checked its tool against its own habit, started on spare ports with
--capture, so it could see exactly what was sent and grep it for leaked paths. The one exception happened before the rule existed. It was the reason for the rule. - Idempotent codemods have edge cases. colab is my codemod tool: it states a change once as a structural rule and applies it everywhere it matches. I used it to add the new
rootfield to sixteen request structs, guarded so that a second run would change nothing. The same guard on the matching sixteen call sites stopped matching once the formatter moved each field onto its own line, so a second run would have added them again. A codemod’s report says what it changed. It’s worth running it twice to see that the second run changes nothing. - The tool hosting the session is part of the session. The portfolio session runs in a terminal inside ggh. Rebuilding ggh to pick up its new tracing meant relaunching it, which ended the session doing the work, along with two installs still running in the background. Tools that host agents are infrastructure for those agents, and restarting them is a deployment.
What it doesn’t do
- The refresh walks the tree. That’s at most once a second, at tens of milliseconds for a few hundred files. A very large repository will want a file watcher instead.
rootisn’t inferred from a tool’s own file argument. A caller in a workspace has to passroot, though the error tells it to.- Own time assumes the whole trace arrives at once. That’s exact for habit-otel. For an SDK that exports a trace in several batches, a parent looks slower than it is.
- The traces so far are short. Apart from ggh’s first hour, they come from test runs. The
gh searchmedians point at the 7.5-second p95 but don’t yet explain it. That needs a week of real use in the “Slowest steps” table.
The portfolio is the project
The two failures had the same shape. symgraph assumed the directory a session started in was the project. The telemetry switch assumed every process that read it was doing real work. Both were reasonable when one person ran one tool in one repository. Neither holds once an agent runs across many repositories, starts subagents, runs every test suite and reads every config file in the course of an afternoon.
What I’d take from it is a short checklist for any tool an agent will use across a portfolio:
- Every query states its scope, explicitly, at least when the tool can’t work it out unambiguously.
- An empty answer says whether it’s empty because nothing matched, or because the tool can’t see.
- Anything that’s on for the whole machine has an off switch that tests use by default.
- Trace the steps, not just the totals.