Overview
The Forge module is the main orchestration layer of Dream Foundry. It manages the complete lifecycle of running multiple candidate implementations, scoring them across multiple criteria, and selecting the winner.Core Function
run_forge()
Runs the complete forge loop with all candidates.The goal for candidates to implement. This is the task description that all candidate agents will attempt to solve.Example:
"Generate weekly AI events for Discord"If
True, run candidates in Daytona sandboxes for isolation. Otherwise, runs locally via subprocess.Note: Requires DAYTONA_API_KEY environment variable to be set. Falls back to local execution if Daytona is not configured.Optional callback function for streaming logs during execution.Signature:
callback(candidate_id: str, message: str) -> NoneThis allows real-time monitoring of candidate execution progress.ForgeResult - Complete result object with all scoring data and winner information
Data Classes
ForgeResult
Complete result of a forge run containing all execution data, scores, and winner information.The objective that was executed
ISO timestamp when the forge run completed (e.g.,
"2026-01-28T14:30:00.123456")Execution mode used:
"local" or "daytona"List of all candidate information including their artifacts. Each candidate contains:
id: Candidate identifiername: Human-readable namedescription: Description of approachscript: Path to implementation scriptartifact: Generated output content (if any)
List of score dictionaries for each candidate containing:
candidate_id: Identifiersuccess: Boolean indicating if execution succeededquality_score: Quality score (0-100)speed_score: Speed score (0-100)total_score: Weighted total scorequality_details: Detailed quality validation results
ID of the winning candidate (highest total score)
Total score of the winner
The artifact content produced by the winner, or
None if no artifact was generatedDirectory path where all artifacts are stored
Constants
CANDIDATES
List of all available candidate implementations. Each candidate has a unique approach and tradeoffs.Helper Functions
run_candidate_local()
Runs a single candidate locally via subprocess. This is an internal function used byrun_forge().
Candidate dictionary from CANDIDATES list
The objective to execute
Directory to store output artifacts
Optional logging callback
(produced_output, error_occurred, runtime_seconds, artifact_content, error_message)
This function has a 60-second timeout per candidate. If execution exceeds this, a timeout error is returned.
Scoring Weights
The forge uses weighted scoring across three criteria:- Success (20%): Did the candidate produce output without errors?
- Quality (60%): Does the output meet requirements?
- 10+ events (2 per day Mon-Fri)
- Daytona AI Hackathon must be included
- Valid URLs (lu.ma, meetup, eventbrite)
- AI-related content
- Correct event types (hackathon, meetup, conference)
- Speed (20%): Execution time (faster = better, max 30 seconds)
Artifacts
The forge produces several artifacts in theartifacts/ directory:
scores.json Structure
Error Handling
The forge captures and reports errors comprehensively:- Subprocess errors: Captured via stderr, limited to 500 characters
- Timeouts: 60-second limit per candidate
- Sentry integration: Errors automatically sent to Sentry (if configured)
- Missing output: Detected and scored as failure
Integration with Sentry
Optional Sentry integration for error monitoring:- Set
SENTRY_DSNenvironment variable - Install
sentry-sdk:pip install sentry-sdk - Errors are automatically captured during execution
Sentry is completely optional. The forge works without it, but provides enhanced error tracking when configured.