AI Agents¶
All agents follow the agent pattern and use prompts stored in the database.
Agent Overview¶
| Agent | Model | Purpose |
|---|---|---|
| Brief Generator | Sonnet | Structures article outlines from backlog items, injects trusted sources |
| Researcher | Sonnet | Gathers evidence via PubMed, web search, vault notes |
| Writer | Sonnet | Produces full article drafts |
| Factuality Checker | Haiku | Validates medical claim accuracy |
| SEO Optimizer | Haiku | Checks keyword usage, heading structure, snippets |
| Style Checker | Haiku | Evaluates readability and tone |
| Synthesis | Haiku | Reconciles quality gate feedback into rewrite instructions |
| Triage | Haiku | Classifies research news relevance |
| Digest Writer | Sonnet | Summarizes weekly research findings |
| Readability | Haiku | Scores readability metrics (Flesch, sentence length) |
| Image Generator | Haiku | Composes DALL-E prompts from article context, generates featured images |
| Cornerstone Updater | Sonnet | Integrates new content into cornerstone articles |
Model Selection¶
- Sonnet is used for tasks that require creative writing or complex reasoning (research, drafting, cornerstone updates)
- Haiku is used for classification, scoring, and structured evaluation tasks (quality gates, triage, synthesis)
All prompts are versioned in the database and managed via Alembic data migrations. See Manage Prompts for details.
Language Support
The Factuality Checker supports both English and German content with language-specific prompts (v3) for improved cultural and linguistic accuracy.
Trusted Sources
The Brief Generator queries the trusted_sources table for active sources filtered by article language and injects them as a <trusted_sources> XML block in the user message. This seeds key_sources_to_consult with authoritative sources (Cochrane, NICE, ATA, etc.) without restricting the researcher's search freedom. Sources with language="both" (scientific) are included for all articles; language-specific sources (medical journalism) are filtered by the backlog item's language.
Agent Modules¶
Each agent is defined in src/agents/ with a corresponding module:
src/agents/
base.py # call_agent() -- shared invocation logic
schemas.py # Pydantic models for all agent I/O
brief_generator.py # generate_brief()
researcher.py # research_topic()
writer.py # write_article()
factuality_checker.py # check_factuality()
seo_optimizer.py # optimize_seo()
style_checker.py # check_style()
synthesis.py # synthesize_feedback()
triage.py # triage_item()
digest_writer.py # write_digest()
cornerstone_updater.py # update_cornerstone()
readability.py # check_readability()
image_generator.py # generate_featured_image()
cost_tracker.py # Token usage tracking