Bug Description
Session compression (context summarization) corrupts tool_call JSON arguments when the conversation is interrupted mid-tool-call (e.g., by a slash command). The tool call’s arguments field is truncated to exactly 214 characters, producing invalid JSON. All subsequent requests in that session fail with:
Minimax midstream error: invalid params, invalid function arguments json string, tool_call_id: call_function_XXXX_1
Steps to Reproduce
- Start a Signal (or other messaging platform) conversation
- Model produces a tool call (e.g., execute_code, patch)
- While the model is processing, user sends a slash command (e.g., /usage, /queue) — the gateway discards it but the message enters the conversation
- Session compression runs automatically (triggered by token limit)
- New session is created via “session split”
- The compressed session now has the tool call with truncated 214-char arguments
- All subsequent API calls fail — only solution is to delete the session file and restart gateway
Evidence
Two confirmed instances — both truncations are exactly 214 chars:
| Original Session |
Tool |
Original Args |
After Compression |
| 20260418_125807_1da1c108 |
patch |
7085 chars VALID |
214 chars INVALID |
| 20260419_091949_e28764f6 |
execute_code |
6089 chars VALID |
214 chars INVALID |
Log evidence of the trigger sequence:
10:47:33 - User: please setup a task that runs every morning at 6:30am...
10:48:26 - User sends /usage while model is thinking
10:48:26 - Gateway: Discarding command /usage from pending queue
10:49:37 - User: /queue I tried using /usage while you were thinking...
10:52:57 - User: Please proceed...
10:57:40 - Compression runs (minimax/minimax-m2.7 via openrouter)
10:58:30 - Session split → corrupted tool call in new session (20260419_105817_b91660)
10:58:29 - First error: API call failed, msgs=42
Same pattern occurred the previous night at 00:06 with a patch tool call.
Environment
- Hermes Agent: NousResearch/hermes-agent
- Provider: OpenRouter (minimax/minimax-m2.7)
- Platform: Signal gateway
- Session storage: SQLite (~/.hermes/sessions/)
Suggested Fix
The compression logic in context_compressor.py appears to be truncating tool call arguments at a fixed byte limit (214). One of:
- Preserve complete tool call arguments during compression — do not truncate function.arguments
- Detect and reject tool calls with incomplete JSON during session replay
- Add validation in tool_call serialization to ensure arguments are valid JSON before storing
Additionally, consider adding a startup check that validates session files for corrupted tool calls and warns or auto-deletes them.
Bug Description
Session compression (context summarization) corrupts tool_call JSON arguments when the conversation is interrupted mid-tool-call (e.g., by a slash command). The tool call’s arguments field is truncated to exactly 214 characters, producing invalid JSON. All subsequent requests in that session fail with:
Steps to Reproduce
Evidence
Two confirmed instances — both truncations are exactly 214 chars:
Log evidence of the trigger sequence:
Same pattern occurred the previous night at 00:06 with a patch tool call.
Environment
Suggested Fix
The compression logic in context_compressor.py appears to be truncating tool call arguments at a fixed byte limit (214). One of:
Additionally, consider adding a startup check that validates session files for corrupted tool calls and warns or auto-deletes them.