Skip to content

storm: #23 - Duplicate iteration loop logic between processIssue and processIssueInDir#32

Merged
casperpanduro merged 2 commits intomainfrom
storm/issue-23-duplicate-iteration-loop-logic-between-processissu
Mar 16, 2026
Merged

storm: #23 - Duplicate iteration loop logic between processIssue and processIssueInDir#32
casperpanduro merged 2 commits intomainfrom
storm/issue-23-duplicate-iteration-loop-logic-between-processissu

Conversation

@casperpanduro
Copy link
Copy Markdown
Contributor

Closes #23

Summary

Duplicate iteration loop logic between processIssue and processIssueInDir

Problem

src/core/loop.ts contains two nearly identical iteration loops: processIssue (lines 39–111) and processIssueInDir (lines 182–237). Both implement the same core pattern:

  • Load contexts, instructions, workflow
  • Resolve template
  • Spawn agent
  • Accumulate token usage
  • Check timeouts and exit codes
  • Run checks and collect failures
  • Sleep between iterations

The only meaningful differences are (1) processIssue uses log.step while processIssueInDir uses log.issue, and (2) processIssue sets up the branch before the loop. Any bug fix or behavioral change must be applied in two places, and they have already drifted (e.g. processIssueInDir is missing the explicit check-failure log line).

Suggested fix

Extract a shared runIterationLoop function that takes the issue, config, cwd, and a logger variant. Both processIssue and processIssueInDir call this shared function after their own setup steps:

async function runIterationLoop(
  issue: GitHubIssue,
  config: StormConfig,
  cwd: string,
): Promise<{ totalUsage: AgentUsage }> {
  // single implementation of the loop
}

This eliminates the duplication and ensures both paths stay in sync.

Changes

  • src/core/loop.ts

1 file changed, 29 insertions(+), 80 deletions(-)

Considerations

Test Plan


Automatically generated by storm-agent on branch storm/issue-23-duplicate-iteration-loop-logic-between-processissu.

@casperpanduro
Copy link
Copy Markdown
Contributor Author

Storm Agent Summary

Model sonnet
Duration 1m 30s
Total tokens 5,941
Input tokens 8
Output tokens 5,933
Cache read tokens 168,394
Cache creation tokens 36,276

@casperpanduro
Copy link
Copy Markdown
Contributor Author

Storm Continue Summary

Model sonnet
Duration 39s
Total tokens 1,258
Input tokens 5
Output tokens 1,253

@casperpanduro casperpanduro merged commit b7f045a into main Mar 16, 2026
1 check passed
@casperpanduro casperpanduro deleted the storm/issue-23-duplicate-iteration-loop-logic-between-processissu branch March 16, 2026 17:00
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.

Duplicate iteration loop logic between processIssue and processIssueInDir

1 participant