Overview
The pipeline module orchestrates the full Magpie workflow: task classification → blueprint execution → CI loops → PR creation. It’s the main entry point for running autonomous coding tasks.Core Function
run_pipeline()
Runs the complete Magpie pipeline from task to PR.
Chat platform adapter (Discord, Teams, CLI) for sending progress updates
Channel/thread ID where the task originated
User who requested the task
Natural language task description (e.g. “add OAuth2 login”)
Pipeline configuration (repo, commands, CI rounds, etc.)
Returns the pipeline outcome including PR URL, CI status, and agent output
- Fetch conversation history from chat platform
- Create sandbox (Daytona remote or local)
- Clone repo (if
github_orgis configured) - Generate branch name via Tier 1 LLM
- Create git branch
- Classify task complexity (Simple/Standard/BugFix)
- Execute appropriate blueprint
- Run CI loop (lint + test) with fix retries
- Generate commit message via LLM
- Commit, push, create PR via
gh - Update Plane issue (if configured)
- Cleanup sandbox
Configuration Types
PipelineConfig
Configuration for a pipeline run.
Local repository directory (used when
github_org is not set)Base branch for PRs (e.g. “main”, “develop”)
Test command for CI validation
Lint command for CI validation
Maximum CI retry attempts if tests fail
Plane.so integration config for issue tracking
When true, agent steps are replaced with shell echo stubs
GitHub org to restrict repo access. When set, parses repo from task message and clones it
Directory for JSONL trace files. When set, all agent calls are traced
Daytona sandbox config. When set, runs commands remotely in Daytona
Warm sandbox pool (feature-gated). Enables pre-built sandbox reuse
PipelineResult
Outcome of a pipeline run.
Final agent output (typically success message or error details)
GitHub PR URL if successfully created
Plane issue ID if integration is configured
Whether lint + test commands passed
Number of CI rounds executed (1 = first attempt, 2+ = retries)
High-level outcome classification
PipelineStatus
High-level pipeline outcome.
Task Classification
classify_task()
Classifies a task as Simple, Standard, or BugFix to determine which blueprint to execute.
Task description to classify
When true, ambiguous tasks default to Simple without calling Claude
Directory for trace logging
Simple: Docs, typos, renames (single-shot agent call)Standard: Features, refactors (TDD blueprint)BugFix: Bug fixes (diagnostic blueprint with investigation step)
- Keyword matching for clear-cut cases:
- Simple: “fix typo”, “update readme”, “fix docs”
- BugFix: “fix bug”, “fix crash”, “investigate”, “broken”
- Standard: “add”, “implement”, “refactor”, “integrate”
- Claude classification for ambiguous tasks (Tier 1 call)
- Default to Simple in dry_run mode
Blueprint Builders
build_main_blueprint()
Builds the Simple blueprint: validate → agent.
build_tdd_blueprint()
Builds the TDD blueprint: scan → plan → write-tests → verify-fail → implement → test → lint.
- scan-repo: Get file tree for context
- plan: Agent creates implementation plan
- write-tests: Agent writes tests ONLY (no implementation)
- verify-tests-fail: Run tests, expect failure (TDD red phase)
- implement: Agent writes implementation to make tests pass
- run-tests: Run tests, expect success (TDD green phase)
- lint-check: Run linter
build_diagnostic_blueprint()
Builds the Diagnostic blueprint: scan → investigate → plan → write-regression-test → verify-fail → fix → test → lint.
- scan-repo: Get file tree
- investigate: Agent traces root cause WITHOUT modifying files
- plan: Agent creates targeted fix plan based on investigation
- write-regression-test: Agent writes test that reproduces the bug
- verify-test-fails: Run test, expect failure
- implement-fix: Agent fixes the root cause
- run-tests: Run all tests, expect success
- lint-check: Run linter
build_fix_blueprint()
Builds a Fix blueprint for CI retry rounds.
Helper Functions
ensure_multi_word_slug()
Ensures a branch slug has at least two hyphen-separated words.
- If task starts with a verb (“add”, “fix”), prepend it:
"fix" + "pipeline"→"fix-pipeline" - Otherwise fall back to
slugify(task)for a natural multi-word slug