Skip to content

fix: settle native tools before compaction #538

Description

@LeXwDeX

Why

With the native LLM runtime enabled, a high-usage provider step can request automatic compaction while a local tool is still executing. The processor closes the stream and aborts that tool. An isolated test of the installed binary reproduced a two-second shell command being interrupted after 349 ms; the identical AI SDK control completed after 2091 ms with exit code 0. The agent loop can continue afterward, but the tool operation has already been interrupted.

Scope

The native session LLM adapter, focused behavior tests, and the v1.0.40 release notes required to deliver this fix through the existing dev-to-main release train. Preserve parallel tool execution, tool-call/result identity, and explicit user cancellation. Do not change DCP policy, automatic compaction thresholds, model limits, or timeout/grace-period settings.

The final review cleanup also covers sharing the repeated 32K model/processor preparation in the three new native regressions. Keep each case's signals, cancellation action, assertions, timeouts, and real runtime path explicit and unchanged. No additional production behavior changes.

Approach

Hold provider step completion events until all local tools for that step have settled and their results have reached the session processor. Keep tool dispatch concurrent and preserve the existing cancellation signal. Exercise the public LLM stream and processor boundary with high usage, delayed and parallel tools, and user interruption; update the earlier finish-before-results expectation.

Acceptance

  • High-usage native requests deliver complete successful slow-tool results before compaction is signaled.

  • Multiple tools start concurrently and all settle before step completion becomes observable.

  • Explicit user interruption still aborts in-flight tools promptly.

  • The regression fails before the fix and passes afterward; package typecheck and relevant host tests pass.

  • The delivery PR targets dev and passes the repository's required checks and SpecGit verdict before merge.

  • Resolve the remaining optional setup-duplication review observation with one focused test preparation helper, and independently review the final delta before publication.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions