-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sweep: Auto Summarize Working Context (β Sandbox Passed) #24
Conversation
Sandbox Executions
Check backend/memory/memory_manager.py with contents:
Check backend/tests/test_memory_manager.py with contents:
Check backend/agent/coding_agent.py with contents: |
Rollback Files For Sweep
|
Apply Sweep Rules to your PR?
|
PR Analysis
PR Feedbackπ‘ General suggestions: The PR is well-structured and includes relevant tests for the new functionalities. However, it would be beneficial to handle potential exceptions that might occur during the summarization process. Also, consider using a more descriptive variable name than π€ Code feedback:
β¨ Usage tips:
|
Add gensim to requirements.txt |
π Wrote ChangesDone. |
Lets use OpenAI for the summary. |
π Wrote ChangesDone. |
/improve |
π Wrote ChangesDone. |
if self.memory_manager.working_context.turn_counter == 0: | ||
print("Summarized Context: ", self.memory_manager.working_context.context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Instead of directly printing the summarized context, consider returning it as part of the response from the query
method. This would make the output more testable and flexible for different interfaces. [enhancement]
if self.memory_manager.working_context.turn_counter == 0: | |
print("Summarized Context: ", self.memory_manager.working_context.context) | |
if self.memory_manager.working_context.turn_counter == 0: | |
summarized_context = self.memory_manager.working_context.context | |
return {"Summarized Context": summarized_context} |
backend/memory/memory_manager.py
Outdated
def summarize_context(self): | ||
# Call OpenAI API to get the summary | ||
response = self.client.create_summary(self.context) | ||
return response.choices[0].text.strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The summarize_context
method currently returns the summary directly. It would be better to update the context
attribute of the WorkingContext
object within this method. This would ensure that the summarized context is used in subsequent operations. [enhancement]
def summarize_context(self): | |
# Call OpenAI API to get the summary | |
response = self.client.create_summary(self.context) | |
return response.choices[0].text.strip() | |
def summarize_context(self): | |
# Call OpenAI API to get the summary | |
response = self.client.create_summary(self.context) | |
self.context = response.choices[0].text.strip() |
backend/memory/memory_manager.py
Outdated
self.turn_counter += 1 | ||
if self.turn_counter == 5: | ||
self.context = self.summarize_context() | ||
self.turn_counter = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The update_context
method currently increments the turn_counter
and resets it after 5 turns. However, it does not handle the case where the turn_counter
exceeds 5. Consider adding a condition to reset the turn_counter
when it exceeds 5. [bug]
self.turn_counter += 1 | |
if self.turn_counter == 5: | |
self.context = self.summarize_context() | |
self.turn_counter = 0 | |
self.turn_counter = (self.turn_counter + 1) % 6 | |
if self.turn_counter == 0: | |
self.context = self.summarize_context() |
backend/tests/test_memory_manager.py
Outdated
# Arrange: Reset the turn counter to 0 | ||
self.memory_manager.working_context.turn_counter = 0 | ||
# Act: Call the update_context method 5 times | ||
for _ in range(5): | ||
asyncio.run(self.memory_manager.update_context()) | ||
# Assert: Check whether the turn_counter is reset to 0 | ||
assert self.memory_manager.working_context.turn_counter == 0, 'Turn counter was not reset after 5th update' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The test test_turn_counter_reset_after_5th_update
currently checks if the turn_counter
is reset to 0 after 5 updates. However, it does not check if the context is summarized. Consider adding an assertion to check if the context is summarized after 5 updates. [enhancement]
# Arrange: Reset the turn counter to 0 | |
self.memory_manager.working_context.turn_counter = 0 | |
# Act: Call the update_context method 5 times | |
for _ in range(5): | |
asyncio.run(self.memory_manager.update_context()) | |
# Assert: Check whether the turn_counter is reset to 0 | |
assert self.memory_manager.working_context.turn_counter == 0, 'Turn counter was not reset after 5th update' | |
def test_turn_counter_reset_after_5th_update(self): | |
# Arrange: Reset the turn counter to 0 | |
self.memory_manager.working_context.turn_counter = 0 | |
original_context = self.memory_manager.working_context.context | |
# Act: Call the update_context method 5 times | |
for _ in range(5): | |
asyncio.run(self.memory_manager.update_context()) | |
# Assert: Check whether the turn_counter is reset to 0 and context is summarized | |
assert self.memory_manager.working_context.turn_counter == 0, 'Turn counter was not reset after 5th update' | |
assert self.memory_manager.working_context.context != original_context, 'Context was not summarized after 5th update' |
Says it failed the pytest check |
π Wrote ChangesDone. |
PR Feedback (click)
Description
This pull request introduces changes to the codebase that implement auto summarization of the working context in the coding agent. It also includes tests to verify the functionality of the new features.
Summary
query
method ofcoding_agent.py
to print the summarized context if the turn counter is 0.summarize
function fromgensim.summarize
inmemory_manager.py
.summarize_context
inmemory_manager.py
to summarize the context using the imported function.update_context
method inmemory_manager.py
to update the context and reset the turn counter to 0 after every 5th update.test_memory_manager.py
to verify the functionality ofsummarize_context
and the turn counter reset.Fixes #23.
π Latest improvements to Sweep:
π‘ To get Sweep to edit this pull request, you can: