refactor(runtime): make a single provider step the ModelAdapter primitive - #1425
Merged
Conversation
Astro-Han
commented
Jul 24, 2026
Astro-Han
left a comment
Contributor
Author
There was a problem hiding this comment.
The inline image-budget bug blocks this head.
- [P2]
packages/runtime/src/model-adapter.ts:180setsmaxRetries: 0. Onmain,streamTextuses the AI SDK default of two retries. The replacement path inai-sdk-backend.ts:1577-1597retries only errors classified asNetwork, so 429RateLimitand 5xxProviderUnavailableresponses now fail immediately. Preserve retries for those classes or add them to the runtime-owned retry policy, with tests for both cases. - [P2]
packages/runtime/src/ai-sdk-backend.ts:1634makes an exported optional input mandatory only after the model returns a tool call. A directAiSdkBackendcaller that omitsloadTurnRuntimeEventsworked onmain, but now fails before tool settlement withdurable current-run reader is required for tool continuation. Either make the reader a required constructor contract or retain a non-durable continuation path. Add a tool-loop test with the reader omitted. - [P2] The overflow retry at
packages/runtime/src/ai-sdk-backend.ts:1560keepsreturnedToolCallsfrom the failed attempt. A stream that emits a tool call and then an in-stream context-length error will compact and retry. If the retry finishes normally, the stale call is still settled at line 1638. Clear attempt-local calls before retrying, or decline recovery once the failed attempt has emitted a tool call. The overflow tests cover an error-only stream, not this sequence.
Please revise before merging.
Astro-Han
commented
Jul 24, 2026
This was referenced Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ModelAdapter.startStreamcall exactly one schema-only provider request with SDK retries disabledCloses #1381
Verification
npm test --workspace @maka/runtime— 2,432 passed, 7 skipped, 0 failednpm test --workspace @maka/headless— 1,314 passed, 1 skipped, 0 failednpm run buildnpm run typechecknpm run format:checknpm run lintReview focus
The loop waits for every tool call in a provider step with
Promise.allSettled, then waits for the event consumer durability boundary before reloading the current-run ledger. Overflow recovery rebuilds from durable facts and re-enters active tool-result pruning before the retry so archived payloads cannot reappear.