📬 feat: Report Tool Results Per Call via onResult Channel#13698
Merged
Conversation
Owner
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Contributor
GitNexus: ❌ deploy failedThe deploy failed — the previous index (if any) continues to be served. |
Tool batches already execute in parallel here, but results were only delivered to the agent graph through the single resolve(results[]) call — so a fast tool's completion event waited on the slowest call in the batch. Report each result through the optional onResult channel (agents SDK > 3.2.33) as it settles, letting the graph emit that call's completion immediately. resolve remains the authoritative batch outcome; the callback is optional-chained, so this is a no-op until the SDK release lands and remains backward compatible after.
…kage-lock.json and related package.json files
0a9241e to
3fa2dbd
Compare
onResult Channel
fuuuzzy
pushed a commit
to fuuuzzy/LibreChat
that referenced
this pull request
Jun 18, 2026
…ila#13698) * 📬 feat: Report Tool Results Per Call via onResult Channel Tool batches already execute in parallel here, but results were only delivered to the agent graph through the single resolve(results[]) call — so a fast tool's completion event waited on the slowest call in the batch. Report each result through the optional onResult channel (agents SDK > 3.2.33) as it settles, letting the graph emit that call's completion immediately. resolve remains the authoritative batch outcome; the callback is optional-chained, so this is a no-op until the SDK release lands and remains backward compatible after. * 🧹 chore: Prettier Formatting in onResult Spec * 🧹 chore: Sort Imports in handlers.ts * 🔧 chore: Update @librechat/agents dependency to version 3.2.34 in package-lock.json and related package.json files
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
I wired the tool-execution handler to report each result to the agent graph as it settles, instead of only delivering the full batch at the end. The handler already runs tool batches in parallel (
Promise.allover the calls), but theON_TOOL_EXECUTEcontract previously exposed only the singleresolve(results[])channel — so a 1-second tool's completion event waited for the slowest call in the same batch. The agents SDK now accepts an optional per-callonResultcallback (agents#239) and emits that call's completed run step immediately when invoked; this PR is the host half.onResultcallback off the batch request with a forward-compatible cast, so this compiles against the currently installed SDK typings and activates automatically once the release containing agents#239 lands; until thenonResultisundefinedand the optional chain makes this a no-op.reportResulthelper, so every result shape — success, error, host-tool, queued — is reported exactly once as it settles;resolve(results)remains the authoritative batch outcome and is unchanged.The SDK side gates the fast-path on no-hooks/no-HITL configurations and dedupes against batch-time emission, so no changes are needed here for those cases — when the SDK withholds
onResult, this code path is simply inert.Change Type
Testing
packages/api/src/agents/handlers.spec.ts: a gated slow tool proves the fast call is reported before the batch resolves (and before the slow tool finishes); a throwingonResultlistener doesn't preventresolve; behavior withoutonResultis unchanged. Fullhandlers.spec.tspasses (78 tests).tscreports no errors in the touched files.Test Configuration:
packages/api.Checklist