The Hidden Art of Making Intelligence Composable

Xuan Qin

Hatched by Xuan Qin

Jun 19, 2026

10 min read

78%

0

What if the hardest part of AI is not intelligence, but decomposition?

We tend to talk about large language models as if the main challenge were getting them to be smarter. But in practice, the harder problem is stranger: how do you break a messy task into pieces an AI can reliably handle, then stitch the pieces back together without losing meaning? That question sits underneath everything from recursive algorithms to LLM application design.

The moment you ask an AI to do something real, the task usually stops looking like a single problem and starts looking like a tree. A document becomes chunks. A recommendation task becomes candidates. A conversation becomes memory plus context plus output formatting. And once you see the world this way, a surprising connection emerges: the same logic that makes recursion dangerous or elegant also explains why modern AI systems need frameworks, orchestration, and careful control over state.

The deeper lesson is not merely that structure helps. It is that intelligence becomes useful only when it can be composed.


The tree you do not see

A recursive function looks simple when you write it. But its hidden cost appears only when you draw the call tree. A single call may branch into two, which branch into two more, and so on. Before long, a tiny line of code has become a full binary tree with explosive growth. That is why a recursive solution can appear elegant while secretly being expensive.

This is where memoization changes more than performance. It changes visibility. By caching repeated subproblems, you are not just avoiding redundant work, you are making the complexity legible. The hard part of recursion is often not the recursion itself, but the repeated recomputation that makes the tree grow unchecked.

That same problem shows up in LLM workflows. Ask a model to analyze a whole dataset at once, and you create a giant context tree in disguise. Ask it to reason across many documents without structure, and you invite repetition, drift, and token waste. What looks like one task is actually many overlapping subproblems, and without a decomposition strategy, the model keeps redoing work it has already implicitly done.

Think of a sales report: if you ask an LLM, “What are the key trends in these 5,000 rows?” the naive approach is to stuff the data into context and hope for the best. That is the equivalent of letting recursion expand until it hits the wall. A more disciplined approach splits the task into chunks, extracts local meaning, then combines results. That is not just a software technique. It is a cognitive principle.

The difference between brittle intelligence and scalable intelligence is often whether repeated work is recognized as repeated work.

Memoization and LLM orchestration share a hidden ethic: do not recompute what can be remembered, summarized, or reused.


Why prompt engineering is really complexity management

The popular story about LLMs says the main skill is writing better prompts. That is only partly true. Prompting matters, but the larger challenge is determining the shape of the computation.

A useful framework is to think of every LLM application as containing five design questions:

  1. What is the unit of work?
  2. What state must persist across units?
  3. How are partial results combined?
  4. When do we stop refining?
  5. How do we choose among competing outputs?

These questions are the software version of recursion analysis. In a recursive algorithm, you care about the base case, the branching factor, the repeated subproblems, and the way results propagate upward. In an LLM pipeline, you care about chunking, memory, aggregation, iteration, and ranking.

This is why abstraction layers matter. A framework that helps swap models, manage history, parse outputs, and coordinate chains is not just convenience plumbing. It is a way of controlling complexity. If a model is the reasoning engine, then the framework is the scaffolding that prevents the reasoning from collapsing under its own weight.

Consider a customer support assistant. If you ask it to answer directly from a long conversation, it may miss earlier constraints. If you preserve chat history, you let the task retain state. If you use an output parser, you force the answer into a format your system can trust. If you use chains, you make multi-step work explicit. If you use agents, you allow conditional branching when the path is not fixed in advance.

This is the key point: LLM applications are not just prompts plus models. They are recursive systems with memory, branching, and aggregation.

The better the decomposition, the less mystical the intelligence becomes. And the less mystical it becomes, the more dependable it gets.


Four ways to combine fragments without losing the whole

Once you accept that an AI task is usually a composition problem, the question becomes: which composition pattern fits the job?

A helpful mental model is to think of four modes, each corresponding to a different kind of complexity.

1. Stuffing: when the whole thing fits in memory

Sometimes the simplest answer is best. If the dataset is small, you can put everything in context and ask for a direct answer. This is like solving a tiny recursive problem without optimization because the branching is trivial.

The strength of this method is obvious: there is no coordination overhead. The weakness is also obvious: it scales poorly, and it tempts you to mistake convenience for generality.

Use this when the problem is genuinely small, tightly bounded, and unlikely to grow.

2. Map-reduce: when local meaning must be aggregated

Map-reduce is the pattern most people intuitively understand once they see it. Split the data into chunks, analyze each chunk, then combine the partial results into a final answer. This is the natural choice when the task resembles “find the common themes across these reports” or “summarize this long corpus.”

Its power is that it respects the limits of context while preserving coverage. Instead of asking the model to carry the whole burden at once, you let it perform a series of local computations and then synthesize them.

This is almost the computational cousin of reading a book chapter by chapter, then writing an essay from the chapter notes. The final argument is not in any one chapter. It emerges from the structure of the reduction step.

3. Refine: when truth emerges through iteration

