Course Content
CrewAI Multi-Agents
9 sections · 53 lessons
How do you ensure consistency across agent outputs?
What you need to know
"Consistency" means two things, and they have different fixes.
Format and style consistency
- Same fields, headings, units and tone
- Fixed by schemas, shared style rules and one model
- Checked by code guardrails
Factual consistency
- Same numbers and names in every section
- Fixed by passing one source through
context - Checked by comparing fields in code
Tools for format and style
- Schemas everywhere.
output_pydanticmeans every agent returns the same field names and types. Adatefield cannot come back as "yesterday". - One style contract. Put tone, glossary and format rules in one string and include it in each task description with an input variable (for example
{style_guide}), or load it as aStringKnowledgeSource. One place to change it. - Same model, low temperature for tasks of the same kind. Mixing models across sibling sections shows up quickly as different tone and length.
- A code guardrail that checks required sections, units (₹, not Rs or INR) and banned phrases. It is cheaper and stricter than a reviewer agent.
- An editor task at the end that only standardises terms and formatting, with a firm "do not add facts" rule.
Tools for facts
If three agents need the same number, compute it once and pass it through context to all of them. Do not hope that each agent will retrieve the same value from memory or search; retrieval can return different results each time.
1facts = Task(description="Collect today's headline figures",2 expected_output="Figures with sources", agent=data_agent,3 output_pydantic=DailyFigures)45markets = Task(description="Write the markets section. {style_guide}",6 expected_output="120 words", agent=writer,7 context=[facts], guardrail=check_style)8tech = Task(description="Write the tech section. {style_guide}",9 expected_output="120 words", agent=writer,10 context=[facts], guardrail=check_style)A real-life example
A media startup runs a daily news-digest flow at 6 am. Five writer agents produce sections: markets, tech, sport, politics and weather. In the first version, the digest said "Sensex closed at 81,200" in markets and "81,350" in the summary, because the summary agent searched again later. Sections varied from 60 to 300 words, and dates appeared in three formats.
The fixes: one facts task gathers figures once and every section reads it through context; each section task has the same {style_guide} and a guardrail for "90–130 words, dates as 24 Sep 2026, amounts with ₹"; all writers use one model at temperature 0.2. Reader complaints about contradictions went from about 2 a week to none in a month, and the editor task became optional.
Follow-up questions to expect
- "Would memory help keep facts consistent?" — Not reliably. Memory is retrieval, so it may miss or return an older value. Pass the facts directly.
- "Why not one agent for all sections?" — For five short sections, one agent can be better and cheaper. Split only when sections need different tools or the prompt gets too long.
- "How do you check consistency automatically?" — Compare shared fields in code: every number in the summary must appear in the
factsoutput.