👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/agents/content_creation_pipeline
Content Creation Pipeline for C# .NET Applications
Purpose of the Sample
Content Creation Pipeline demonstrates how to use LM-Kit.NET to build a sequential multi-agent content workflow using the PipelineOrchestrator where content flows through a series of specialized agents, each refining and improving it.
The sample shows how to:
- Create multiple specialized content agents for different stages.
- Use
PipelineOrchestratorto chain agents sequentially. - Pass output from one stage as input to the next.
- Visualize content evolution through each pipeline stage.
- Access intermediate outputs at every step.
Why Pipeline Orchestration with LM-Kit.NET?
- Structured workflow: content progresses through defined stages.
- Specialization: each agent focuses on one aspect of content creation.
- Quality layers: multiple passes ensure polished output.
- Transparency: see how content evolves at each stage.
- Local-first: entire pipeline runs on your hardware.
Target Audience
- Content Teams: automate blog post, article, and documentation creation.
- Marketing Departments: streamline content production workflows.
- Technical Writers: create structured documentation pipelines.
- Publishers: build editorial review workflows.
- Educators: understand sequential agent chaining patterns.
Problem Solved
- Structured content creation: from topic to polished article in defined stages.
- Separation of concerns: each agent specializes in one task.
- Quality assurance: multiple refinement passes.
- Fact verification: dedicated stage for accuracy checking.
- Workflow automation: repeatable content production process.
Sample Application Description
Console app that:
- Lets you choose from 5 models suitable for content generation.
- Creates four specialized pipeline agents (Outliner, Writer, Editor, Fact-Checker).
- Sets up a PipelineOrchestrator to chain agents sequentially.
- Enters an interactive creation loop where you can:
- Enter a topic or brief.
- Watch content evolve through each stage.
- See intermediate outputs (truncated for display).
- Receive polished final content.
- Displays execution statistics (stages completed, duration).
- Loops until you type
quitto exit.
Key Features
- PipelineOrchestrator: sequential agent chaining.
- Four-Stage Pipeline: Outliner, Writer, Editor, Fact-Checker.
- Content Evolution: see how content transforms at each stage.
- Color-Coded Stages: each stage output in distinct colors.
- Intermediate Access: view output from any pipeline stage.
- Timing Metrics: total pipeline execution duration.
Built-In Models (menu)
On startup, the sample shows a model selection menu:
| Option | Model | Approx. VRAM Needed |
|---|---|---|
| 0 | Google Gemma 3 4B | ~4 GB VRAM |
| 1 | Microsoft Phi-4 Mini 3.8B | ~3.3 GB VRAM |
| 2 | Meta Llama 3.1 8B | ~6 GB VRAM |
| 3 | Alibaba Qwen-3 8B | ~5.6 GB VRAM |
| 4 | Microsoft Phi-4 14.7B | ~11 GB VRAM |
| other | Custom model URI | depends on model |
The same model is used for all pipeline stages. Larger models produce higher quality content.
Pipeline Stages
| Stage | Agent | Input | Output | Role |
|---|---|---|---|---|
| 1 | Outliner | Topic/Brief | Structured outline | Creates logical structure with sections and key points |
| 2 | Writer | Outline | Draft content | Expands outline into full prose (400-600 words) |
| 3 | Editor | Draft | Polished content | Improves grammar, style, flow, and clarity |
| 4 | Fact-Checker | Polished content | Verified content | Adds caveats, qualifiers, and accuracy notes |
Content Flow
Topic/Brief → Outliner → Writer → Editor → Fact-Checker → Final Content
Stage Details
1. Outliner Agent
- Analyzes the topic
- Creates structured outline with:
- Compelling title
- Introduction section
- 3-5 main sections with headings
- Key points for each section
- Conclusion section
2. Writer Agent
- Takes the outline
- Expands into engaging prose
- Maintains logical flow
- Includes relevant examples
- Targets 400-600 words
3. Editor Agent
- Fixes grammar and spelling
- Improves sentence structure
- Enhances flow and transitions
- Removes redundancy
- Polishes word choice
4. Fact-Checker Agent
- Identifies claims needing verification
- Adds appropriate qualifiers
- Flags potentially outdated information
- Ensures balanced presentation
- Adds notes for important caveats
Example Topics
Try the sample with:
Technical content:
- "Write a blog post about the benefits of TypeScript for large-scale applications"
- "Create an article explaining how blockchain technology works for beginners"
Business content:
- "Write a guide on best practices for remote team management"
- "Create content about effective communication strategies for distributed teams"
Lifestyle content:
- "Create content about sustainable living tips for apartment dwellers"
- "Write an article on productivity techniques for work-from-home professionals"
Agent Configuration
using LMKit.Agents;
using LMKit.Agents.Orchestration;
using LMKit.Model;
// Load model (shared by all pipeline stages)
LM model = new LM(new Uri(modelUri));
// Create pipeline agents
var outlinerAgent = Agent.CreateBuilder(model)
.WithPersona(@"Outliner - Expert Content Outliner.
Create well-structured outlines including:
- A compelling title
- An introduction section
- 3-5 main sections with clear headings
- Key points under each section
- A conclusion section")
.WithPlanning(PlanningStrategy.None)
.Build();
var writerAgent = Agent.CreateBuilder(model)
.WithPersona(@"Writer - Professional Content Writer.
Expand outlines into engaging prose:
- Clear, accessible style
- Smooth transitions between sections
- Relevant examples where appropriate
- Consistent tone throughout
- 400-600 words total")
.WithPlanning(PlanningStrategy.None)
.Build();
var editorAgent = Agent.CreateBuilder(model)
.WithPersona(@"Editor - Meticulous Editor.
Refine and polish content:
- Grammar and spelling corrections
- Improved sentence structure
- Enhanced flow and transitions
- Removed redundancy
- Better word choice for clarity")
.WithPlanning(PlanningStrategy.None)
.Build();
var factCheckerAgent = Agent.CreateBuilder(model)
.WithPersona(@"FactChecker - Fact-Checker and Quality Reviewer.
Review content for accuracy:
- Identify claims needing verification
- Add appropriate qualifiers
- Flag potentially outdated information
- Ensure balanced presentation
- Add notes for important caveats")
.WithPlanning(PlanningStrategy.None)
.Build();
// Create pipeline orchestrator
var pipeline = new PipelineOrchestrator()
.AddStage("Outliner", outlinerAgent)
.AddStage("Writer", writerAgent)
.AddStage("Editor", editorAgent)
.AddStage("FactChecker", factCheckerAgent);
// Execute pipeline
var result = await pipeline.ExecuteAsync(
$"Create content about: {topic}",
cancellationToken);
// Access stage results
foreach (var stageResult in result.AgentResults)
{
Console.WriteLine($"Stage output: {stageResult.Content}");
}
// Final content
Console.WriteLine($"Final: {result.Content}");
Console.WriteLine($"Duration: {result.Duration.TotalSeconds:F1}s");
Architecture
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Outliner │ ──▶ │ Writer │ ──▶ │ Editor │ ──▶ │Fact-Checker │
│ Agent │ │ Agent │ │ Agent │ │ Agent │
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
│ │ │ │
▼ ▼ ▼ ▼
Outline Draft Text Polished Text Final Content
Understanding the Output
The demo displays content evolution through each stage:
| Color | Stage | Content Type |
|---|---|---|
| Yellow | Outliner | Structured outline with sections and key points |
| Green | Writer | Draft prose expanded from outline |
| Magenta | Editor | Polished content with improved style |
| Cyan | Fact-Checker | Verified content with caveats and notes |
| White | Final Content | Complete, production-ready content |
| Dark Gray | Statistics | Stages completed, success count, duration |
Output Format
┌─── Stage 1: OUTLINER ────────────────────────────────────────
[Outline with title, sections, key points...]
└─────────────────────────────────────────────────────────────────
┌─── Stage 2: WRITER ──────────────────────────────────────────
[Draft prose, may be truncated for display...]
└─────────────────────────────────────────────────────────────────
┌─── Stage 3: EDITOR ──────────────────────────────────────────
[Polished content, may be truncated for display...]
└─────────────────────────────────────────────────────────────────
┌─── Stage 4: FACT-CHECKER ────────────────────────────────────
[Final verified content with notes...]
└─────────────────────────────────────────────────────────────────
╔═══════════════════════════════════════════════════════════════╗
║ FINAL CONTENT ║
╚═══════════════════════════════════════════════════════════════╝
[Complete content ready for use]
Behavior & Policies
- Model sharing: same model used for all four pipeline stages.
- Sequential execution: each stage waits for the previous to complete.
- Output chaining: each stage receives the previous stage's output.
- Intermediate truncation: display truncates long intermediate outputs.
- Full final output: final content is displayed in full.
- Timeout: 10-minute timeout per pipeline execution.
- Licensing: set an optional license key via
LicenseManager.SetLicenseKey("").
Getting Started
Prerequisites
- .NET 8.0 or later
- Sufficient VRAM for the selected model (4-11 GB depending on model choice)
Download
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/agents/content_creation_pipeline
Run
dotnet build
dotnet run
Then:
- Select a model by typing 0-4, or paste a custom model URI.
- Wait for the model to download (first run) and load.
- Enter a topic or brief for content creation.
- Watch content evolve through each stage.
- Receive polished final content.
- Type
quitto exit.
Troubleshooting
Low-quality content
- Use a larger model for better writing.
- Provide more detailed topic briefs.
Outline too sparse
- Topic may need more context.
- Try more specific or detailed briefs.
Content too short
- Writer agent targets 400-600 words.
- Adjust persona for longer content if needed.
Slow pipeline
- Four sequential stages mean four inference calls.
- Use a smaller or faster model.
- Consider reducing stages for simpler workflows.
Out-of-memory errors
- Single model is shared, so VRAM usage is manageable.
- Pick a smaller model if needed.
Stage failures
- Check
StageResult.IsSuccessfor each stage. - Failed stages may produce empty or error content.
- Check
Extend the Demo
- Add/remove stages: customize pipeline for different content types.
- Parallel branches: split pipeline for A/B content variations.
- Custom personas: create specialized pipelines (technical docs, marketing, social media).
- Format conversion: add stages for Markdown, HTML, or other formats.
- SEO optimization: add stage for keyword integration.
- Translation: add stage for multi-language content.
- Quality scoring: implement automated quality metrics.
- Conditional stages: skip stages based on content characteristics.
Pipeline Variations
Documentation Pipeline
Technical Brief → Outliner → Writer → Technical Editor → API Validator
Marketing Pipeline
Product Brief → Outliner → Copywriter → Brand Reviewer → SEO Optimizer
Social Media Pipeline
Topic → Content Strategist → Writer → Tone Adjuster → Platform Formatter