Repository navigation
fix: scope final-content fallback to model invocation - #672
Closed
pedrojreis wants to merge 1 commit into
Closed
pedrojreis wants to merge 1 commit into
pedrojreis wants to merge 1 commit into
Conversation
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.
Problem
A caller-tool host can mark a tool ID in
graph.invokedToolIdsfrom itson_run_stephandler before the current model invocation finishes. The final-content fallback then recomputes an invocation base key containing the new tool count, fails to find the text deltas already emitted under the original key, and emits the complete assistant plan again after the tool announcement.This produces duplicate streamed/completed assistant content and can break a downstream caller-executed Tool replay.
Change
getStepBaseKey/getStepKeyand their Tool-count discriminator unchanged, so a later post-tool invocation can still emit its own nonstreaming answer.Regression proof
The new test uses the real graph streaming/event path with a deterministic model fixture. It streams a plan, announces a caller Tool, marks its ID from the host callback, and lets the model complete. Before the fix, the aggregated output contains the plan twice; after the fix, both aggregated content and message deltas contain it once.
The full graph reasoning/fallback suite plus Langfuse/deterministic-trace-id coverage passed: 12 suites, 232 tests, including the existing post-tool final-text and invoke-only fallback cases.
No dependency/version bump, release, merge, or deployment is included. This draft is held for owner approval before any upstream merge/publication or downstream rollout.
Additional local checks passed: scoped ESLint on
Graph.tsand its regression suite;npm run build(CJS/ESM bundles and TypeScript declarations). Existing source formatting is preserved; no repository-wide formatter changes are included.Hosted CI status
The upstream CI run currently concludes
action_requiredfor this first-time contributor: https://github.com/LibreChat-AI/agents/actions/runs/42845956936. Maintainer action is required before hosted checks can run; no hosted CI success is claimed. The PR remains a draft, with no merge/publication/rollout performed.