Repository navigation
Conversation
get_communication_history() returned the constant "communication history is in memory of the agent". Being always truthy, ReActReasoning injected it into every prompt as "last communication", in place of the messages the agent had actually received. Consolidation folds each step into an LLM-written summary, so exact wording (offers, quantities, who said what) cannot be recovered from long_term_memory. Keep the most recent messages verbatim in a bounded log, recorded at add time (async delivery goes through add_to_memory), and render them with the shared _format_message_entry() formatter used by the other backends. With no messages the result is "", so ReAct adds no section. Recording at add time keeps the log independent of consolidation: a message is visible while the agent plans its next step, and a failed and retried summarization neither drops nor duplicates it. The log is created lazily so instances unpickled from older versions keep working. Fixes mesa#327
Contributor
|
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: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Author
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.
Pre-PR Checklist
Summary
LongTermMemory.get_communication_history()returned a constant placeholder. Because the string is always truthy,ReActReasoninginjected it into every prompt as "last communication", so agents usingLongTermMemorynever saw the messages they received. This PR returns the real, recent messages, and""when there are none.Bug / Issue
Fixes #327.
react.pyonly adds the section when the history is truthy. The other backends return""when there are no messages.LongTermMemoryreturned"communication history is in memory of the agent", which filled that slot on every step, while messages delivered viasend_messagewere never shown.Implementation
Consolidation rewrites each step into an LLM summary, so exact wording and senders cannot be recovered from
long_term_memory. The fix keeps recent messages verbatim:(step, message)log (communication_history_capacity, default 50, validated as a positive int,boolrejected). The history is injected into every ReAct prompt, so it must not grow without limit.add_to_memoryaftersuper(), so base validation runs first.aadd_to_memorydelegates to it, which covers async delivery._format_message_entry(), matching the output of the other backends.Memory._step_event_order. Instances pickled before this change have no log attribute and would otherwise raiseAttributeErroron the first delivered message.Alternatives rejected:
"": hides the placeholder but still shows no messages.get_prompt_ready().Testing
12 new tests in
tests/test_memory/test_lt_memory.py: all fail onmain, all pass here."".0,-1,1.5,True).ReActReasoning.get_react_promptoutput contains the real message and not the placeholder.End-to-end with two
LLMAgents (LLM mocked): aftersend_message("I offer 20 sugar for 5 spice", [b]),b's ReAct prompt containsStep 0: Agent 1 says: I offer 20 sugar for 5 spice. Same withasend_message.Full suite: 1564 passed.
pre-commit runpasses.Additional Notes
bool/non-int capacities. Happy to fold these into fix(memory): render real communication history in LongTermMemory #328 instead if maintainers prefer.ShortTermMemoryandSTLTMemory, a message received between steps only appears in the history one step after the agent's next planning step. With this change,LongTermMemoryexposes it at that planning step. I can open a follow-up issue.