Pipelines fixes ou décomposition adaptative
Enchaînez les requêtes pour les étapes connues ; utilisez l’adaptatif pour les tâches ouvertes.
Pipelines fixes ou décomposition adaptative est une leçon Claude Architect gratuite sur CoddyKit. Ceci est la leçon 1 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Claude Architect, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Claude Architect comprend 4 leçons au total.
Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.
Two Ways to Break Down Work
When a task is too big for a single prompt, you decompose it. There are two fundamental strategies, and choosing the right one is a core architecture skill.
- Fixed pipeline (prompt chaining): you hard-code a known sequence of steps. Step 1 feeds Step 2 feeds Step 3.
- Adaptive decomposition: the model decides what to do next based on what it discovers, looping until the goal is met.
The rule of thumb: fixed pipelines for known sequential steps; adaptive for open-ended investigations. This lesson makes that decision precise.
Fixed Pipeline = Prompt Chaining
A fixed pipeline is just prompt chaining: you orchestrate a deterministic sequence in your own code. You know the steps in advance, so you wire them up explicitly. Each call does one focused job, and its output becomes the next call's input.
Because you control the order, the flow is predictable, debuggable, and cheap to reason about. There is no model-driven branching about what to do next — only the work inside each step.
# Fixed pipeline: extract -> classify -> summarize
from anthropic import Anthropic
client = Anthropic()
def step(system, user):
r = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
system=system,
messages=[{"role": "user", "content": user}],
)
return r.content[0].text
entities = step("Extract entities as JSON.", document)
category = step("Classify this record.", entities)
summary = step("Write a one-line summary.", category)When a Fixed Pipeline Wins
Reach for a fixed pipeline when the work has a stable, known shape:
- The steps are the same every run (extract, then validate, then format).
- Order matters and rarely changes.
- You want predictable cost, latency, and easy debugging.
- Each stage has a clear, narrow responsibility.
Classic example: structured data extraction. Extract fields, then run a validation/retry pass, then attach provenance. You always do those three things, in that order — so chain them.
Adaptive Decomposition = Model-Driven
Adaptive decomposition hands the planning to the model. You give it tools and a goal; it inspects results and chooses the next action. This is the agentic loop: send a request, inspect the stop_reason, and if it's tool_use, run the tools, append results to history, and repeat until end_turn.
You cannot pre-wire the path because you don't know it in advance — it depends on what each step reveals.
# Adaptive: the model decides which tool to call next
while True:
resp = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=2048,
tools=tools,
messages=messages,
)
if resp.stop_reason == "tool_use":
results = run_tools(resp) # execute requested tools
messages.append({"role": "assistant", "content": resp.content})
messages.append({"role": "user", "content": results})
continue
break # terminate on stop_reason, never by parsing textWhen Adaptive Decomposition Wins
Choose adaptive decomposition for open-ended investigations where the path can't be known ahead of time:
- Debugging from a vague symptom — you grep, read, then grep usages based on what you find.
- Multi-source research where follow-up queries depend on earlier answers.
- Customer support where the next action depends on what a lookup returns.
Here the branching IS the work. A rigid pipeline would either miss paths or explode into unmaintainable conditionals.
Terminate on stop_reason, Not on Text
The single most common adaptive-loop mistake on the exam: ending the loop by scanning the model's text for words like "done" or "finished." Don't. Decisions are model-driven; terminate on the API stop_reason.
The loop ends when stop_reason is end_turn. While it's tool_use, you keep going. An iteration cap is a safety net only — never the primary stop mechanism. Reserve hard-coded control for guarantees, not for deciding when the work is conceptually complete.
# WRONG: parsing text for completion
if "done" in resp.content[0].text.lower():
break
# RIGHT: drive on stop_reason; cap is only a safety net
MAX_STEPS = 25
for _ in range(MAX_STEPS):
resp = client.messages.create(...)
if resp.stop_reason != "tool_use":
break # end_turn / max_tokens / stop_sequenceHybrid: Pipelines Containing Adaptive Stages
Real systems mix both. The outer flow is often a fixed pipeline, but one stage may be an adaptive agentic loop. You get the predictability of chaining at the macro level and flexibility where you genuinely need it.
Example: an extraction pipeline whose middle stage is an adaptive "resolve ambiguities" agent that may call lookup tools an unknown number of times — wrapped by a deterministic validate-and-format stage before and after.
# Outer = fixed chain; one stage = adaptive loop
raw = extract_stage(document) # fixed
resolved = adaptive_resolver(raw) # agentic loop inside
final = validate_and_format(resolved) # fixedMulti-Pass Code Review: A Decomposition Choice
Decomposition isn't only about pipelines vs loops — it's also about how you split a task to protect the model's attention. Multi-file code review is the canonical case.
A single pass over many files dilutes attention and misses both local bugs and integration issues. The fix is a deliberate decomposition: a per-file local pass first, then a separate cross-file integration pass. Two focused passes beat one unfocused pass.
# Decompose review into focused passes
for f in changed_files:
review_local(f) # pass 1: per-file, focused
review_cross_file(changed_files) # pass 2: integration concernsCoordinators Decompose Adaptively
In a hub-and-spoke multi-agent system, the coordinator decomposes the goal, delegates to subagents, then aggregates. This is adaptive decomposition at the orchestration layer — the coordinator decides how to split based on the request.
Critical: subagents do not inherit the coordinator's conversation history. Every subagent prompt must carry its full context explicitly. Multiple Task calls in one response run in parallel — useful when sub-problems are independent.
# Coordinator delegates with explicit, self-contained context
subagent_prompt = f"""You are researching ONE sub-topic.
Context (do not assume shared history):
Goal: {goal}
Sub-topic: {subtopic}
Constraints: {constraints}
Return findings with source citations."""Sessions: Resume, Fork, or Start Fresh
Adaptive work often spans sessions. Claude Code gives you --resume <name> to continue a named session and fork_session to branch from a shared point and explore alternatives in parallel.
But beware: resumed tool results can be stale if the codebase changed since. Sometimes a fresh session seeded with a structured summary beats resuming — you get current state plus the distilled context, without dragging outdated tool output along.
# Continue a named session
claude --resume refactor-auth
# Branch to explore an alternative path
# fork_session creates a sibling from the shared point
# When code moved on, prefer a fresh session + summary
claude -p "Here is a structured summary of prior work: ..."A Decision Checklist
Before you build, ask:
- Do I know the steps in advance, in a fixed order? -> fixed pipeline / prompt chaining.
- Does the next step depend on what earlier steps reveal? -> adaptive agentic loop.
- Mostly fixed with one uncertain stage? -> hybrid: chain the outer flow, embed an adaptive loop.
- Reviewing many files? -> decompose into per-file then cross-file passes.
And always: terminate adaptive loops on stop_reason, with iteration caps only as a safety net.
Quick Check
A scenario-based decision on choosing a decomposition strategy.
Recap
Key takeaways:
- Fixed pipeline (prompt chaining) for known, ordered steps — predictable, debuggable, cheap.
- Adaptive decomposition for open-ended investigations where the next step depends on what you discover.
- Hybrid is common: a fixed outer flow with an adaptive stage embedded.
- Always terminate adaptive loops on
stop_reason(end_turn); iteration caps are a safety net, never the primary stop. Never parse text for "done." - For multi-file review, decompose into a per-file pass then a separate cross-file pass.
- Subagents don't inherit history — pass context explicitly. Resume sessions carefully; a fresh session with a structured summary can beat stale resumed tool results.
Apprends Python avec un tuteur IA — gratuit
Écris et exécute du vrai code dans ton navigateur, obtiens de l'aide instantanée d'un tuteur IA disponible 24h/24, et reprends là où tu t'es arrêté sur le web ou dans l'app.
- Cours
- 26
- Leçons
- 104
Questions Fréquemment Posées
La leçon « Pipelines fixes ou décomposition adaptative » est-elle gratuite ?
Oui — le texte complet de « Pipelines fixes ou décomposition adaptative » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Claude Architect, passe à CoddyKit PRO. Le cours Claude Architect comprend 4 leçons au total.
Qu'est-ce que j'apprendrai dans « Pipelines fixes ou décomposition adaptative » ?
Enchaînez les requêtes pour les étapes connues ; utilisez l’adaptatif pour les tâches ouvertes. Tu pratiques Claude Architect avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.
Dois-je avoir de l'expérience pour commencer Claude Architect ?
Aucune expérience préalable n'est requise. Claude Architect sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 1 sur 4.
Combien de temps prend la leçon « Pipelines fixes ou décomposition adaptative » ?
La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.
Peux-tu écrire et exécuter du code dans cette leçon Claude Architect ?
Oui. Chaque leçon Claude Architect inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.
Toutes les leçons de ce cours
- Pipelines fixes ou décomposition adaptative
- Décomposition en plusieurs passes
- Gestion des sessions
- Contexte obsolète et nouveau départ