Skip to content

perf(agent): stop accumulating generator-tool preliminaryResults - #110

Open
LukasParke wants to merge 1 commit into
mainfrom
lukeparke/dev-817-drop-preliminary-results
Open

perf(agent): stop accumulating generator-tool preliminaryResults#110
LukasParke wants to merge 1 commit into
mainfrom
lukeparke/dev-817-drop-preliminary-results

Conversation

@LukasParke

@LukasParke LukasParke commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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 terminal tool.result event no longer carries the full history.

This is the remaining isolate-memory landmine from the @openrouter/agent 0.9.0 review. PR #109 already covers opt-in replay compaction. This PR covers executor / ModelResult accumulation.

What

  • executeGeneratorTool no longer pushes validated yields into preliminaryResults.
  • ModelResult no longer accumulates preliminaryResultsForCall or attaches it to the terminal result event.
  • toolResultsToMap / summarizeToolExecutions stop forwarding the unused array.
  • Public types keep the optional field for compatibility; the runtime no longer populates it.

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 (initialResponse cache + getInitialResponse()).

Test plan

  • pnpm lint / pnpm typecheck in packages/agent
  • pnpm test in packages/agent: 96 files, 1153 tests

Open in Devin Review

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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines +1 to +5
---
'@openrouter/agent': patch
---

Stop accumulating generator-tool `preliminaryResults` arrays. Yields are still broadcast live; the terminal `tool.result` event no longer copies every yield.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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