Trail content
8 minEnglish narration, Portuguese subtitlesPodcast (RSS)
Chapters
  1. 0:00Opening
  2. 1:10The diagnosis
  3. 2:15Why it happens
  4. 2:46What it costs
  5. 3:57A challenge
  6. 4:47The treatment
  7. 6:14Is it this smell?
  8. 7:19Wrap-up
Transcript

Opening

The marketing team has an agent that turns a brief into a published post. It researches the topic, writes the draft, reviews it against the brand guide, and publishes it to the blog. All in the same loop, with the same context, and the same tools.

Here's how it was configured, more or less word for word. You are the content agent. Research, write, review rigorously, and publish only when it's excellent.

And the tools. Web search, fetch a page, read the brand guide, write and edit the draft, check plagiarism. And also publish the post, post to social media, update the CRM, and send the newsletter.

One Friday, the agent published a draft with a competitor's figures, copied from a page it read during research. The review step was in the prompt. But it was the same model, with the same context full of web pages, reviewing its own text, with the publish tool within reach the whole time. In this lesson, you'll learn to see this smell, and where to make the cut.

The diagnosis

Here's the shape. The whole task goes to one agent.

It holds every tool, and a prompt that tries to describe every role.

Untrusted content from the research enters the same context that will decide whether to publish.

Whoever reviews is whoever wrote, looking at the same material.

And the side effect tool is available from the very first step.

How do you spot it? One agent handles steps of different kinds. Research, production, review, and execution, all mixed together.

Every tool, read and side effect alike, is available at every step.

The system prompt describes several roles. You are researcher, writer, and reviewer.

Review happens in the same context that produced the work. And by the end of the task, that context still carries all the raw material from the start.

And a problem in one step forces changes to the prompt for all of them.

Why it happens

It starts small. The agent only wrote drafts. Publishing was just one more tool.

One agent looks simpler. One prompt, one loop, one deploy. Splitting looks like needless complexity.

Good models cope in the demo. On short tasks, the single agent works fine. The problem only shows up at scale, or in odd cases.

And nobody draws the boundaries. Without someone asking which steps really exist, they blend together.

What it costs

The first cost is quality. Review in the same context tends to agree with what was produced. The model rereads its own reasoning, not the result with fresh eyes.

Then security. Untrusted content read during research sits in the same context as the side effect tools. That's the recipe for an attack where instructions hide inside the pages an agent reads. A mega agent that researches and publishes in the same context is the classic target.

Then context. The end of the task carries the clutter of the start. That's context rot.

And maintenance. Changing how review works means editing the prompt that also researches and writes. And each change affects everything.

Picture the same pattern in an online store. An agent that answers delivery questions, looks up the order, and issues refunds. A simple where is my package still has the refund tool on the list. Text in a product description, or a creative user, pushes the model toward the side effect.

A challenge

Here's one for you. The content agent researches, writes and publishes. You can make one change this week. Which cut reduces the most risk?

Take the publish tool out of the model's loop, and publish in a code step, with approval. A side effect tool available during research is the risk that already broke on Friday. Isolating the effect is the smallest cut. Research and writing can wait for the next slice.

Adding a second role whose only job is to review rigorously, in the same context with the same tools, isolates nothing. The reviewer still sees the pages, and can still publish. And telling the agent to forget the pages after the draft doesn't remove a single token, or a single tool.

The treatment

There are two refactorings. Extract subagent, when there are steps with their own tools and context, like research and review. Each becomes a subagent that returns only its result. And introduce a router, when the agent handles different kinds of requests, each needing different tools. Often, the final step, publish, pay or send, doesn't even need a model. It becomes code, behind approval.

Here's the smallest cut that already reduces harm. Research reads the web in an isolated context, and returns cited facts. Not raw pages.

Writing gets the brief plus those facts, without the pages.

Review gets the draft plus the brand guide, without the writer's reasoning.

And publishing is code, with a person in the loop, if the channel is public.

