fix(agent): use unique IDs for host-advance todo_write events to prevent frontend panel merge#4132
Merged
esengine merged 1 commit intoJun 12, 2026
Conversation
…ite events
emitTodoState emitted every synthetic todo_write with the static ID
host-advance, so multiple complete_step calls within a turn produced
events that the frontend merged into a single item (matching by ID).
The todo panel only rendered the first sign-off update and dropped
subsequent advances.
Add a monotonic atomic.Int64 counter (hostAdvanceSeq) to the Agent and
pass the matched todo item index from advanceCanonicalTodo into
emitTodoState. The tool ID is now host-advance-{seq}-{idx} — the
counter guarantees uniqueness across turns (no cross-turn ID reuse),
while the index maps directly to the task panel position for
debuggability (e.g. host-advance-3-2 means third advance, item 2).
The per-turn ledger, canonical todo state, and all guard mechanisms
are unchanged. Update the hostAdvances test helper to accept any
host-advance-* prefix.
JesonChou
added a commit
to JesonChou/DeepSeek-Reasonix
that referenced
this pull request
Jun 12, 2026
…arts Builds on esengine#4132 (unique host-advance IDs) by fixing the second half of esengine#4105: host-advance events were emitted in real time but never persisted, so the TodoPanel regressed on tab switch or restart. Add HistoryWithCanonicalTodos that injects the canonical task list into the history response, and EmitCanonicalTodoState that pushes it via the live stream, covering both history-load and cached-tab-switch paths.
JesonChou
added a commit
to JesonChou/DeepSeek-Reasonix
that referenced
this pull request
Jun 12, 2026
…arts Builds on esengine#4132 (unique host-advance IDs) by fixing the remaining half of esengine#4105: host-advance events were emitted in real time but never persisted, so the TodoPanel reverted on tab switch or restart. Add HistoryWithCanonicalTodos that injects the canonical task list into the history response, and EmitCanonicalTodoState that pushes it via the live stream, covering both history-load and cached-tab-switch paths. Closes esengine#4105. Regression: internal/agent PASS internal/agent/testutil PASS internal/control PASS (1 pre-existing MCP env failure) internal/serve PASS (1 pre-existing HTML lang failure) internal/evidence PASS Full ./... PASS (9 pre-existing env failures unchanged)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4105
Description
Problem
emitTodoStateemits a synthetictodo_writeevent after eachcomplete_stepsign-off to refresh the frontend TodoPanel. Every event used the static tool ID"host-advance":The frontend (
useController.ts) resolves tool items by ID: when it finds an existing item, it updates it in place instead of creating a new one. Multiplecomplete_stepcalls within a single turn therefore merged into one item, and the TodoPanel only rendered the first sign-off. Subsequent advances were silently dropped.Reproduction (reported in #4105):
Impact: the model follows the system prompt ("you don't need a separate todo_write") but the panel never catches up. The model's observed workaround is to manually re-send
todo_writeafter every sign-off, adding turns and token overhead.Design
Add a monotonic
atomic.Int64counter (hostAdvanceSeq) to the Agent struct, and pass the matched todo item index fromadvanceCanonicalTodointoemitTodoStateto form a unique, self-documenting tool ID:hostAdvanceSeq(prefix)itemIndex(suffix)Examples:
Preserved (unchanged)
verifyTodoCompletionTransitions(feat(agent): guard todo completion transitions #2576: blocks unverified completions)recordTodoState(fix(agent): close complete_step cross-turn evidence + loop gaps #4014: synthetic receipt for cross-turn gate)rebuildTodoState,incompleteCanonicalTodosname === "todo_write", not ID)plan-seedsynthetic events (separate ID namespace)Related
Files changed
Tests
All passing:
complete_step_e2e_test.go— 5 E2E tests (helper updated for prefix match)canonical_todo_test.go—TestAdvanceCanonicalTodoCompletesAndPromotesetc.evidence_flow_test.go— 10 evidence flow testsfinal_readiness_test.go— cross-turn gate behaviourinternal/evidence— receipt matchinginternal/tool/builtin— complete_step / todo_write execution