Fix/ handle different LLM encodings for listener IDs in speak_to#147
Fix/ handle different LLM encodings for listener IDs in speak_to#147gamal1osama wants to merge 5 commits intomesa:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #147 +/- ##
==========================================
+ Coverage 90.08% 90.17% +0.09%
==========================================
Files 19 19
Lines 1503 1517 +14
==========================================
+ Hits 1354 1368 +14
Misses 149 149 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
The
speak_totool expectslistener_agents_unique_idsto be alist[int], but LLMs often send it in different formats depending on how they serialize arguments:"[5, 9]"(the LLM JSON-encodes it twice by mistake)5(when there's only one recipient)Without this fix, the code raises a
TypeError(e.g.'in <string>' requires string as left operand, not int) which gets caught byToolManager._process_tool_calland returned to the LLM as a cryptic"Error: ..."— the message is never delivered and the LLM has no useful feedback to recover from.This PR adds normalization logic to handle all three cases, so messages get through regaurdless of how the LLM formats the IDs.
Example scenarios that now work:
Testing
Added 5 new tests covering every normalization branch:
test_speak_to_accepts_stringified_list"[11, 12]"parsed viaast.literal_evaltest_speak_to_accepts_bare_int11wrapped to[11]test_speak_to_handles_none_idsNonetreated as empty listtest_speak_to_handles_malformed_string_ids[]test_speak_to_handles_non_numeric_ids_in_list["alice", "bob"]→int()fails →[]The first two fail without this PR (raise
TypeError), the last three cover the except/fallback branches for full patch coverage. All existing tests still pass.