From c1764a644d2ba8289b50d9f4e03dab025c225867 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 1 Jun 2026 22:13:00 -0400 Subject: [PATCH] chore(conductor): Add new track 'minimax_history_fix_20260601' --- conductor/tracks.md | 5 +++++ .../minimax_history_fix_20260601/index.md | 5 +++++ .../minimax_history_fix_20260601/metadata.json | 8 ++++++++ .../minimax_history_fix_20260601/plan.md | 18 ++++++++++++++++++ .../minimax_history_fix_20260601/spec.md | 17 +++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 conductor/tracks/minimax_history_fix_20260601/index.md create mode 100644 conductor/tracks/minimax_history_fix_20260601/metadata.json create mode 100644 conductor/tracks/minimax_history_fix_20260601/plan.md create mode 100644 conductor/tracks/minimax_history_fix_20260601/spec.md diff --git a/conductor/tracks.md b/conductor/tracks.md index 94f90673..513e5a4e 100644 --- a/conductor/tracks.md +++ b/conductor/tracks.md @@ -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/)* diff --git a/conductor/tracks/minimax_history_fix_20260601/index.md b/conductor/tracks/minimax_history_fix_20260601/index.md new file mode 100644 index 00000000..c9110e90 --- /dev/null +++ b/conductor/tracks/minimax_history_fix_20260601/index.md @@ -0,0 +1,5 @@ +# Track minimax_history_fix_20260601 Context + +- [Specification](./spec.md) +- [Implementation Plan](./plan.md) +- [Metadata](./metadata.json) \ No newline at end of file diff --git a/conductor/tracks/minimax_history_fix_20260601/metadata.json b/conductor/tracks/minimax_history_fix_20260601/metadata.json new file mode 100644 index 00000000..2a3b9323 --- /dev/null +++ b/conductor/tracks/minimax_history_fix_20260601/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" +} \ No newline at end of file diff --git a/conductor/tracks/minimax_history_fix_20260601/plan.md b/conductor/tracks/minimax_history_fix_20260601/plan.md new file mode 100644 index 00000000..52a982bd --- /dev/null +++ b/conductor/tracks/minimax_history_fix_20260601/plan.md @@ -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) \ No newline at end of file diff --git a/conductor/tracks/minimax_history_fix_20260601/spec.md b/conductor/tracks/minimax_history_fix_20260601/spec.md new file mode 100644 index 00000000..14b9291f --- /dev/null +++ b/conductor/tracks/minimax_history_fix_20260601/spec.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. \ No newline at end of file