fix: preserve queued prompt boundaries end to end - #63298
fix: preserve queued prompt boundaries end to end#63298yingliang-zhang wants to merge 13 commits into
Conversation
Related: competes with #46459 (earlier, narrower — role-alternation merge only) for the same #45560. This PR is the broader end-to-end superset (FIFO queue + Desktop hydration + exactly-once IDs + cron/gateway mirror). Not a duplicate; maintainer picks the canonical approach. |
|
Follow-up from independent review: commit f735371a2 removes the JSON-RPC request-id fallback for |
f735371 to
84b6afc
Compare
|
Rebased onto latest |
|
Thanks for tracing the loss of prompt identity through the TUI queue, canonical history, SessionDB, and provider copy. The underlying issue is real: Problems
Suggested changes
Automated hermes-sweeper review. |
|
Addressed the The busy-submit path again attempts Verification:
|
7a146e1 to
ae8afd7
Compare
|
Rebased the reviewed series onto current |
ae8afd7 to
850ccfa
Compare
|
Main advanced again across the Desktop queue/session-switch surface, so I completed a second exact-lease rebase. Final head is |
|
Fixed the new current-main CI contract failure in The restore-repair test introduced by
I also corrected the directly stale restore comments/docstrings; production control flow is unchanged. Verification:
|
27b4340 to
3f5034e
Compare
3f5034e to
e1130c7
Compare
caaccf0 to
c706e9c
Compare
ef7fe8e to
f2c8b04
Compare
Address maintainer review by retaining accepted live steering and identity-preserving queued fallback, including current-main interrupt behavior after rejected steering.
Update rebased fixtures for routed stored-session helpers and assert source metadata survives compute-host fail-open dispatch.
Update the current-main restore-repair tests and explanatory comments for NousResearch#63298's canonical source-boundary contract. Adjacent user turns remain distinct in canonical history while the copied provider wire payload merges them with an explicit marker.
… preserving user turns
Co-authored-by: Hermes Agent (orchestrator) <noreply@hermes-agent.local>
…loads Co-authored-by: Hermes Agent (orchestrator) <noreply@hermes-agent.local>
Fixes #45560.
Summary
[Next user message]marker so the model still sees the semantic boundaryRoot cause
tui_gateway._enqueue_promptstored one pending prompt. A second busy-time submission replaced that source boundary withprev + "\n\n" + text, so queueing, SessionDB, and Desktop hydration could never recover two independently submitted messages.A second destructive merge existed in
repair_message_sequence: consecutive canonical user dicts were collapsed in place before API construction. That also changed the DB flush cursor and erased source identity even when the gateway had preserved it.This PR keeps source messages separate through the canonical queue/history/DB path. Provider-only role repair runs on copied API messages, where adjacent users are merged with an explicit boundary marker. No synthetic assistant bubble is added to canonical history.
Exactly-once behavior
Desktop reuses the queue entry ID when a timed-out submission resumes and retries. The gateway now acknowledges an explicit ID already present in the inflight turn, FIFO, canonical history, or SessionDB instead of interrupting/enqueuing it again. JSON-RPC request IDs are deliberately not used for deduplication because clients may reuse them after reconnect.
Verification
tests/test_tui_gateway_server.pywith standalone-TUI environment — 316 passedtests/test_tui_gateway_queue_on_busy.py— 16 passednpm run typecheckand focused ESLint — passedgit diff --check— passedThe six warnings in the 265-test run are existing
pkg_resources/datetime deprecations fromlark_oapiduring Telegram configuration tests.Relation to #46459
#46459 preserves chronology by writing
[Later user message]into text that is still canonically merged. This PR is an independent end-to-end fix for the uncoveredtui_gatewaysingle-slot/DB/Desktop path and uses a different architecture: canonical objects remain separate, while a separately implemented[Next user message]marker exists only in the provider wire copy. No code from #46459 is included.