fix(core): prevent duplicate LLM calls when message contains URL or triggers providers#6528
Open
nicolasdma wants to merge 1 commit intoelizaOS:developfrom
Open
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…riggers providers Remove providers length check from isSimple determination. Providers enrich state (already handled at L863-871) but don't require re-generating the response. The previous check incorrectly treated "has providers" as "not simple", causing messages with URLs to go through the actions path and trigger a second LLM call via the REPLY action handler. Relates to elizaOS#6486
681b3d8 to
3a304b6
Compare
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.
Relates to
Relates to #6486
Risks
Low — single condition removed from a boolean expression. No new code, no new logic paths.
Background
What does this PR do?
Removes the
providers.lengthcheck from theisSimpledetermination inpackages/typescript/src/services/message.ts.What kind of change is this?
Bug fix (non-breaking change that fixes an issue).
Changes
When a user sends a message containing a URL, the LLM's first call (via
runSingleShotCore) generates and streams the response text. It also returnsproviders: ["ATTACHMENTS"]because the prompt template instructs it to when it sees URLs.The
isSimplecheck at line 1883 previously treated "has providers" as "not simple":This caused the message to go through the
actionspath, which triggered the REPLY action handler (reply.ts:60), making a second LLM call withreplyTemplateand streaming another response — duplicating output and doubling token costs.The fix: Remove the providers check. Providers enrich state (already handled at L863-871) but don't require re-generating the response.
isSimpleshould only care about whether the action is REPLY (text already generated and streamed) vs something else (needs execution).Testing
Greptile Summary
Removes the
providers.lengthcheck from theisSimpleboolean expression, preventing duplicate LLM calls when messages contain URLs or trigger provider enrichment.Key Changes:
(!responseContent.providers || responseContent.providers.length === 0)fromisSimplecheck at line 1883actions: ["REPLY"]now correctly use the "simple" path regardless of provider presenceImpact:
runSingleShotCorecall is now correctly used as final outputConfidence Score: 5/5
Important Files Changed
isSimpledetermination to prevent duplicate LLM calls when URLs trigger provider enrichmentLast reviewed commit: 681b3d8
(2/5) Greptile learns from your feedback when you react with thumbs up/down!