Skip to content

Comments

fix(parallel): invoke onPatchesGenerated callback in parallel execution#167

Merged
jlevy merged 1 commit intomainfrom
fix/parallel-onpatchesgenerated-callback
Feb 24, 2026
Merged

fix(parallel): invoke onPatchesGenerated callback in parallel execution#167
jlevy merged 1 commit intomainfrom
fix/parallel-onpatchesgenerated-callback

Conversation

@jlevy
Copy link
Owner

@jlevy jlevy commented Feb 24, 2026

Problem

The runMultiTurnForItems function (parallel execution path) was not calling the onPatchesGenerated callback, while the serial path did (line 729).

This prevented consumers from observing patches and stats (including turnStats.prompts) when parallel execution was enabled, breaking features like token composition tracking that depend on prompt data.

Solution

Added the callback invocation after agent response and before applying patches, matching the serial path behavior.

Impact

  • onPatchesGenerated now fires for all execution modes (serial and parallel)
  • turnStats.prompts is now accessible in parallel execution
  • ✅ Enables token breakdown and other observability features

Testing

  • All existing unit tests pass
  • Integration tests pass
  • Verified in ai-trade-arena with token breakdown feature

Related

The callback was introduced for observability but the parallel path was missing the invocation when parallel execution was implemented.

The runMultiTurnForItems function (parallel execution path) was not
calling the onPatchesGenerated callback, while the serial path did.

This prevented consumers from observing patches and stats (including
turnStats.prompts) when parallel execution was enabled, breaking
features like token composition tracking that depend on prompt data.

The fix adds the callback invocation after agent response and before
applying patches, matching the serial path behavior at line 729.

Impact:
- onPatchesGenerated now fires for all execution modes
- turnStats.prompts is now accessible in parallel execution
- Enables token breakdown and other observability features

Related: The callback was introduced for observability but the
parallel path was missing the invocation when parallel execution
was implemented.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Coverage Report for packages/markform

Status Category Percentage Covered / Total
🔵 Lines 66.17% (🎯 64%) 6117 / 9243
🔵 Statements 65.97% (🎯 64%) 6336 / 9604
🔵 Functions 65.58% (🎯 64%) 747 / 1139
🔵 Branches 62.61% (🎯 60%) 4414 / 7049
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/markform/src/harness/programmaticFill.ts 70.85% 69.11% 65.71% 71.34% 102-125, 203, 211-307, 316, 334, 354, 601-602, 657-661, 731-736, 746-747, 914-915, 931-947, 981-1003, 1060-1062, 1071, 1117-1129, 1134-1135, 1188-1193, 1210, 1241-1246, 1261, 1281-1288, 1300
Generated in workflow #1011 for commit 9b25de6 by the Vitest Coverage Report Action

@jlevy jlevy merged commit ef0d7ba into main Feb 24, 2026
1 check passed
@jlevy jlevy deleted the fix/parallel-onpatchesgenerated-callback branch February 24, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant