Overview
Magpie provides several debugging tools to help you understand what’s happening during pipeline execution, diagnose issues, and trace agent behavior.The —trace Flag
The--trace flag is your primary debugging tool. It enables detailed tracing of agent calls with real-time output and JSONL logs.
Enabling Trace Mode
What —trace Does
When--trace is enabled:
- Real-time stderr output — See what the agent is doing as it happens
- JSONL trace files — Detailed logs written to
.magpie/traces/magpie-trace-YYYY-MM-DD.jsonl - Event classification — Each agent event is categorized (CALL, TEXT, TOOL_REQ, DONE)
Stderr Output Format
When tracing is enabled, you’ll see real-time output like:Event Types
| Event | Description |
|---|---|
CALL: | Agent call started with this prompt |
TEXT: | Agent generated text output |
TOOL_REQ: | Agent requested a tool call (file edit, shell command) |
TOOL_RESP: | Tool execution result |
DONE: | Agent call completed (duration, tool count) |
JSONL Trace Files
Location
Trace files are written to:Trace File Structure
Analyzing Trace Files
You can analyze trace files using command-line tools:Verbose Mode Details
Setting Verbose Mode Programmatically
Fromcrates/magpie-cli/src/main.rs:11:
How Trace Verbose Works
The verbose flag is stored in an atomic boolean:TraceBuilder API
TheTraceBuilder is used internally to record agent calls. Understanding it helps when debugging or extending Magpie.
Creating a Trace
Fromcrates/magpie-core/src/trace.rs:
Event Kinds
Writing Traces to Disk
Error Handling Patterns
Understanding Magpie’s error handling helps with debugging.Using anyhow for Error Context
Fromcrates/magpie-core/src/pipeline.rs:1330:
Error Context Chain
Errors in Magpie use context chaining to provide detailed error messages:Common Error Patterns
Debugging Common Issues
Pipeline Fails During Setup
Symptoms: Pipeline fails before agent runs Debug steps:-
Check environment variables:
-
Verify git configuration:
-
Check branch exists:
Agent Call Hangs
Symptoms: Agent call never completes Debug steps:-
Run with
--traceto see where it’s stuck: -
Check if
claudeCLI is responsive: - Look for infinite loops in tool calls in trace output
CI Loop Keeps Failing
Symptoms: Pipeline succeeds but CI never passes Debug steps:-
Run CI commands manually:
-
Check error output in trace files:
- Look for flaky tests or environment-specific issues
Sandbox Commands Fail
Symptoms: Commands work locally but fail in sandbox Debug steps:-
Check sandbox working directory:
-
Verify files exist in sandbox:
-
Check sandbox environment variables (Daytona):
Logging with tracing
Magpie uses thetracing crate for structured logging.
Log Levels
Setting Log Level
Log Output
WithRUST_LOG=debug, you’ll see detailed logs:
Performance Debugging
Trace File Analysis
Find slow steps:Tool Call Analysis
Find steps with many tool calls:Debugging in Tests
When writing tests, you can enable debug output:Debugging Daytona Sandboxes
When using Daytona sandboxes:Summary
Key debugging tools:--traceflag for real-time output and JSONL logs- JSONL trace files in
.magpie/traces/ RUST_LOGenvironment variable for log levels- Error context chains with
anyhow MockSandboxfor isolated testing
- Run with
--traceto see what’s happening - Check trace files for patterns or errors
- Verify environment variables and configuration
- Run commands manually to isolate issues
- Check logs with
RUST_LOG=debug - Test error cases with
MockSandbox