Repository navigation
fix(tools): persist tool output reference labels and keep keys unique across runs - #629
Open
Shabonasar wants to merge 1 commit into
Open
Shabonasar wants to merge 1 commit into
Shabonasar wants to merge 1 commit into
Conversation
… across runs
[ref: toolNturnM] labels were added only when the key was live in the current
run's registry, and every run restarted its turn counter at 0. A restored
history therefore had no labels (the first labelled result of each later turn
changed the prefix and missed the provider cache), and keys repeated between
turns, so {{tool0turn0}} from an old turn silently resolved to the current one.
- ON_RUN_STEP_COMPLETED tool_call now carries `ref` and `unresolved_refs`
(direct, early, eager and batch completions); the content aggregator keeps them
- formatAgentMessages restores them as `_refKey` / `_unresolvedRefs`
- annotateMessagesForLLM labels by `_refKey` without a registry lookup
- Run seeds the registry turn counter past the highest restored key, so a
placeholder naming an older turn is reported as unresolved
Fixes LibreChat-AI#627
This was referenced Oct 20, 2026
This branch has not been deployed
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.
The
[ref: tool<i>turn<n>]label is now the stored name of a tool output: it is saved with the result and restored with the history, and turn numbers continue across runs. Before, the label was shown only while the key was in the current run's registry and every run restarted atturn0, so:{{tool0turn0}}from an old turn silently resolved to the current turn's output.Fixes #627
[unresolved refs: ...]warning.tool_callpart.Measurements
Real Anthropic API through LibreChat, 6 turns, adaptive thinking, code interpreter running code, chained
bash_toolcalls, MCP tool, restart after turn 3, turn 5 references a key from turn 1. "series" = the LibreChat series plus agents #613, #614, #615, #619 (LibreChat-AI/LibreChat#17102);dev= LibreChatdevwith agentsmain. This PR has no dependency on the series and was added on top of each. "before" used a 1h cache TTL, "after" 5m.devdevWith the series, keys run
tool0turn0...tool0turn8without repeats, and the turn-5 probe returns[unresolved refs: tool0turn0]instead of a wrong output. Ondevthe labels are now stable too, but its misses come from other restore differences fixed by the series (LibreChat-AI/LibreChat#17102).Testing
llmspecs need API keys, 2 handoff/checkpoint specs).ToolNode.persistedReferences.test.ts(9): fields on direct, early and eager completions; none when the feature is off; aggregator -> persistence -> restore gives the live wire content; turn seeding; old key stays unresolved.tsc --noEmit, eslint,check:circular-depsclean.Type of change
Checklist