But don't overcorrect. The opposite is a smell too. A pipeline of five agents with job titles. A researcher, an analyst, a writer, a reviewer, and an editor. Each takes the previous one's text, and returns nearly the same text. It costs five times as much, with no real split of tools or context. That smell has a name of its own, decorative multi-agent. Split where the nature of the work changes, not where the org chart wants a job title.

Is it this smell?

Three cases to sharpen the eye. A support agent answers questions, looks up orders, and issues refunds, with one prompt and one set of tools. Refunds above a hundred dollars go to a person. Is it a mega agent? Yes. The approval covers big amounts, but the question answering path still has the refund tool within reach. A router would separate the paths.

A research agent reads sixty pages and writes a report. No side effects at all. But the report sometimes ignores sources read early on. That's a milder version, mixed with context rot. Split the reading into subagents that return cited summaries.

And an engineer using a terminal assistant to edit a repository, approving every change it proposes. Read and write tools in one agent, under continuous supervision. That's fine. The smell hurts when the same loop reads the web, and fires a side effect, with nobody watching.

Wrap-up

So here's the idea to take with you. When one agent researches, writes, reviews and acts, every step inherits every risk. Separate the reading from the acting, give review fresh eyes, and turn the final side effect into code with approval. That's usually the cut that matters most.

In the next lesson, we'll make the main cut step by step: extract subagent. See you there.

SmellBloaters

Mega Agent

Mega-Agente

Mega Agent is an AI code smell, a sign of trouble in LLM systems, in the Bloaters group. One agent researches, writes, reviews, and publishes with the same context and the same tools.

Element
06/37
Level
Intermediate
Read
4 min
Updated
On this page 7
  1. 01Signs and symptoms
  2. 02Reasons
  3. 03Cost of ignoring
  4. 04Treatment
  5. 05Payoff
  6. 06When to ignore
  7. 07Is it this smell?
  8. ··Quick answers

Signs and symptoms

The marketing team has an agent that turns a brief into a published post. It researches the topic, writes the draft, reviews it against the brand guide, and publishes to the blog. All in the same loop, with the same context and the same tools. An excerpt of its configuration (anonymized):

system: You are the content agent. Research, write, review rigorously,
        and publish only when it is excellent.
tools:  web_search, fetch_page, read_brand_guide, write_draft,
        edit_draft, check_plagiarism, publish_post, post_to_social,
        update_crm, send_newsletter

One Friday, the agent published a draft with a competitor’s figures copied from a page it read during research. The review step existed in the prompt, but it was the same model, with the same context full of web pages, reviewing its own text with publish_post within reach the whole time.

Signs of a Mega Agent:

  • One agent handles steps of different kinds: research, production, review, execution.
  • Every tool, read and side-effect alike, is available at every step.
  • The system prompt describes several roles (“you are researcher, writer, and reviewer”).
  • Review happens in the same context that produced the work.
  • The context at the end of the task carries all the raw material from the start.
  • A problem in one step forces changes to the prompt for all of them.
flowchart TD
  B(["1. Brief"]):::io --> A(["2. One agent, one context, every tool"]):::llm
  A --> W["3. Web research"]:::untrusted
  W --> A
  A --> D["4. Draft and review in the same context"]:::tool
  D --> A
  A --> P["5. publish_post"]:::tool
  1. The whole task goes to one agent.
  2. It holds every tool and a prompt that tries to describe every role.
  3. Untrusted research content enters the same context that will decide on publishing.
  4. Whoever reviews is whoever wrote, looking at the same material.
  5. The side-effect tool is available from the very first step.
Check +20 XP on first tryOn Friday the agent published a competitor's figures from a page it read during research. Review was in the prompt. Why did review not stop the publish?

Reasons

  • It starts small. The agent only wrote drafts. Publishing was “just one more tool”.
  • One agent looks simpler. One prompt, one loop, one deploy. Splitting looks like needless complexity.
  • Good models cope in the demo. On short tasks the single agent works fine, and the problem only shows up at scale or in odd cases.
  • Nobody draws the boundaries. Without an explicit question about which steps exist, they blend together.

