Skip to content

test(minimax): use 'content' key so compress_history_tags actually runs#92

Open
shaun0927 wants to merge 1 commit intolsdefine:mainfrom
shaun0927:test/compress-history-key-fix
Open

test(minimax): use 'content' key so compress_history_tags actually runs#92
shaun0927 wants to merge 1 commit intolsdefine:mainfrom
shaun0927:test/compress-history-key-fix

Conversation

@shaun0927
Copy link
Copy Markdown
Contributor

Problem

tests/test_minimax.py::TestMiniMaxCompressHistoryTags::test_think_tag_compressed_in_old_messages
constructs its message fixture with the key \"prompt\":

messages = [
    {"role": "assistant", "prompt": f"<think>{long_think}</think>\nShort answer."},
    {"role": "user", "prompt": "Follow up"},
] + [{"role": "user", "prompt": f"msg{i}"} for i in range(12)]

But compress_history_tags in llmcore.py reads msg['content']:

# llmcore.py:38
c = msg['content']

So the function raises KeyError: 'content' on the first iteration of the
compression loop. The assertion line that the test was written to exercise
is never reached.

$ pytest tests/test_minimax.py::TestMiniMaxCompressHistoryTags -v
E   KeyError: 'content'
llmcore.py:38: KeyError
FAILED tests/test_minimax.py::TestMiniMaxCompressHistoryTags::test_think_tag_compressed_in_old_messages

Fix

Replace \"prompt\" with \"content\" in the fixture and in the
post-compression lookup so the test actually runs the compression
code path it claims to verify.

         messages = [
-            {"role": "assistant", "prompt": f"<think>{long_think}</think>\nShort answer."},
-            {"role": "user", "prompt": "Follow up"},
-        ] + [{"role": "user", "prompt": f"msg{i}"} for i in range(12)]
+            {"role": "assistant", "content": f"<think>{long_think}</think>\nShort answer."},
+            {"role": "user", "content": "Follow up"},
+        ] + [{"role": "user", "content": f"msg{i}"} for i in range(12)]
         ...
-        first_content = result[0]["prompt"]
+        first_content = result[0]["content"]

Verification

$ pytest tests/test_minimax.py::TestMiniMaxCompressHistoryTags -v
PASSED

The test now exercises the real <think> tag truncation path against
compress_history_tags, which is what the test name promises.

test_think_tag_compressed_in_old_messages constructed messages with
a 'prompt' key, but compress_history_tags in llmcore.py reads
msg['content']. The test therefore raises KeyError on the first
iteration of the compression loop before any tag-handling logic
runs, so the assertion line is never reached.

Replace 'prompt' with 'content' in the fixture and in the post-
compression lookup so the test exercises the actual code path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant