Skip to content

[FEATURE]: Session loop performance — doom loop in-memory, summary debounce, parallel plugin events #20302

Closed as not planned

Description

@AndresCdo

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Three targeted performance optimizations in the session processing loop:

1. In-memory doom loop detection (session/processor.ts)

Replace MessageV2.parts(ctx.assistantMessage.id) database call with an in-memory toolCallHistory array tracked in ProcessorContext. The doom loop check already has all the data it needs from the streaming event handler — no need to re-query the database on every tool call.

2. Summary debounce (session/processor.ts)

Run SessionSummary.summarize() only on the first step of a session. Subsequent steps produce summaries that overwrite the first one with no additional value, wasting CPU and I/O on redundant summary computation.

3. Parallel plugin event handlers (plugin/index.ts)

Replace sequential for loop with Effect.forEach({ concurrency: "unbounded" }) so slow plugin event handlers don't block the main event stream. Each handler runs in a forked fiber with error isolation via Effect.tryPromise.

Impact

Optimization Before After Improvement
Doom loop check per tool call 1 DB query 0 (in-memory) N queries eliminated
Summary computation per step Every step First step only Eliminates redundant work
Plugin event handlers Sequential Parallel 2-5x faster with multiple plugins

Risk

Minimal — all three changes are surgical and backward compatible:

  • Doom loop: same logic, different data source (in-memory vs DB)
  • Summary: first step behavior unchanged, subsequent steps skip redundant work
  • Plugin handlers: same input, parallel execution with error isolation

Activity

  1. added a commit that references this issue on Mar 31, 2026
    35540b6
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Mar 31, 2026
  3. github-actions commented on Mar 31, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  4. removed
    perfIndicates a performance issue or need for optimization
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions