From b07a8fc76f3805d6feaee0ca7f775fdca9a9405d Mon Sep 17 00:00:00 2001 From: 356252190-star <356252190@163.com> Date: Sun, 26 Apr 2026 17:47:39 +0800 Subject: [PATCH] fix: add X-Hermes-Session-Id header to preserve tool context across turns (#240) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #237 When web-ui sends a chat message, it includes conversation_history with only user and assistant messages — tool calls and tool results are filtered out. Meanwhile, it sends session_id in the request body but does NOT pass the X-Hermes-Session-Id header. Without the header, the gateway falls back to using the incomplete conversation_history from the body, so the AI agent loses context about previous tool calls, especially after idle periods. Fix: Pass X-Hermes-Session-Id as a request header so the gateway loads complete session history from the session DB (including tool messages). Co-authored-by: 356252190-star <356252190-star@users.noreply.github.com> --- packages/client/src/api/hermes/chat.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/client/src/api/hermes/chat.ts b/packages/client/src/api/hermes/chat.ts index bbd399c..48e706f 100644 --- a/packages/client/src/api/hermes/chat.ts +++ b/packages/client/src/api/hermes/chat.ts @@ -41,9 +41,14 @@ export interface RunEvent { } export async function startRun(body: StartRunRequest): Promise { + const headers: Record = {} + if (body.session_id) { + headers['X-Hermes-Session-Id'] = body.session_id + } return request('/api/hermes/v1/runs', { method: 'POST', body: JSON.stringify(body), + headers, }) }