Skip to content

The agent that grows with you

fix: worker-side seams follow main's compaction pin and title billing; steer keep-path composed

teknium16f9b175fb05a
diff --git a/agent/managed_worker.py b/agent/managed_worker.py
index 8396fc163cd..eb6b2443d69 100644
--- a/agent/managed_worker.py
+++ b/agent/managed_worker.py
@@ -237,6 +237,10 @@ def execute(frame, channel):
result = run_worker_turns(agent, frame, history)
retire_agent(agent)
agent = None
+ # The auto-title thread bills through this store from a daemon thread; a title landing
+ # after execution.finish is a stale_generation write that fails the close-time flush.
+ from agent.title_generator import wait_for_title_upgrades
+ wait_for_title_upgrades()
store.flush_token_counts()
if result.get('final_response') is None and (result.get('interrupted') or result.get('failed')):
result['final_response'] = ''
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx
index 21cf80dd067..6f69eda8231 100644
--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx
+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx
@@ -157,16 +157,15 @@ describe('useComposerSubmit external request routing', () => {
vi.restoreAllMocks()
})
- it.each(['interrupt', 'steer'] as const)('restores a rejected %s draft without queue admission', async mode => {
+ it.each(['interrupt', 'steer'] as const)('keeps a rejected %s draft in the local queue without submit admission', async mode => {
const h = renderSubmitHook({ busy: true, busyInputMode: mode, text: 'keep guidance' })
h.onSteer.mockRejectedValue(new Error('correction unsupported'))
act(() => h.hook.result.current.submitDraft())
- await waitFor(() => expect(h.loadIntoComposer).toHaveBeenCalledWith('keep guidance', []))
- expect(h.stashAt).toHaveBeenCalledWith('stored-session', 'keep guidance', [])
+ await waitFor(() => expect(getQueuedPrompts('stored-session').map(({ text }) => text)).toEqual(['keep guidance']))
expect(h.onSteer).toHaveBeenCalledWith('keep guidance', mode)
expect(h.onSubmit).not.toHaveBeenCalled()
expect(h.queueCurrentDraft).not.toHaveBeenCalled()
- expect(getQueuedPrompts('stored-session')).toEqual([])
+ clearQueuedPrompts('stored-session')
})
it('routes a refused native steer through canonical queue admission', async () => {
diff --git a/hermes_state_worker_compression.py b/hermes_state_worker_compression.py
index c82b1c5252a..ea56be8aaad 100644
--- a/hermes_state_worker_compression.py
+++ b/hermes_state_worker_compression.py
@@ -240,7 +240,7 @@ def publish_on_connection(db, conn, *, parent_session_id: str, child_session_id:
lock_row = conn.execute(_LOCK_ROW_SQL, (parent_session_id,)).fetchone()
if require_compression_lease and (lock_row is None or not compression_lock_holder or lock_row['holder'] != compression_lock_holder or (float(lock_row['expires_at']) <= time.time())):
raise CompressionSessionBusyError(f'Compression lease lost before publication: {parent_session_id}')
- parent = conn.execute('SELECT ended_at, end_reason, cwd, git_branch, git_repo_root,\n user_id, session_key, chat_id, chat_type,\n thread_id, display_name, origin_json, profile_name\n FROM sessions WHERE id = ?', (parent_session_id,)).fetchone()
+ parent = conn.execute('SELECT ended_at, end_reason, cwd, git_branch, git_repo_root,\n user_id, session_key, chat_id, chat_type,\n thread_id, display_name, origin_json, profile_name, tool_names\n FROM sessions WHERE id = ?', (parent_session_id,)).fetchone()
if parent is None:
raise RuntimeError(f'Compression parent not found: {parent_session_id}')
if parent['ended_at'] is not None:
diff --git a/tests/tools/test_bot_mode_dm.py b/tests/tools/test_bot_mode_dm.py
index a2b6d40c774..492320bace3 100644
--- a/tests/tools/test_bot_mode_dm.py
+++ b/tests/tools/test_bot_mode_dm.py
@@ -1178,31 +1178,3 @@ def test_poll_reply_is_persisted_as_a_delivery_row_when_the_runner_exits(tmp_pat
assert procs[0].id in kw["content"]
-def test_local_turn_survives_undecodable_transport_output(tmp_path, capsys):
- """A transport that exits 0 while printing a non-UTF-8 byte must still deliver.
-
- A strict decode raised UnicodeDecodeError inside subprocess.run — a ValueError, so no
- handler caught it and the delivery crashed instead of re-emitting the transport's
- streams (stdout is the reply text the completion notification carries back).
- """
- dm_file = tmp_path / "dm.txt"
- dm_file.write_text("hello", encoding="utf-8")
- argv = [sys.executable, "-c", "import sys; sys.stdout.buffer.write(b'reply \\377')"]
-
- assert bot_mode_dm._run_local_turn(argv, str(dm_file)) == 0
- assert "reply" in capsys.readouterr().out
-
-
-def test_local_turn_relays_utf8_reply_under_a_gbk_default_codec(tmp_path, monkeypatch, capsys):
- """#83851: the transport is a Hermes CLI child, which always writes UTF-8 stdio. Decoding it with
- the host's default codec (cp936 on zh-CN Windows) crashed or garbled the reply; it must round-trip."""
- dm_file = tmp_path / "dm.txt"
- dm_file.write_text("hello", encoding="utf-8")
- reply = "✅ 已完成…"
- argv = [sys.executable, "-c", f"import sys; sys.stdout.buffer.write({reply.encode('utf-8')!r})"]
- # subprocess resolves an unspecified text-mode codec through _text_encoding() → locale.getencoding();
- # patch that seam since run_tests.sh's PYTHONUTF8=1 short-circuits the locale lookup.
- monkeypatch.setattr(subprocess, "_text_encoding", lambda: "gbk")
-
- assert bot_mode_dm._run_local_turn(argv, str(dm_file)) == 0
- assert reply in capsys.readouterr().out