Parallel code-only agents spike

t-369.19·WorkTask·
·
·
·Omni/Agent.hs
Parent:t-369·Created1 month ago·Updated1 month ago

Dependencies

Description

Edit

Test parallel execution of code-only agents without shared state.

Context

The code-only spike showed single-agent success. Now test if we can run multiple agents in parallel on subtasks.

This is the "embarrassingly parallel" case - no coordination, just partition and merge.

Hypothesis

Parallel code-only agents can: 1. Reduce wall-clock time proportionally 2. Handle partitioned tasks correctly 3. Merge results coherently

Experiment Design

Task: Batch Computation

-- Task that naturally partitions
batchTask :: [Text] -> IO [Text]
batchTask inputs = do
  -- Sequential baseline
  t1 <- timed $ traverse codeOnlyAgent inputs
  
  -- Parallel (no communication)
  t2 <- timed $ mapConcurrently codeOnlyAgent inputs
  
  -- Compare times
  ...

Task: Research with Merge

-- Each agent researches independently, merge at end
parallelResearch :: [Topic] -> IO Summary
parallelResearch topics = do
  -- Spawn one agent per topic
  results <- mapConcurrently researchTopic topics
  
  -- Merge (no shared state during execution)
  mergeResults results

researchTopic :: Topic -> IO TopicResult
researchTopic topic = codeOnlyAgent ("Research: " <> topic)

Task: Map-Reduce Style

-- Map phase: parallel
-- Reduce phase: single agent synthesizes
mapReduce :: Text -> [Text] -> IO Text
mapReduce question documents = do
  -- Map: extract relevant info from each doc
  extracts <- mapConcurrently (\doc -> 
    codeOnlyAgent ("Extract info about '" <> question <> "' from: " <> doc)) documents
  
  -- Reduce: synthesize
  codeOnlyAgent ("Synthesize these extracts: " <> show extracts)

Deliverables

1. Parallel execution wrapper

-- Omni/Agent/Experiments/ParallelCodeOnly.hs

parallelCodeOnly :: Int -> [Text] -> IO [RunResult]
parallelCodeOnly concurrency tasks = do
  -- Use async with concurrency limit
  sem <- newQSem concurrency
  mapConcurrently (withSem sem . codeOnlyAgent defaultConfig) tasks

withSem :: QSem -> IO a -> IO a
withSem sem = bracket_ (waitQSem sem) (signalQSem sem)

2. Benchmark suite

data ParallelBenchmark = ParallelBenchmark
  { pbName :: Text
  , pbTasks :: [Text]
  , pbExpectedSpeedup :: Double  -- e.g., 5x for 5 tasks on 5 cores
  }

runParallelBenchmarks :: IO ()
runParallelBenchmarks = do
  -- Batch: 10 independent tasks
  runBenchmark "batch" batchTasks 1    -- sequential
  runBenchmark "batch" batchTasks 5    -- parallel
  runBenchmark "batch" batchTasks 10   -- fully parallel
  
  -- Research: 5 topics
  runBenchmark "research" researchTasks 1
  runBenchmark "research" researchTasks 5

3. Metrics

  • Wall clock time (sequential vs parallel)
  • Total cost (should be same)
  • Success rate (should be same)
  • Speedup factor (actual vs theoretical)

Expected Results

| Metric | Sequential | Parallel (5x) | |--------|------------|---------------| | Wall time | 30s | ~6s | | Total cost | $0.00015 | $0.00015 | | Success rate | 100% | 100% |

What We Learn

1. Parallelism works - Agents don't interfere 2. Scaling characteristics - Linear? Sublinear? 3. Failure modes - Do parallel failures cascade? 4. Cost characteristics - Any overhead?

Testing

  • [ ] Parallel execution produces same results as sequential
  • [ ] Wall time scales with concurrency
  • [ ] No race conditions or interference
  • [ ] Proper error handling for partial failures

Files

  • Omni/Agent/Experiments/ParallelCodeOnly.hs (new)

Timeline (2)

🔄[human]Open → InProgress1 month ago
🔄[human]InProgress → Done1 month ago