Skip to content

fix(runtime): keep dispatch alive when model context is not cloneable - #3528

Merged
kojiwakayama merged 2 commits into
mainfrom
fix/issue-375-nonfatal-model-context
Aug 10, 2026
Merged

kojiwakayama merged 2 commits into
mainfrom
fix/issue-375-nonfatal-model-context

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes veryfront/veryfront-issue-inbox#375.\n\n## Summary\n\n- drop a model-call context event when its payload cannot be structured-cloned\n- count and log the sanitized failure class without including tool output\n- continue model dispatch while preserving fail-closed behavior for actual sink failures\n\n## Verification\n\n- \n- \n- \n- running 1 test from ./src/runtime/runtime-bridge.test.ts
runtime-bridge ...
skips non-cloneable model context without failing model dispatch ...
------- output -------
12:17:28 SERVER ▲ [runtime-bridge] Model call context event was not persisted because it is not cloneable
failureClass=DataCloneError
12:17:28 SERVER ▲ [runtime-bridge] Model call context event was not persisted because it is not cloneable
failureClass=DataCloneError
----- output end -----
skips non-cloneable model context without failing model dispatch ... ok (1ms)
emits one exact run event with normalized messages and resolved tools before direct generate ... ok (0ms)
records exactly one ordered context for each evolving skill-backed dispatch ... ok (0ms)
emits before stream-backed generate and direct stream dispatch ... ok (1ms)
propagates sink failures without dispatching ... ok (0ms)
awaits the mandatory sink before the public sink and provider dispatch ... ok (0ms)
calls a sink shared by both lanes only once ... ok (0ms)
fails closed in either sink lane ... ok (1ms)
isolates nested sink mutations from generate and stream provider inputs ... ok (0ms)
uses the direct generate path for models without tools ... ok (0ms)
forwards reasoning options to direct generate models ... ok (0ms)
buffers the stream path for models that prefer streamed generate ... ok (0ms)
buffers streamed tool calls for models that prefer streamed generate ... ok (1ms)
uses the direct stream path for models without tools ... ok (0ms)
rejects a second stream view started after direct consumption ... ok (0ms)
cancels a sole stream consumer without waiting for an unused branch ... ok (0ms)
handles an abandoned stream request rejection ... ok (0ms)
forwards reasoning options to direct stream models ... ok (0ms)
uses the direct generate path for ordinary function tools ... ok (0ms)
uses the direct stream path for ordinary function tools ... ok (0ms)
uses the direct stream path for provider-native tools ... ok (0ms)
uses the direct generate path for provider-native tools ... ok (0ms)
keeps providerExecuted on direct generate provider tool results ... ok (0ms)
uses the direct stream path for provider-native web_fetch ... ok (1ms)
uses the direct generate path for provider-native web_fetch ... ok (0ms)
drops trailing assistant prefill messages before direct stream requests ... ok (0ms)
drops trailing assistant prefill messages before direct generate requests ... ok (0ms)
runtime-bridge ... ok (7ms)

ok | 1 passed (27 steps) | 0 failed (10ms)\n-

Summary by CodeRabbit

  • Bug Fixes
    • Runtime dispatch now succeeds when model context contains data that cannot be cloned.
    • Uncloneable context is skipped for event delivery instead of causing the model call to fail.
    • Successfully cloneable events continue to be delivered independently.
    • Improved logging and metrics capture when event data cannot be cloned.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kojiwakayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 28 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d8a75cc-8fd2-4527-9424-6bd233ff384f

📥 Commits

Reviewing files that changed from the base of the PR and between 9c61c8d and 3579745.

📒 Files selected for processing (3)
  • docs/api-reference/veryfront/embedding.md
  • src/runtime/runtime-bridge.test.ts
  • src/runtime/runtime-bridge.ts
📝 Walkthrough

Walkthrough

The runtime bridge now skips non-cloneable model context events. It records an error metric, logs a warning, and continues model dispatch. Tests verify successful dispatch and skipped sink delivery.

Changes

Runtime bridge clone handling

Layer / File(s) Summary
Handle non-cloneable context events
src/runtime/runtime-bridge.ts
Clone failures now record an error metric and log a warning. Failed events are skipped independently for mandatory and public sinks.
Verify dispatch behavior
src/runtime/runtime-bridge.test.ts
The test now expects successful dispatch, one model invocation, and no run-event sink invocation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: kwakayama

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: keeping runtime dispatch active when model context is not cloneable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-375-nonfatal-model-context

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c61c8d3ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/runtime/runtime-bridge.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/runtime/runtime-bridge.ts`:
- Around line 513-520: Update the event delivery flow around cloneEvent so a
null clone for one sink does not return before the other sink is invoked; remove
the combined mandatoryEvent/publicEvent early return and rely on the existing
per-sink guards to deliver each successfully cloned event. Add a regression test
covering two sinks where one clone fails and the other succeeds, verifying only
the successful clone is delivered.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a5614692-c8c1-4578-97bc-890ffc03ef62

📥 Commits

Reviewing files that changed from the base of the PR and between a63ffc0 and 9c61c8d.

📒 Files selected for processing (2)
  • src/runtime/runtime-bridge.test.ts
  • src/runtime/runtime-bridge.ts

Comment thread src/runtime/runtime-bridge.ts
@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 10, 2026
@kojiwakayama
kojiwakayama removed this pull request from the merge queue due to a manual request Aug 10, 2026
@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit 41dd8d4 Aug 10, 2026
53 of 56 checks passed
@kojiwakayama
kojiwakayama deleted the fix/issue-375-nonfatal-model-context branch August 10, 2026 11:32
@kwakayama kwakayama mentioned this pull request Aug 10, 2026
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