Skip to content

fix: guard against non-LLM recipients in speak_to tool(#158)#161

Open
BhoomiAgrawal12 wants to merge 4 commits intomesa:mainfrom
BhoomiAgrawal12:fix/speak-to-non-llm-recipient
Open

fix: guard against non-LLM recipients in speak_to tool(#158)#161
BhoomiAgrawal12 wants to merge 4 commits intomesa:mainfrom
BhoomiAgrawal12:fix/speak-to-non-llm-recipient

Conversation

@BhoomiAgrawal12
Copy link
Contributor

Summary

speak_to crashed with AttributeError when any of its named recipients was a non-LLM agent with no memory attribute.

speak_to builds its recipient list from agent.model.agents and does not require recipients to be LLMAgent instances.
The subsequent recipient.memory.add_to_memory() call then crashed on any agent
that was not an LLMAgent.

Bug / Issue

Fixes #158

Implementation

  1. Added hasattr guard inside speak_to's recipient loop.
  2. Added logging for warning.

Testing

New test added in tests/test_tools/test_inbuilt_tools.py and all previous 11 tests passed as well.

Additional Notes

Existing test_speak_to_records_on_recipients is unchanged and still passes.

Copilot AI review requested due to automatic review settings March 5, 2026 20:11
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3e9d159c-5dc8-4a82-a7b2-acedfc5d9146

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

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

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.67%. Comparing base (4ea91ed) to head (4aa28e0).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
+ Coverage   90.08%   90.67%   +0.59%     
==========================================
  Files          19       19              
  Lines        1503     1545      +42     
==========================================
+ Hits         1354     1401      +47     
+ Misses        149      144       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a crash in speak_to when recipients include non-LLM agents that don’t implement the expected memory interface.

Changes:

  • Added a guard in speak_to to skip recipients without a memory attribute and log a warning.
  • Added a unit test to ensure speak_to doesn’t crash when a non-LLM recipient is included.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
mesa_llm/tools/inbuilt_tools.py Skips recipients missing memory and emits a warning instead of crashing.
tests/test_tools/test_inbuilt_tools.py Adds regression coverage for non-LLM recipients lacking memory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@colinfrisch
Copy link
Member

Thanks for your work ! Can you address the copilot suggestions (accept/refuse with justification), we can probably merge soon :)

@colinfrisch colinfrisch self-assigned this Mar 7, 2026
@BhoomiAgrawal12
Copy link
Contributor Author

Thanks for your work ! Can you address the copilot suggestions (accept/refuse with justification), we can probably merge soon :)

@colinfrisch thanks for approving! I have addressed the copilot suggestion of adding another test.

@BhoomiAgrawal12 BhoomiAgrawal12 force-pushed the fix/speak-to-non-llm-recipient branch from f7a2213 to d33b841 Compare March 7, 2026 17:22
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.

speak_to tool call crashes with AttributeError when recipients are non-LLM agents

3 participants