Skip to content

fix: preserve newest fusion context under byte budget#3

Merged
leblancfg merged 1 commit into
mainfrom
vi/preserve-recent-fusion-context
Jun 26, 2026
Merged

fix: preserve newest fusion context under byte budget#3
leblancfg merged 1 commit into
mainfrom
vi/preserve-recent-fusion-context

Conversation

@leblancfg

Copy link
Copy Markdown
Owner

Problem

collectRecentConversation walks entries from newest to oldest, but it used to join the accumulated context and then truncate from the start when the byte budget was exceeded. If an older message pushed the joined string over budget, the truncation could remove the newest user/assistant exchange before the worker prompts were built.

That is backwards for fusion planning: workers need the latest turn more than stale context.

Change

  • Track the byte budget while collecting conversation chunks.
  • Stop adding older chunks once the next one would exceed the budget.
  • Keep the existing truncation behavior only for the single-message case where the newest chunk is itself too large.
  • Add a regression test that verifies the newest assistant message survives a small context budget.

Verification

  • pnpm test -- tests/fusion.test.ts
  • pnpm run typecheck
  • pnpm run format:check
  • git diff --check

@leblancfg
leblancfg force-pushed the vi/preserve-recent-fusion-context branch from ef1e4c1 to ba4b866 Compare June 26, 2026 00:31
@leblancfg
leblancfg merged commit b5c04cd into main Jun 26, 2026
1 check passed
@leblancfg
leblancfg deleted the vi/preserve-recent-fusion-context branch June 26, 2026 00:33
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