perf(agent): stop accumulating generator-tool preliminaryResults - #110
perf(agent): stop accumulating generator-tool preliminaryResults#110LukasParke wants to merge 1 commit into
Conversation
Yields are still broadcast live. The executor and ModelResult no longer copy every yield into a per-call array or onto the terminal tool.result event. Fixes DEV-817.
| --- | ||
| '@openrouter/agent': patch | ||
| --- | ||
|
|
||
| Stop accumulating generator-tool `preliminaryResults` arrays. Yields are still broadcast live; the terminal `tool.result` event no longer copies every yield. |
There was a problem hiding this comment.
🟡 Release note marks a consumer-visible data removal as a bug-fix-level change
The release note for this change is labelled as a bug-fix-level bump ('@openrouter/agent': patch at .changeset/drop-preliminary-results.md:2) even though the completed-tool event and generator execution result stop carrying the list of intermediate updates entirely, so anyone reading that list now silently gets nothing.
Impact: Consumers upgrading on what looks like a safe fix-level release can lose data they depend on without any warning in the changelog.
Why this conflicts with the repository's changeset bump guidance
.agents/skills/changeset-versioning/SKILL.md defines bump types: patch for "Bug fixes, type fixes, defensive coding improvements", major for "Breaking API changes". The runtime no longer populates ToolExecutionResult.preliminaryResults (packages/agent/src/lib/tool-executor.ts:383-388) nor preliminaryResults on the tool.result / tool_result events (packages/agent/src/lib/model-result.ts:970-991), while the public types at packages/agent/src/lib/tool-types.ts:1214 and packages/agent/src/lib/tool-types.ts:1368-1369 still advertise the field as available. Existing consumers reading these fields compile fine but observe undefined at runtime — a behavioral breaking change on the public event surface, not a patch-level fix.
Was this helpful? React with 👍 or 👎 to provide feedback.
Fixes DEV-817.
Stop copying every generator-tool yield into a per-call array that lives until the call settles. Yields are still broadcast live via
onPreliminaryResult; the terminaltool.resultevent no longer carries the full history.This is the remaining isolate-memory landmine from the
@openrouter/agent0.9.0 review. PR #109 already covers opt-in replay compaction. This PR covers executor /ModelResultaccumulation.What
executeGeneratorToolno longer pushes validated yields intopreliminaryResults.ModelResultno longer accumulatespreliminaryResultsForCallor attaches it to the terminal result event.toolResultsToMap/summarizeToolExecutionsstop forwarding the unused array.Why
Fusion-style generator tools stream for minutes inside a 128MB Worker isolate. Broadcasting live is enough; retaining every yield until settle is O(total streamed bytes) and is the same failure mode the openrouter-web bun patch exists to stop.
The
getUsage()/getToolCalls()trim-unaware replay half of DEV-817 is already handled by PR #109 (initialResponsecache +getInitialResponse()).Test plan
pnpm lint/pnpm typecheckinpackages/agentpnpm testinpackages/agent: 96 files, 1153 tests