Private
Public Access
0
0

chore(conductor): Add new track 'minimax_history_fix_20260601'

This commit is contained in:
2026-06-01 22:13:00 -04:00
parent 7a434adb7c
commit c1764a644d
5 changed files with 53 additions and 0 deletions
+5
View File
@@ -280,3 +280,8 @@ This file tracks all major tracks for the project. Each track has its own detail
- [x] **Track: Selectable Thinking Monologs**
*Link: [./tracks/selectable_thinking_monologs_20260601/](./tracks/selectable_thinking_monologs_20260601/)*
---
- [ ] **Track: Fix MiniMax history sequencing and truncation**
*Link: [./tracks/minimax_history_fix_20260601/](./tracks/minimax_history_fix_20260601/)*
@@ -0,0 +1,5 @@
# Track minimax_history_fix_20260601 Context
- [Specification](./spec.md)
- [Implementation Plan](./plan.md)
- [Metadata](./metadata.json)
@@ -0,0 +1,8 @@
{
"track_id": "minimax_history_fix_20260601",
"type": "bug",
"status": "new",
"created_at": "2026-06-01T00:00:00Z",
"updated_at": "2026-06-01T00:00:00Z",
"description": "Fix MiniMax history sequencing and truncation"
}
@@ -0,0 +1,18 @@
# Implementation Plan: MiniMax History Fix
## Phase 1: Implementation
- [ ] Task: Implement History Repair
- [ ] Create `_repair_minimax_history(history: list[dict[str, Any]])` in `src/ai_client.py`.
- [ ] Logic: Check if the last message is `assistant` with `tool_calls`. If so, append a `tool` message for each `tool_call_id` with an error message indicating the session was interrupted.
- [ ] Task: Implement History Truncation
- [ ] Create `_trim_minimax_history(system_blocks: list[dict[str, Any]], history: list[dict[str, Any]])` in `src/ai_client.py` (adapt from `_trim_anthropic_history`).
- [ ] Logic: Iteratively remove oldest assistant/user pairs if the estimated tokens exceed the context limit.
- [ ] Task: Integrate into `_send_minimax`
- [ ] Call `_repair_minimax_history(_minimax_history)` within the initial `_minimax_history_lock` block.
- [ ] Call `_trim_minimax_history` at the start of the `for round_idx` loop.
- [ ] Log dropped messages to `_append_comms`.
## Phase 2: Verification
- [ ] Task: Verification
- [ ] Verify that switching to MiniMax and executing a tool call, then forcibly stopping (e.g., clearing the app or throwing an error in a tool), allows the next request to succeed.
- [ ] Task: Conductor - User Manual Verification 'Phase 2: Verification' (Protocol in workflow.md)
@@ -0,0 +1,17 @@
# Specification: MiniMax API History Sequence Fix
## 1. Overview
The user is experiencing a `MiniMax Bad Request: invalid params, tool call result does not follow tool call (2013)` error. This occurs when the `_minimax_history` in `src/ai_client.py` becomes corrupted, typically when a session is interrupted after the AI makes a tool call but before the `tool` role result messages are appended. The next user message breaks the required `assistant(tool_calls) -> tool` sequence.
## 2. Functional Requirements
* **History Repair:** Implement a `_repair_minimax_history` function (similar to `_repair_deepseek_history`) to detect dangling tool calls at the end of the history and append synthesized error `tool` responses to close the loop before adding new user messages.
* **History Truncation:** Implement a `_trim_minimax_history` function to prevent the history array from growing indefinitely and hitting token limits. It should intelligently drop old message pairs (assistant/user) while preserving tool call sequences.
* **Integration:** Apply these mechanisms within the `_send_minimax` execution flow.
## 3. Non-Functional Requirements
* **Stability:** The changes must safely handle locking (`_minimax_history_lock`) and not crash if history is empty.
* **Consistency:** The implementation should align with the established patterns used for the DeepSeek and Anthropic providers.
## 4. Acceptance Criteria
* The `_send_minimax` function no longer crashes with error code 2013 when resuming a session after an interrupted tool call.
* The history remains within manageable token limits over long sessions.