Self-Improving Agentic Systems Using DSPy for Production Email Generation

relevance_ai · Tech · 2025 · source Agentic: yes · promotional bias: high · summary-only (no fetched source) · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: outbound sales email generation

Relevance AI wanted production email-generation agents that improve from real feedback instead of relying on static manually tuned prompts.

Constraints:

Architecture

The described system integrates DSPy optimization with a human-in-the-loop approval workflow: agents draft outbound sales emails after CRM data gathering and prospect research, pause for human approval at critical checkpoints, store approved or corrected outputs as training data, optimize DSPy programs with the accumulated examples, cache optimized programs, and use them for future inference.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  A["CRM and prospect research context"] --> B["Email generation agent"]
  B --> C["Human approval checkpoint"]
  C --> D["Training example collector"]
  D --> E["DSPy optimization pipeline"]
  E --> F["Cached DSPy programs"]
  F --> B
  E --> G["Evaluation framework"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
CRM and prospect research context Inputs used to personalize outbound sales emails. Email generation agent
Email generation agent Drafts outbound emails using optimized DSPy programs. CRM and prospect research context, Human approval checkpoint, Cached DSPy programs
Human approval checkpoint Reviews, approves, or corrects email output before delivery. Email generation agent, Training example collector
Training example collector Stores approved/corrected examples for optimization. Human approval checkpoint, DSPy optimization pipeline
DSPy optimization pipeline Uses optimizers such as BootstrapFewShot, random search, and MIPROv2 to improve programs. Training example collector, Cached DSPy programs, Evaluation framework
Cached DSPy programs Reusable optimized programs used at inference time. DSPy optimization pipeline, Email generation agent
Evaluation framework Compares DSPy agents to non-DSPy controls with semanticF1 and human-quality claims. DSPy optimization pipeline

Data flow

CRM and prospect-research context enters the email-generation agent; the agent drafts an email; an approval checkpoint lets a human approve or correct the output; the feedback is stored as training data by Prompt Optimizer tooling; DSPy optimizers select examples and/or prompt instructions; optimized programs are cached in the knowledge base; future email generations use the cached program at inference time.

3 supporting quotes
“The system operates at a specific integration point in the workflow—after CRM data gathering and prospect research but before email delivery”summary, stated
“When the agent executes its assigned task, the system pauses at key checkpoints for human approval.”summary, stated
“The optimized programs are automatically cached in the knowledge base under "_dspy_programs" for efficient reuse.”summary, stated

Why this architecture

The architecture turns required human approval from a pure bottleneck into a learning signal: approved and corrected outputs become training examples, DSPy optimizes programs offline, and cached optimized programs keep inference fast.

3 supporting quotes
“The feedback mechanism is positioned as central to the self-improvement capability”summary, stated
“feedback flowing directly into the DSPy training set to create what they describe as a dynamic learning environment”summary, stated
“During inference, the system leverages cached optimized programs to run inference steps with minimal computational overhead.”summary, stated

Models used: DSPy-optimized LLM programs · LLM-based semanticF1 evaluator

Scale

Alternatives considered (roads not taken)

Manual prompt tuning

Rejected because: The case study frames DSPy optimization as reducing production agent build time by eliminating manual prompt tuning.

“while reducing agent development time by 50% through elimination of manual prompt tuning.”summary, stated

Static agent prompts without feedback

Rejected because: The system uses human-approved examples as a continuous training signal for future optimization.

“The system demonstrates continuous improvement through automated collection of human-approved examples”summary, stated

One optimizer for all data sizes

Rejected because: The summary describes different DSPy optimizers for fewer than 20, around 50, and 200+ samples.

“the system leverages three DSPy optimizers matched to different data scales.”summary, stated

Patterns

human-in-the-loop-gate (quality-control)

Humans approve or correct generated emails at checkpoints, and those corrections become training examples.

“The implementation uses an "Approval Required" setting for output tools in agent settings, enabling human oversight and refinement of outputs that creates a learning loop for the agent.”summary, stated

eval-driven-development (optimization)

DSPy optimization and semanticF1 comparisons guide program improvement against control agents.

“conducting parallel tests between DSPy-powered agents and control agents (non-DSPy variants) using identical inputs, tools, and workflows.”summary, stated

Tradeoffs

Use DSPy optimization.

Chose learned prompts/programs from approved examples over manual prompt tuning.

Rationale: Optimization reduced build time and improved the system through real feedback.

“The integration of DSPy represents an attempt to move beyond manual prompt engineering toward more systematic optimization, which aligns with broader industry trends toward treating prompts as learnable components rather than manually crafted artifacts.”summary, stated

Keep human approval in the loop.

Chose approval checkpoints before email delivery over fully autonomous email sending.

Rationale: Human oversight preserves quality and creates the training signal for improvement.

“The reliance on human approval at critical checkpoints represents both a strength and a limitation. It ensures quality control and provides the training signal for improvement, but also means the system isn't fully autonomous and requires ongoing human involvement.”summary, stated

Gotchas (what bit them)

Training data quality dominates the optimization pipeline.

Root cause: Bad or inconsistent approved examples propagate into DSPy programs.

Resolution: Invest in refined gold sets and human approval quality before relying on optimization.

“training data quality represents the most critical component, directly impacting the entire pipeline's performance.”summary, stated

The reported performance metrics lack full methodology detail.

Root cause: The summary notes ambiguity around how matching or exceeding human quality was operationalized.

Resolution: Treat the performance claims as promotional and require clearer evaluation documentation before copying the metric design.

“lack detailed methodology explanation.”summary, stated

Human approval can become a throughput bottleneck.

Root cause: The self-improvement loop depends on ongoing human review and correction quality.

Resolution: Use approval checkpoints for quality-sensitive outputs while monitoring review volume and consistency.

“It ensures quality control and provides the training signal for improvement, but also means the system isn't fully autonomous”summary, stated

Evaluation

The system reportedly compared DSPy agents to non-DSPy control agents using identical workflows and semanticF1, while also reporting human-quality match/exceed rates.

Metrics: semanticF1 · human-written quality match rate · human performance exceed rate · agent development time reduction · response time

“At the core of the evaluation process is the semanticF1 score—a metric that uses LLMs to measure semantic precision and recall of responses, combining them into a comprehensive performance indicator.”summary, stated
“However, it's worth noting that the claimed performance metrics of "80% matching human-written quality" and "6% exceeding human performance" lack detailed methodology explanation.”summary, stated

Outcomes

The source is unavailable, so these outcomes are summary-backed and should be discounted relative to source-backed cases.

“The company claims their DSPy-powered systems generated emails matching human-written quality 80% of the time, with 6% of cases exceeding human performance, while cutting production agent building time by 50%.”summary, stated
“The company claims their DSPy-powered systems generated emails matching human-written quality 80% of the time, with 6% of cases exceeding human performance, while cutting production agent building time by 50%.”summary, stated