fix: keep Hermes session across runs and speak long replies as a digest (2.5.3)

Over the runs transport Hermes never reports the session it attached to a
run in the SSE stream, only in GET /v1/runs/{id}. EveFlow only read it in the
polling fallback, so the locally generated id was sent again and again and
each message opened a fresh Hermes session, losing the conversation context.
The client now adopts the run's session id after every run.

Long answers are now spoken as a digest: the first sentences (configurable,
4 by default) plus the closing question, followed by a short notice that the
full text is on screen. The default instructions ask Hermes to open long
replies with the essentials and to rely on the ongoing conversation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln4KL1feHtnV4nee4sZFhM
This commit is contained in:
Claude committed 2026-09-05 08:22:48 +00:00
1 parent 5991410685
commit c2aef4cbc7
12 files changed
+256 -16

No files matched your search

+19 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { chunkForSpeech, cleanForSpeech, extractSentences, isTranscriptNoise, preprocessMedia } from '../src/lib/text';
import { chunkForSpeech, cleanForSpeech, closingQuestion, extractSentences, isTranscriptNoise, preprocessMedia, spokenDigest } from '../src/lib/text';
describe('text', () => {
it('cleans markdown for speech', () => {
@@ -40,3 +40,21 @@ describe('isTranscriptNoise', () => {
expect(isTranscriptNoise('Oui')).toBe(false);
});
});
describe('spokenDigest', () => {
const reply = 'Voici la réponse. Elle contient plusieurs phrases. Une troisième pour la forme. Et une quatrième.\n\n```js\nconsole.log(1)\n```\n\nTu veux que je continue ?';
it('speaks the first sentences and keeps the closing question', () => {
const digest = spokenDigest(reply, 2);
expect(digest.truncated).toBe(true);
expect(digest.text).toBe('Voici la réponse. Elle contient plusieurs phrases. Tu veux que je continue ?');
});
it('leaves short replies untouched', () => {
const digest = spokenDigest('Bonjour Michael. Tout va bien.', 4);
expect(digest).toEqual({ text: 'Bonjour Michael. Tout va bien.', truncated: false });
});
it('ignores code blocks when counting and only reports a real question', () => {
expect(spokenDigest('Une phrase.\n\n```\ncode\n```\n', 1).truncated).toBe(false);
expect(closingQuestion(reply)).toBe('Tu veux que je continue ?');
expect(closingQuestion('Aucune question ici.')).toBeNull();
});
});