Skip to content

fix(assistant): reuse a repeated read in one turn - #250

Merged
omznc merged 3 commits into
mainfrom
fix/assistant-repeat-reads
Nov 11, 2026
Merged

omznc merged 3 commits into
mainfrom
fix/assistant-repeat-reads

Conversation

@omznc

@omznc omznc commented Nov 11, 2026

Copy link
Copy Markdown
Member

Problem

A model can ask for the same read two times in one turn, for example the same time report with the same range. The server ran both calls, and the trace showed two identical rows.

Change

  • Keep the result of each read for the turn, keyed by tool name and arguments (runOrReuse in assistant.service.ts).
  • A repeat gets that result and sends no tool_start or tool_result event, so the web and mobile traces show one row.
  • Each call still gets its own tool row, so the model has an answer for every call.
  • A write clears the kept results. A failed read is not kept, so the model can retry it.
  • Two identical calls in one parallel batch share one run.

Test

  • New test in assistant.test.ts: the same read twice in a batch and once in the next step gives one trace step and three equal tool rows.
  • bun test (assistant), tsc, bun run check and bun run complexity pass.

A model can ask for the same read two times in one turn, for example
the same time report with the same range. The server ran both calls,
and the trace showed two identical rows.

Keep the result of each read for the turn, by tool name and
arguments. A repeat gets that result and sends no trace events. Each
call still gets its own tool row, so the model has an answer for
every call. A write clears the kept results, and a failed read is
not kept.
get_timer returns the elapsed time, which moves with the clock, so a
repeat in the same turn must run again. The .then that forgets a
failed read also needs a rejection handler, or a rejected read
becomes an unhandled rejection.

Add a test that a write between two equal reads runs the second read
again.
@omznc
omznc marked this pull request as ready for review November 11, 2026 23:21
@omznc
omznc requested a review from a team as a code owner November 11, 2026 23:21
@omznc
omznc merged commit acaed35 into main Nov 11, 2026
7 checks passed
@omznc
omznc deleted the fix/assistant-repeat-reads branch November 11, 2026 23:21
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