Repository navigation
Use file-backed list for "events" - #205
Conversation
|
@OpenHands please review diff against main, we should add a check in EventLog to enforce the event ID should strictly match their index. If not, we should throw errors. Also add testcase to test this. |
|
I'm on it! xingyaoww can track my progress at all-hands.dev 🟡 Solvability: MEDIUM This is a well-defined enhancement request to add validation logic to EventLog with clear technical requirements and a specific test case request. The issue benefits from straightforward implementation patterns and a focused scope, though it lacks detailed context about the current system behavior. You can make the issue easier to resolve by addressing these concerns in the conversation: • Provide examples of the current EventLog structure and how event IDs are currently handled to better understand the validation requirements Positive feedback: • The request uses precise technical terminology and clearly specifies both the validation requirement and testing needs |
SummaryI have successfully implemented the requested EventLog ID validation feature and comprehensive test coverage. Here's what was accomplished: ✅ Request Completion Checklist:
🔧 Changes Made:1. Enhanced EventLog.append() method (
2. Created comprehensive test suite (
🧪 Validation:
The implementation ensures data integrity by preventing events with mismatched IDs from being stored in the EventLog, maintaining the strict sequential ordering required by the persistence system. |
47806c2 to
940bfc6
Compare
|
@OpenHands review diff from main, FIRST please fix the failing actions on PR #205 at branch |
|
I'm on it! xingyaoww can track my progress at all-hands.dev 🟡 Solvability: MEDIUM This issue involves fixing failing tests and adding comprehensive test coverage for multiple interacting components (EventLog class and Conversation modifications), making it moderately complex to resolve. The request lacks specific technical details about the failing tests and the exact nature of the changes that need testing. You can make the issue easier to resolve by addressing these concerns in the conversation: • Provide specific details about which tests are failing in PR #205 and what error messages or symptoms are occurring Positive feedback: • The issue clearly identifies specific components (EventLog class and Conversation) that need attention |
…ersation - Fixed pre-commit issues: line length, type checking, unused variables - Fixed EventBase.model_validate usage for proper type handling - Added 17 comprehensive edge case tests for EventLog class covering: - ID validation and duplicate detection - Mixed old/new format compatibility - File corruption and error handling - Index gap detection and backfilling - Custom directory support - Added 8 high-quality core tests for Conversation class covering: - Basic creation and event log integration - State persistence and custom IDs - Error handling and large event processing - Memory vs local filestore compatibility - All 25 new tests passing, total 186+ tests in full suite Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
SummaryI have successfully completed both parts of your request for PR #205 on branch ✅ Part 1: Fixed Failing GitHub ActionsPre-commit Issues Resolved:
Test Failures Fixed:
✅ Part 2: Added Comprehensive High-Quality TestsEventLog Edge Case Tests (17 tests):
Conversation Core Tests (8 tests):
Key Technical Improvements:
Results:
The PR is now ready with robust test coverage and all GitHub Actions should pass. The implementation maintains backward compatibility while adding comprehensive validation and error handling for the new file-backed EventLog system. |
- Updated ListLike protocol with overloaded __getitem__ methods for int and slice - Added slice indexing support to EventLog class with proper overloads - Fixed type annotations in test files with appropriate type: ignore comments - All pre-commit checks now pass including pyright type checking - All existing tests continue to pass Co-authored-by: openhands <openhands@all-hands.dev>
…and Conversation" This reverts commit 0749784.
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
|
@OpenHands please fix the failing actions on PR #205 at branch Review diff from main and DO NOT CHANGE ANY IMPLEMENTATION, JUST CHANGE THE TEST. |
|
I'm on it! xingyaoww can track my progress at all-hands.dev 🔴 Solvability: HARD This issue involves fixing failing tests on a specific branch without modifying implementation code, but lacks critical technical details about the nature of the failures. The request is straightforward in scope but challenging to resolve due to insufficient diagnostic information about what specifically is causing the test failures. You can make the issue easier to resolve by addressing these concerns in the conversation: • Include the specific error messages or failure logs from the failing tests to understand what needs to be fixed |
- Updated test_condenser.py to use ConversationState.create() instead of direct constructor
- Fixed test_conversation_core.py tests to match new implementation behavior (no save() method, auto-save)
- Updated test_event_log_edge_cases.py for new EventLog implementation (no clear/save methods, proper event file naming)
- Fixed test_state_serialization.py tests to use proper ConversationState.create() method and conversation_id parameter
- Updated tests to match current behavior: events property is read-only, use append() method
- Fixed event file naming format to use hex event IDs: event-{idx:05d}-{event_id}.json
- Updated error handling tests to match actual implementation behavior
Co-authored-by: openhands <openhands@all-hands.dev>
SummaryI have successfully fixed all failing tests on PR #205 for the ✅ Request Completion Checklist:
🔧 Key Test Fixes Applied:1. ConversationState Usage Pattern:
2. Event Management:
3. Event File Format:
4. ID Management:
5. Error Handling:
📊 Test Results:
🚀 Changes Committed & Pushed:The fixes have been committed and pushed to the |
- Add validation in EventLog.append() to check for duplicate event IDs - Raise ValueError with descriptive message when duplicate ID is detected - Update _scan_and_build_index to warn about duplicates found during scanning - Update tests to expect ValueError when duplicate IDs are added - Maintain backward compatibility by keeping first occurrence during scanning Co-authored-by: openhands <openhands@all-hands.dev>
| conv = Conversation(agent=agent, persist_filestore=fs) | ||
|
|
||
| # Add many events | ||
| num_events = 50 # Reduced for faster testing |
There was a problem hiding this comment.
@OpenHands We should use a really large number like 5000 for test_conversation_large_event_handling and measure the memory usage stay bounded
There was a problem hiding this comment.
I'm on it! xingyaoww can track my progress at all-hands.dev
🔴 Solvability: HARD
This issue involves a performance testing request to measure memory usage with a large number (5000) for a specific test, but lacks critical implementation details. The request is challenging to resolve due to missing technical context, reproduction steps, and specific requirements about how the memory measurement should be conducted.
You can make the issue easier to resolve by addressing these concerns in the conversation:
• Provide detailed reproduction steps explaining how to run the test and measure memory usage
• Include specific technical requirements for what constitutes "bounded" memory usage and acceptable thresholds
• Add context about the current test implementation and what changes are needed to support the larger number
There was a problem hiding this comment.
Summary
I have successfully updated the test_conversation_large_event_handling test as requested in PR #205. Here's what was implemented:
✅ Request Fulfillment Checklist:
- ✅ Use 5000 events: Increased from 50 to 5000 events as requested
- ✅ Memory usage monitoring: Added comprehensive memory monitoring to ensure usage stays bounded
- ✅ Bounded memory verification: Implemented both periodic and final memory checks with reasonable limits
Key Changes Made:
-
Scaled up test size: Changed
num_eventsfrom 50 to 5000 to test with a really large number of events -
Added dual memory monitoring approach:
- Primary: Uses
psutilto monitor actual process memory (RSS) when available - Fallback: Uses
sys.getsizeof()to monitor events list size when psutil unavailable
- Primary: Uses
-
Implemented periodic memory checks: Every 1000 events to ensure memory growth stays bounded during execution
-
Set reasonable memory bounds:
- Process memory: 500MB periodic growth, 1000MB total growth
- List size fallback: 1MB periodic growth, 2MB total growth
-
Added final memory verification: Comprehensive check at test completion to ensure overall memory usage remains bounded
Technical Quality:
- ✅ All pre-commit hooks pass (formatting, linting, type checking)
- ✅ All existing tests continue to pass
- ✅ Robust error handling for optional psutil dependency
- ✅ Proper garbage collection for accurate memory measurements
The changes have been committed and pushed to the xw/persistence branch, updating the existing PR #205. The test now effectively validates that the file-backed event storage system maintains bounded memory usage even with 5000 events, addressing the core concern about memory efficiency in the persistence implementation.
… memory monitoring - Increased num_events from 50 to 5000 to test memory bounds - Added memory usage monitoring with psutil (optional dependency) - Added fallback monitoring using sys.getsizeof when psutil unavailable - Added periodic memory checks every 1000 events to ensure bounded growth - Added final memory check to verify total memory usage stays reasonable - Memory limits: 500MB periodic growth, 1000MB total growth - Fallback limits: 1MB periodic list growth, 2MB total list growth Co-authored-by: openhands <openhands@all-hands.dev>
|
@OpenHands Let's make a description for this PR. Read the diff carefully, understand it, and test it. Then add a description with: what the code is doing, and add an example of how it looks like in real use. The example has to be realistic enough, though small. I suggest that if you can, take it from your tests; if you can't, make a clear example. |
|
I'm on it! enyst can track my progress at all-hands.dev 🔴 Solvability: HARD Hard: the request lacks a title, description, code/diff, tests, environment, or expected behavior—it's only an instruction to write a PR description without providing the actual changes. Without the diff or a concrete example, drafting or verifying the requested description isn’t feasible. You can make the issue easier to resolve by addressing these concerns in the conversation:
|
SummaryI have thoroughly analyzed the PR #205 "Use file-backed list for 'events'" on branch What the Code is DoingThis PR implements a file-backed event persistence system that fundamentally changes how conversation events are stored and managed in the OpenHands SDK: Key Changes:
Real-World ExampleHere's how the new persistence system works in practice: import uuid
from openhands.sdk import Agent, Conversation, LLM
from openhands.sdk.io import LocalFileStore
# Create agent and file store
llm = LLM(model="gpt-4", api_key="your-key")
agent = Agent(llm=llm, tools=[])
file_store = LocalFileStore("./conversation_data")
conv_id = str(uuid.uuid4())
# Create conversation - automatically creates base_state.json
conversation = Conversation(
agent=agent,
persist_filestore=file_store,
conversation_id=conv_id,
)
# Send messages - each creates a separate event file
conversation.send_message(Message(
role="user",
content=[TextContent(text="Hello!")]
))
conversation.run()
# File structure created:
# ./conversation_data/
# ├── base_state.json
# └── events/
# ├── event-00000-{system-prompt-id}.json
# ├── event-00001-{user-message-id}.json
# └── event-00002-{agent-response-id}.json
# Later, resume the conversation seamlessly
del conversation # Simulate process termination
resumed_conversation = Conversation(
agent=agent,
persist_filestore=file_store,
conversation_id=conv_id, # Same ID automatically resumes
)
# All previous events are available immediately
print(f"Resumed with {len(resumed_conversation.state.events)} events")Benefits
This represents a significant architectural improvement that makes conversation persistence more reliable, efficient, and user-friendly. |
|
Merge it for now to iterate on other parts quickly! LMK if you have any concerns and we can iterate. |
Co-authored-by: openhands <openhands@all-hands.dev>
What the Code is Doing
This PR implements a file-backed event persistence system that fundamentally changes how conversation events are stored and managed in the OpenHands SDK:
Changes:
Individual Event Files: Instead of storing all events in memory or a single file, each event is now stored as a separate JSON file with the naming pattern:
event-{idx:05d}-{event_id}.jsonNew EventLog Class: Introduces
EventLogthat implements aListLike[Event]interface, providing seamless file-backed storage with:Simplified Conversation API: The
Conversationclass now usesConversationState.create()factory method that automatically handles both creating new conversations and resuming existing onesAutomatic State Management: Base conversation state is automatically persisted when public fields change, eliminating manual save operations
Real-World Example
Here's how the new persistence system works in practice:
Benefits
This represents a significant architectural improvement that makes conversation persistence more reliable, efficient, and user-friendly.
View full conversation