Some tasks are not about independent chunks. They are about convergence. You begin with a rough answer from the first piece of evidence, then improve it incrementally as new evidence arrives. This is powerful when the output should become more precise over time rather than merely more complete.

Refine resembles a Bayesian instinct: each new piece of information updates the current belief. It is ideal for tasks like evolving summaries, iterative drafting, or synthesizing evidence into a single narrative that must improve as the evidence accumulates.

This pattern mirrors a recursive algorithm with a strong base case and repeated updates. The key is that the system must not restart from scratch each time. It must carry forward the best current state.

4. Map-rerank: when the best answer matters more than the average answer

Some tasks do not need an average. They need a winner. In recommendation systems, search, and selection problems, you often care less about merging every partial result and more about scoring candidates so the best one rises to the top.

Map-rerank works because it separates generation from judgment. First, produce options. Then evaluate them. This is a crucial distinction because many AI systems fail not in generation, but in choice. They can list ten plausible answers and still fail to select the right one.

The real insight here is that not all aggregation is averaging. Sometimes the correct operation is ranking, not merging. That is a different kind of complexity, and it demands a different kind of orchestration.


From recursion to recommendation: the same hidden law

At first glance, recursion analysis and LLM workflow design seem like topics from different universes. One is about algorithms. The other is about AI product architecture. But they share a single underlying law: the cost of intelligence is determined by how many times you make it revisit the same structure.

In recursion, repeated subproblems create exponential blowups unless you cache or restructure the computation. In LLM systems, repeated context, duplicated prompts, and uncontrolled conversation history create cost blowups, latency, and inconsistency. Memoization and orchestration are both answers to the same issue: how do you prevent the system from working too hard to rediscover what it already knows?

This is especially important for recommendation systems built with LLMs. A recommendation engine is not just a generator of options. It is a process of narrowing uncertainty. You might retrieve candidates from a database, summarize their features, score them against user intent, and return the best fit. Each step is a subproblem. Each step can be chained, cached, or reranked.

Imagine recommending a course to a learner. The system might:

  1. Retrieve courses relevant to the learner’s goals.
  2. Summarize each course against the learner’s history.
  3. Rank the courses by fit.
  4. Refine the ranking if the learner has additional constraints, such as time or level.

That is not a single prompt. It is a controlled computation. The model does not replace structure. It requires structure to be trustworthy.

The most powerful AI systems will not be those that answer in one shot. They will be those that know how to break, remember, combine, and choose.

This is the bridge between algorithm design and LLM design: both are fundamentally about managing the shape of work.


A practical mental model: the four verbs of scalable intelligence

If you are building with LLMs, the easiest way to avoid chaos is to think in four verbs: split, remember, combine, choose.

Split the problem into units small enough to handle reliably. This prevents context overflow and reduces cognitive noise.

Remember what matters across units. Use history, state, or cached intermediate outputs so the system does not repeat itself.

Combine partial outputs with a deliberate strategy. Sometimes that means summarizing. Sometimes it means voting. Sometimes it means iterating toward a better draft.

Choose when the task is competitive, not additive. In recommendation or ranking, the goal is to select the strongest candidate, not to average the field.

This framework is useful because it turns a vague aspiration, “make the AI work,” into an engineering question, “which verb dominates this task?” A document summarizer mostly splits and combines. A conversational assistant depends heavily on remembering. A recommender system emphasizes choose. A research synthesis tool may need all four in sequence.

The power of the framework is not only operational. It also protects you from a familiar trap: overtrusting the model’s fluency. A fluent answer can conceal a bad computation. A structured pipeline can reveal when the answer is actually supported.


Key Takeaways

  • Do not think of LLM tasks as single prompts. Most real tasks are decompositions that need chunking, state, aggregation, or ranking.
  • Use the right combination pattern for the job. Stuffing is for small inputs, map-reduce for broad synthesis, refine for convergence, and map-rerank for selection.
  • Treat memory as a first-class design choice. Chat history, cached intermediates, and parsers are not extras, they are what make outputs reliable.
  • Ask which subproblems repeat. If the same reasoning is happening multiple times, cache, reuse, or restructure it to avoid exponential growth.
  • Design for composition, not just generation. The best AI systems do not merely produce text, they coordinate pieces of work into a trustworthy whole.

The real lesson: intelligence is only useful when it can be organized

We often imagine intelligence as a spark, a sudden answer, a single elegant idea. But practical intelligence is usually less romantic and more architectural. It is the ability to hold partial truths, carry them forward, and assemble them into something more useful than any isolated fragment.

That is why recursion and LLM orchestration belong in the same conversation. Both reveal that complexity is not defeated by brute force. It is managed by shape. A recursive function becomes tractable when repeated work is controlled. An AI application becomes reliable when prompts, memory, chunking, and ranking are composed with intention.

So the next time a model gives you a decent answer, ask a deeper question: Was that intelligence, or was that organization? The best systems will be both. But the organization comes first.

Because in the end, the frontier is not whether machines can think. It is whether we can teach them, and ourselves, how to make thought composable.

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣
The Hidden Art of Making Intelligence Composable | Glasp