<!-- Markdown twin of https://stevinhq.com/blog/does-architecture-still-matter. Generated at build; the HTML is the canonical page. -->

> Does architecture still matter when AI writes the code? | Stevin — A production refactor of MCP resources shows why clear state ownership, stable names and enforceable conventions matter more—not less—when AI writes code.
> Source: https://stevinhq.com/blog/does-architecture-still-matter · Language: en · 中文: https://stevinhq.com/zh/blog/does-architecture-still-matter

**Engineering** · Nov 30, 2026 · 13 min read

# Does architecture still matter when AI writes the code?

**[Hsuan-Kai Liao](https://www.linkedin.com/in/hsuankailiao/)** · Stevin team

On the morning of November 5, a paused task started running again.

The agent needed to call a tool from an external MCP server. Following the usual process, it first ran tool discovery (asking the system which tools are available right now), and the system said the tool was available. It then made the call and got back “Tool not found”.

The logs show what happened next. The agent checked the resource status, read earlier records, and tested the connection again. About two minutes later, it re-established the connection and the task continued.

Every step the agent took in those two minutes followed the process. The problem was that the system had given it two contradicting results, one saying “available” and one saying “not found”, so it had to check one by one which was correct.

Figure: Figure 1. In one resumed task, tool discovery returned available, then the tool call returned Tool not found. The agent checked status and retested for about two minutes before reconnecting and continuing. After the fix, discovery answers only from tools connected in the current turn, and this path is covered by a regression test.

This post records a refactor of our MCP, resources and skills modules during that period, and a few specific problems we ran into along the way.

## Who decides what an MCP server's state means?

Three terms first. Every external capability the agent can use is called a **resource**. An MCP server is a resource, and so is a written set of instructions, which we call a skill. The code that connects one kind of resource to the system is a **driver**. Beneath the drivers is a layer that manages registration, versions and state for all resources. We call it the **resource layer**.

Before the refactor, MCP state was spread across three places: tool discovery kept its own snapshot, the pre-call check made its own judgment, and the connection code made another. Normally all three agreed. When something went wrong, they could disagree.

That is what happened in the opening example: tool discovery read an old snapshot, while in this turn the server was not actually connected.

Three days earlier, on November 2, there was a clearer example. An MCP server that had been working disconnected several times in a row. The system re-probed it as designed and received a 401 (the error code for “unauthorized”). After that, the pre-call check decided the server had not passed review, the connection code decided it needed no authorization, and in the next turn its tools were not loaded at all. Each piece of code was reasonable on its own. The problem was that nobody had ever defined what “this probe failed” should mean.

The fix moved this decision into the resource layer and split it into two cases. If the result was only temporarily unavailable, the previously reviewed tools stay and the failure is recorded separately. If the server clearly changed its tool definitions, only then does the system stop using it and wait for a new review. The three places stopped deciding on their own and started asking the resource layer the same question.

The fix took 2 hours and 12 minutes from opening the PR to merging it, and it reached main the same day. It was quick mainly because the rule finally had a clear owner.

## Connection latency and resource state

That same evening, a chat message waited about 40 seconds for its first reply.

Broken down, nearly 20 of those seconds went to opening external connections. One connection that was already broken took 13.5 seconds to report failure. In the admin console, its status showed “ready” the whole time, so the system would try it again in the next turn.

Figure: Figure 2. One request took 40 seconds from message to reply card. Opening external connections took 19.9 seconds, including 13.5 seconds for one broken connection to report failure. This is a breakdown of one request, not an average.

A separate measurement looked at the step where every turn asked MCP servers for their tool lists on the spot. The median was 3.3 seconds, the 90th percentile 14.1 seconds (90% of requests finished within 14.1 seconds), and the longest 24.1 seconds. In 59 of 83 cases the cache was missed, and at the time this step took about half of the context preparation time.

Looking back, the problem was that the single word “ready” had to carry too much meaning: is it configured, has it passed review, can it be reached now, is it loaded in this turn. After the refactor, resource state was split into several independent fields. Servers now connect in parallel. A server that cannot be reached is skipped and retried later. Re-probing runs in the background so it no longer slows down the current request.

## Tool naming and call ambiguity

Another problem had to do with tool names.

Previously, the system added a source prefix to a tool name only when two servers had tools with the same name. That caused two problems. Connecting a new server could suddenly change the name of an existing tool. And in the list, some tools showed their source while others did not, which made them hard to tell apart.

Now every tool name always includes the resource it belongs to, similar to “server.tool”. Connecting another server later does not change existing names. If a name is too long, the system rejects it at review time instead of shortening it, because a shortened name could collide with another tool.

We found no record of this causing a wrong tool call in production. But this kind of error would be hard to spot in the logs, so we chose to fix it early.

Another ticket recorded three similar runs. In one, the agent took 8 steps and 129.7 seconds and was still checking configuration. In another, the agent reinstalled a server without applying a fix it had found in the previous turn. At the time, “connection failed” and “authorization required” returned almost the same message, so the agent could not tell whether to wait, retry or ask the user. Now each case has its own message and a suggested next step. If several tests fail in a row, the message explicitly says to stop retrying.

An agent chooses its next step based on what the system returns. When the messages contradict each other, or different situations return the same message, wrong decisions and repeated calls become more likely.

## Keeping development stable with AI in the loop

During that period the main repository had 415 non-merge commits, and 296 of them, about 70%, carried a co-author credit from an AI coding tool. A credit only shows that AI took part; it does not show who wrote which line. In our current process, AI drafts most of the code, people set the constraints and review, and quality checks in CI act as a final gate. Writing code is no longer the slowest step.

When AI changes code, it usually focuses only on the part it was asked to change. Ask it to fix the pre-call check and it adds a condition there. Ask it to fix the connection code and it adds another one there. The three-way disagreement described above most likely grew this way, one reasonable step at a time.

So a large part of this refactor went into turning conventions into rules a machine can check automatically. Which layer may depend on which, and whether skills may call MCP directly, became part of the CI quality checks, with no exceptions. Any change that crosses a boundary fails CI right away, instead of relying on a reviewer to notice.

Our documentation system has a more concrete example. Our user manual provides an MCP that both people and agents use to search and edit it. In late November we added tools for moving pages and images.

AI wrote the move feature in a few minutes. The hard part was two things: after a move, every link to the file must still point to the right place, and an edit must never overwrite someone else's newer changes with an old version.

Review found several edge cases one after another. Reference-style links (a Markdown style where link addresses are listed at the bottom of the page) broke after a move. Links split across two lines were not recognized. Reads used one version of a file and writes used another. At first we added a separate rule for each link style, but there was no end to it. So we wrote two principles into a decision record instead: whether a link is correct is decided by how the documentation site itself resolves it, and reads and writes must be based on the same version. Later the check was tightened from “the set of targets matches” to comparing each link one by one, so a correct link cannot hide a broken one.

Figure: Figure 3. Related test definitions increased from 34 before the move-tool work to 71 after. Definitions for editing MCP tools increased from 9 to 11; the two new tools move and delete images. Twice as many tests does not mean fewer production defects.

Once these two principles were in place, fixes became much faster. In the fastest case, 2 minutes and 50 seconds after review pointed out that reference-style image links would break, the author confirmed the problem and pointed to a fix. With the rules written down, AI writes code against them and people review against the same rules.

## An optimization we withdrew

We also once tried to take a shortcut ourselves.

The idea was: if some tools had already been discovered earlier in the same session, reuse them in the next turn and skip one model call. Review raised two problems. A session can span several users and last several days, so it is not the same as the current turn's context. And after an approval pause and resume, the visible tools may no longer be the set that was approved.

So the feature was first turned off by default, and later removed entirely before it reached main. Every turn still starts with no external tools available. It never shipped and never caused problems. It could be removed this cleanly because “each turn decides which tools it loads” was already a written rule that no optimization could bypass.

## Maintainability: how many files does one change touch?

Maintainability sounds abstract. In daily work, it mostly comes down to one question: how many files does a small change touch?

We used the merge that moved skills onto the resource layer as a dividing line and counted non-merge commits on main for 14 days before and after. Related commits went from 16 to 26, so the later two weeks were busier. But the number of files each commit touched across the repository fell from a median of 6 to 3, and from a mean of 9.44 to 5.38. For MCP-related commits alone, the mean fell from 10.38 to 4.05.

Figure: Figure 4. Files touched per commit: across all related repository commits, the median fell from 6 to 3 and the mean from 9.44 to 5.38. For MCP-related commits alone, the mean fell from 10.38 to 4.05. Related commits rose from 16 to 26. The sample is small and describes how far a change reaches, not a defect rate.

The fewer files a change touches, the less reviewers need to read, the fewer places AI has to keep consistent at once, and the easier it is to spot a change that crosses a boundary.

Since skills moved onto the resource layer, every edit creates a version that cannot be changed afterwards, and skills are scoped to either a person or a team. “Which version of this skill is current, and who uses it” now has a clear answer. The interface has not caught up yet. A UI review in mid-November found that a skill takes effect as soon as it is saved, with no preview, no comparison and no rollback. The versions exist underneath, but users cannot use them yet. That work is still on the to-do list.

## Call latency and repeated calls

After these changes, we went back to the traces (records of the timing and calls of every step in each run) to compare.

From October 20 to November 27, the same environment had 4,086 runs. The trace platform cannot filter by tool name, so we drew a random sample of 640 runs stratified by day, and grouped them by the build each run actually used: before skills joined the resource layer, after, after the authorization and tool discovery fixes, and after the state split and connection gateway shipped. A run counted as MCP-related if it called tool discovery, tool search or resource management. 130 runs met this rule, about one in five.

Figure: Figure 5. Median time from run start to first MCP-related call: before, 23.11 seconds (59 runs); after skills joined the resource layer, 23.78 seconds (30); after the discovery fix, 16.77 seconds (23); after the state split, 10.7 seconds (16). The 95th percentiles were 216.1, 68.1, 98.2 and 90.0 seconds. Samples are small, and the share of automated tasks and model mix differ between groups.

The clearest change is at the start: the median time to the first MCP-related call fell from 23.1 seconds to 10.7 seconds. The median length of a whole run barely changed, staying around one minute in most groups, while the 95th percentile fell from 541 seconds to 335 seconds. In other words, the agent started calling tools sooner, but the task itself did not get clearly shorter.

We also counted runs where the same tool was called three or more times in a row. This is not always an error, but it usually means the agent is retrying the same thing. Before skills joined, it happened in 1 of 60 runs. Right after, 8 of 30. After the discovery fix, 6 of 24. After the state split, back to 1 of 16. The two middle groups match the period when failed re-probes, authorization expiring after one hour, and wrong tool discovery results were most common.

These numbers should be read with care. The last group has only 16 runs, and only 4 of them are interactive. The traces also do not record tool results, so we cannot yet count how much errors such as “Tool not found” went down. What we can say is that in this sample, the agent started calling tools sooner, and the rate of repeated calls returned to its level before the refactor.

## Closing thoughts

Today, in the same situation as the opening example, tool discovery returns a direct answer: not connected in this turn, and why. The agent no longer spends two minutes checking which result is correct.

Looking back, the methods used in this refactor come down to four concepts.

The first is **a single interpreter**. Each piece of state is interpreted in one place, and everything else asks that place instead of deciding on its own. Whether an MCP server is connected and whether its tools can be used are answered by the resource layer. When the agent no longer receives contradicting information, repeated calls go down too.

The second is **separating meanings**. Words like “ready” and “failed” often cover configuration, review, connectivity and loading at once. Once they are split into independent states, people and agents can tell whether the next step is to wait, retry or ask someone.

The third is **stable names and boundaries**. Tool names always include their resource, so a server connected later does not change existing names. Which layer may depend on which is written as a rule in the CI quality checks. The tool list the agent sees does not change unexpectedly, and AI changes do not quietly cross boundaries.

The fourth is **writing conventions down**. Links are resolved the way the documentation site resolves them, reads and writes use the same version, and each turn decides what it loads. Once these rules are in decision records and tests, AI has something to write against, reviewers have something to check against, and shortcuts cannot go around them.

None of these ideas are new. They were true before AI as well. The difference is that they matter more in vibe coding. AI writes code quickly: a tool can be drafted in minutes, and an afternoon can produce several PRs. But AI focuses on one part at a time, so the faster the local changes, the easier it is for the whole system to become inconsistent. AI agents are also the most frequent users of these systems, and every unclear part of an interface directly affects their decisions, showing up as wrong calls, repeated calls and waiting.

So in a vibe coding workflow, architecture has not become less important. Its focus has shifted. It shows up less in individual lines of code and more in the decisions around the code: which layer answers which question, how names and boundaries are set, and which conventions become rules a machine can check automatically. With those decided, writing fast is a real advantage. Without them, writing fast only makes problems appear sooner and harder to find.

Most of the code can be handed to AI. Which layer answers which question is still something we have to think through for it first.

## Give Stevin a call.

[(978) 205-1112](tel:+19782051112)[Get started](https://stevinhq.com/get-started)

---

[llms.txt](https://stevinhq.com/llms.txt) · [Site map](https://stevinhq.com/sitemap.xml)
