Skip to content

Low memory verification batch size (VERIFY_BATCH_SIZE = 5) causes excessive subagent roundtrips and slow runs #814

Open

Description

@izhangzhihao

Short description

Low memory verification batch size (VERIFY_BATCH_SIZE = 5) causes excessive subagent roundtrips and slow runs

What happened?

### Describe the Bug
In `@cortexkit/pi-magic-context` (`src/features/magic-context/memory/verify.ts` / `dist/index.js`), the batch size for memory verification is hardcoded to `5`:

```javascript
var VERIFY_BATCH_SIZE = 5;

// ...
for (let i = 0; i < group.length; i += VERIFY_BATCH_SIZE) {
  batches.push(group.slice(i, i + VERIFY_BATCH_SIZE));
}

Diagnostics

### Impact & Evidence
When a project accumulates dozens or hundreds of memories requiring periodic verification:
1. Slicing candidates into batches of only 5 creates an unnecessarily high number of subagent invocations / LLM verification rounds.
2. The verification lifecycle takes disproportionately long (often 2x–3x the necessary runtime), consuming excessive turn latency and subagent coordination overhead.

In practice, modern models with structured output capabilities easily handle verifying 10–20 memories in a single prompt without quality degradation. Raising the batch size (e.g., to 10 or 15) cuts the number of verification rounds and total dreamer verification wall-clock time in half.

### Suggested Fix
Increase the default `VERIFY_BATCH_SIZE` to `10` (or make it configurable via user settings).

Plugin version

0.49.28

OpenCode version

No response

Platform

No response

Client

Pi

Log output (optional)

Activity

  1. magic-alfonso commented on Oct 29, 2026

    @magic-alfonso

    Thanks. This one was also part of #783, and we kept it then for a measured reason.

    Verify's cost is mostly the tool calls it makes per memory, such as reading and searching the files a memory points to, not the per-batch prompt. A batch of 10 makes roughly the same file reads as two batches of 5, but in one child session with one time slice. When we measured verify, batches were already running into that slice at size 5. A timed-out batch loses every verdict in it, so a larger batch makes losing work more likely without cutting much total time. That's why 5 is set against the per-batch timeout rather than against model capacity.

    If verify is slow on your project, real numbers would help us see where the time goes. Please share the verify lines from ~/.local/share/cortexkit/magic-context/logs/ for one run (duration, number of batches, any timeouts) and roughly how many memories the project has. If batches finish well inside their slice, there may be room to tune. If they time out, a smaller unit or the split-on-timeout approach from #809 is the better fix.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions