1.9 KiB
1.9 KiB
Fix for Conversation History Bug in Continuation Flow
Problem
When using continuation_id to continue a conversation, the conversation history (with embedded files) was being lost for tools that don't have a prompt field. Only new file content was being passed to the tool, resulting in minimal content (e.g., 322 chars for just a NOTE about files already in history).
Root Cause
reconstruct_thread_context()builds conversation history and stores it inarguments["prompt"]- Different tools use different field names for user input:
chat→promptanalyze→questiondebug→error_descriptioncodereview→contextthinkdeep→current_analysisprecommit→original_request
- The enhanced prompt with conversation history was being placed in the wrong field
- Tools would only see their new input, not the conversation history
Solution
Modified reconstruct_thread_context() in server.py to:
- Create a mapping of tool names to their primary input fields
- Extract the user's new input from the correct field based on the tool
- Store the enhanced prompt (with conversation history) back into the correct field
Changes Made
-
server.py:
- Added
prompt_field_mappingto map tools to their input fields - Modified to extract user input from the correct field
- Modified to store enhanced prompt in the correct field
- Added
-
tests/test_conversation_field_mapping.py:
- Added comprehensive tests to verify the fix works for all tools
- Tests ensure conversation history is properly mapped to each tool's field
Verification
All existing tests pass, including:
test_conversation_memory.py(18 tests)test_cross_tool_continuation.py(4 tests)- New
test_conversation_field_mapping.py(2 tests)
The fix ensures that when continuing conversations, tools receive the full conversation history with embedded files, not just new content.