Skip to content

Fix/pipeline compaction pending loss#1182

Open
ollielin wants to merge 3 commits into
nextlevelbuilder:devfrom
ollielin:fix/pipeline-compaction-pending-loss
Open

Fix/pipeline compaction pending loss#1182
ollielin wants to merge 3 commits into
nextlevelbuilder:devfrom
ollielin:fix/pipeline-compaction-pending-loss

Conversation

@ollielin
Copy link
Copy Markdown

@ollielin ollielin commented May 30, 2026

Summary

Type

  • Feature
  • Bug fix
  • Hotfix (targeting main)
  • Refactor
  • Docs
  • CI/CD

Target Branch

Checklist

  • go build ./... passes
  • go build -tags sqliteonly ./... passes (if Go changes)
  • go vet ./... passes
  • Tests pass: go test -race ./...
  • Web UI builds: cd ui/web && pnpm build (if UI changes)
  • No hardcoded secrets or credentials
  • SQL queries use parameterized $1, $2 (no string concat)
  • New user-facing strings added to all 3 locales (en/vi/zh)
  • Migration version bumped in internal/upgrade/version.go (if new migration)

Test Plan

mrgoonie and others added 3 commits May 20, 2026 17:09
release: promote v3.12.0 official
When PruneStage or ThinkStage triggers mid-loop compaction,
ReplaceHistory() clears the pending buffer. If the current
iteration's assistant(tool_calls) message is in pending, it gets
discarded. The next iteration then sends tool-result messages
without a preceding tool_calls message, causing DeepSeek/OpenAI
to reject the request with HTTP 400:

  Messages with role 'tool' must be a response to a preceding
  message with 'tool_calls'

Fix: save pending before ReplaceHistory and restore it after.

Reproduction:
- Agent with 64K context window
- 4-5 consecutive tool calls (e.g. read_file) in one session
- Token count exceeds soft budget during ToolStage
- PruneStage compaction clears pending including assistant(tool_calls)
- Next iteration fails with HTTP 400
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.

2 participants