Interview prep
RefactoringComposing prompts

Inline Trivial Step

Embutir Etapa Trivial

Inline Trivial Step is an AI refactoring for LLM systems, in the Composing prompts group. Remove a call that does not change the result and fold its work into the neighboring step.

Element
02/35
Level
Beginner
Read
5 min
Updated
On this page 8
  1. 01Problem
  2. 02Solution
  3. 03Before and after
  4. 04Why it works
  5. 05Safe mechanics
  6. 06Risks
  7. 07Challenge
  8. 08Check your understanding
  9. ··Quick answers

Problem

A pipeline step does not change the result measurably, but it costs a whole call. The most common case is the Redundant Self-Critique smell: the model writes a text and, in the next call, reviews its own text without receiving any new information.

Imagine a news site that generates 10,000 summaries a day. The pipeline has two calls: summarize and review. When the team compares the outputs, they see the review returns the draft unchanged, or with one comma moved, in the vast majority of cases. The second call has become an expensive rubber stamp.

Solution

Remove the call that does not change the result and move whatever was useful in it (a criterion, a format, a check) into the neighboring step or into code.

Before and after

 def write_summary(document):
-    draft = llm("Summarize the document in at most 150 words.", document)
-    reviewed = llm("Review the summary below: fix mistakes, make it clearer, "
-                   "and keep it to at most 150 words.", draft)
-    return reviewed
+    summary = llm("Summarize the document in at most 150 words. Keep names, "
+                  "numbers, and dates exactly as in the original.", document)
+    if word_count(summary) > 150:
+        summary = truncate_to_sentence(summary, max_words=150)   # rule in code
+    return summary

Before: two calls, and the second almost always returns the first.

flowchart LR
  D(["1. Document"]):::io --> G(["2. Summarize"]):::llm
  G --> R(["3. Review its own summary"]):::llm
  R --> OUT(["4. Summary"]):::io

After: one call with the useful criterion built in, and the objective rule in code.

flowchart LR
  D(["1. Document"]):::io --> G(["2. Summarize with the criterion"]):::llm
  G --> C["3. Check length in code"]:::tool
  C --> OUT(["4. Summary"]):::io
  1. The same document comes in.
  2. The generation prompt receives the criterion the review was trying to apply.
  3. The objective part (length) becomes code, which counts words without mistakes.
  4. The result goes out with one fewer call.

Why it works

A review step with no new information reads the same thing with the same model and tends to agree with it. Its value is usually an instruction that could live in the previous step (“keep the numbers exact”) or an objective rule that code handles better (“at most 150 words”).

Look at one detail of the old code: the review receives only the draft, not the document. It has no way to know whether a number is right. The most it can do is rewrite, and every rewrite is one more chance to turn “$1.2 million” into “$12 million”.

Research points the same way. The paper “Large Language Models Cannot Self-Correct Reasoning Yet” (Huang et al., 2023) showed that, without an external signal, asking a model to review its own answer does not improve reasoning and sometimes makes it worse.

Building the criterion into the generating step prevents the error instead of trying to fix it later. The generator is the one that sees the original document, so it is the one that needs to hear “keep the numbers”. Moving the objective rule to code swaps a probabilistic call for a deterministic check.

The math of a trivial step

An illustrative calculation shows where the cost lives. Suppose a 3,000-token document and a 200-token summary.

Input Output Wait
Summarize 3,000 tokens 200 tokens one generation
Review about 250 tokens 200 tokens another full generation

The review’s input is cheap. What weighs is the output: the model writes the summary again, token by token. Output tokens usually cost several times more than input tokens, and they are what decides how long the user waits. At 10,000 summaries a day, that is 2 million extra output tokens to return nearly the same text.

Check +20 XP on first tryYour pipeline writes a summary and then calls the same model with 'review the summary below', passing only the draft. What can this review guarantee about the numbers in the text?

Safe mechanics

  1. Measure. Run the eval on the current pipeline and record quality, cost, and latency. Also keep the output before and after the suspect step, for every case.
  2. Compare the step’s input and output. Count in how many cases the output differs meaningfully. A simple metric is enough to start: the share of characters changed. If 95% of cases change by less than 2%, the step is barely working.
  3. Read the cases that changed. Did the change improve things, make them worse, or just swap words? Sometimes the little that changes is exactly where the step does damage.
  4. Run the eval without the step. If quality does not drop, it is a candidate for removal.
  5. List what the step was trying to guarantee. Separate criteria (they go into the previous prompt) from objective rules (they go into code).
  6. Move the criterion and the rule, and remove the call.
  7. Measure again. Equal or better quality, one fewer call, lower latency. Check per category too, not only the average.

Risks

  • The step helped on rare cases. The average hides it. Check the eval per category and the hard cases.
  • The previous prompt bloats. If the moved criterion is long, consider whether the step deserved to become a check with an external signal, as in Reflection.
  • Truncating in code can cut badly. Cut at a sentence boundary and record when a cut happens. If cuts are frequent, the generation prompt needs tuning.

Common mistake: throwing away a review that had a signal

Not every review is trivial. What separates them is the information the step receives.

Signal Trivial step Step worth keeping
What it sees Only the previous output The output plus something new: the document, a test, a tool result
Who judges The same model, with the same vague request A clear rubric, another model, or code
What it produces Almost always the same text Concrete problems that change the result

A step that compares the summary with the document and lists mismatched numbers has a signal. So does a step that runs the tests of generated code. Those become an Evaluator-Optimizer, not a step to inline.

Check +20 XP on first tryYou are auditing a pipeline with several review calls. Which one should you NOT inline into the previous step?

Challenge

This ticket classification pipeline has a step that may be trivial. Which one, and what do you do with it?

1. classify(ticket) -> category
2. confirm("Is category X correct for this ticket? Answer yes or no.")
3. if "no": classify again
Show solution

Step 2 asks the model to confirm its own answer, with no new information. It almost always says “yes”. Remove steps 2 and 3. Instead, ask for a confidence along with the category (structured output with confidence, or token probabilities when the API offers them) and calibrate the threshold on the eval, because the confidence a model states does not always match its real hit rate. Low-confidence cases go to human review or to a larger model, as in a Model Cascade.

Check your understanding

Check +20 XP on first tryYou removed the review and the eval's average accuracy stayed the same: 92% before and 92% after. What is left to check before deploying?

Check +20 XP on first tryThe old review guaranteed 'at most 150 words'. Where does that rule go after the refactoring?

Check +20 XP on first tryWhy does building 'keep names, numbers, and dates exactly as in the original' into the generating step work better than asking for that fix afterwards?

Check +20 XP on first tryAfter every classification, your ticket classifier asks the model 'is category X correct? yes or no'. Which change fixes this best?

Quick answers

What is Inline Trivial Step?

Inline Trivial Step is an AI refactoring for LLM systems, in the Composing prompts group. Remove a call that does not change the result and fold its work into the neighboring step.

What problem does Inline Trivial Step solve?

It treats Redundant Self-Critique.

Which pattern does Inline Trivial Step lead to?

The Prompt Chaining design pattern.

Go further

Relations

Smells it treats 1
Target patterns 1
Shows up in scenarios 1
Search