Greshake et al. (2023) documented indirect injection: instructions hidden in pages an agent reads. A mega agent that researches and publishes in the same context is the classic target. The Chevrolet dealership in Watsonville (2023) showed the other side of the same design: the bot that chats also executes a commercial action, and a malicious prompt became a Tahoe for one dollar.

Cost of ignoring

  • Quality. Review in the same context tends to agree with what was produced. The model rereads its own reasoning, not the result with fresh eyes.
  • Security. Untrusted content read during research sits in the same context as side-effect tools. That is the recipe for indirect injection.
  • Context. The end of the task carries the clutter of the start. See Context Rot.
  • Maintenance. Changing how review works means editing the prompt that also researches and writes, and each change affects everything.

Picture the same pattern in an online store: an agent that answers delivery questions, looks up the order, and issues a Pix refund (Brazil’s instant payment). “Where is my package?” still has issue_refund on the list. Text in a product description, or a creative user, pushes the model toward the side effect.

Treatment

Refactoring Choose it when
Extract Subagent There are steps with their own tools and context, such as research and review. Each becomes a subagent that returns only its result. Target: Subagent Delegation.
Introduce Router The agent handles different kinds of requests, and each kind needs different tools. A router picks the specialist.

Often the final step (publish, pay, send) does not even need a model: it becomes a code step behind approval. See Add Approval Before Side Effect.

The smallest cut that already reduces harm:

  1. Research reads the web in an isolated context and returns cited facts, not raw HTML.
  2. Writing gets the brief plus facts, without the pages.
  3. Review gets the draft plus the brand guide, without the writer’s reasoning.
  4. Publishing is code, with a human in the loop if the channel is public.

The opposite is also a smell: five agents that only pass text along, without splitting tools or context. That is Decorative Multi-Agent. Split where the nature of the work changes, not where the org chart wants a job title.

Check +20 XP on first tryThe agent researches, writes, and publishes. You can make one change this week. Which cut reduces the most risk?

Payoff

  • Each step with a short prompt, minimal tools, and a clean context.
  • Independent review that does not inherit the writer’s reasoning.
  • Web content kept away from side-effect tools.
  • Each step testable and tunable on its own.

When to ignore

  • Short, uniform tasks. An agent that only answers questions using two read tools does not need splitting.
  • A person supervises each step. A coding assistant in the terminal, with a human approving edits, tolerates a broad agent.
  • Steps that need the same context. If writing and adjusting depend on all the material read, splitting may cost more than it helps. At least separate the side-effect tools.

Is it this smell?

Check +20 XP on first tryA support agent answers questions, looks up orders, and issues refunds, all with the same prompt and tools. Refunds above US$100 go to a human. Is this a Mega Agent?

Check +20 XP on first tryA pipeline has five agents with job titles: researcher, analyst, writer, reviewer, and editor. Each takes the previous one's text and returns nearly the same text. It costs five times as much as one agent. Which smell is it?

Check +20 XP on first tryA research agent reads 60 pages and writes a report. It has no side-effect tools. The final report sometimes ignores sources read early on. What do you do first?

Check +20 XP on first tryAn engineer uses a terminal assistant to edit a repository. The agent has read and write tools. She approves every diff. Is this a Mega Agent you should split now?

Quick answers

What is Mega Agent?

Mega Agent is an AI code smell, a sign of trouble in LLM systems, in the Bloaters group. One agent researches, writes, reviews, and publishes with the same context and the same tools.

How do you fix Mega Agent?

With Extract Subagent and Introduce Router. Each refactoring has safe step-by-step mechanics with an eval before and after.

Where does Mega Agent show up in practice?

In the real-world scenarios Call center voice assistant, Content creation pipeline, and Back-office automation with durable execution.

Go further

Relations

Refactorings that treat it 2
Part of the tracks 1
Search