Skip to content

The agent that grows with you

test(bot-mode): pin group PDF staging to the 1:1 file.attach contract

xxxigm8184051be790
diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
index 92788f544f8..d29e5ea23d6 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.test.ts
@@ -589,6 +589,36 @@ describe('attachments', () => {
expect(staged?.data).toBe(pdf.data)
})
+ it('stages group PDFs via file.attach and puts the workspace ref in the member prompt', async () => {
+ const room = await loadRoom()
+ const pdf: Attachment = { data: 'data:application/pdf;base64,JVBERi0=', kind: 'pdf', name: 'spec.pdf' }
+
+ room.rounds.sendToGroupChat('PdfFile', [{ name: 'research', title: '' }], 'read this', null, [pdf])
+ await settle(room, 'PdfFile')
+
+ expect(room.gateway.attaches.some(attach => attach.method === 'file.attach' && attach.filename === 'spec.pdf')).toBe(
+ true
+ )
+ expect(room.gateway.calls).toHaveLength(1)
+ expect(room.gateway.calls[0].prompt).toContain('Attached files staged in your session workspace:')
+ expect(room.gateway.calls[0].prompt).toContain('spec.pdf → @file:attachments/spec.pdf')
+ })
+
+ it('names a failed group PDF attach in the member prompt instead of pretending the file is there', async () => {
+ const room = await loadRoom({
+ failAttach: { 'file.attach': Object.assign(new Error('pdftoppm not installed'), { code: 5028 }) }
+ })
+ const pdf: Attachment = { data: 'data:application/pdf;base64,JVBERi0=', kind: 'pdf', name: 'notes.pdf' }
+
+ room.rounds.sendToGroupChat('PdfFail', [{ name: 'research', title: '' }], 'summarize this', null, [pdf])
+ await settle(room, 'PdfFail')
+
+ expect(room.gateway.calls).toHaveLength(1)
+ expect(room.gateway.calls[0].prompt).toContain('could not be staged into your session')
+ expect(room.gateway.calls[0].prompt).toContain('notes.pdf')
+ expect(room.gateway.calls[0].prompt).not.toContain('Attached files staged in your session workspace:')
+ })
+
it('appends the file.attach ref_text to the member turn prompt', async () => {
const room = await loadRoom()
const doc: Attachment = { data: 'data:text/plain;base64,aGVsbG8=', kind: 'file', name: 'notes.txt' }
diff --git a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts b/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts
index 158bdf82345..ff826a2b3d6 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts
@@ -90,6 +90,9 @@ export interface GatewayOptions {
* `profiles.configure`, then reject it as a CAS conflict — the race the
* sync worker's pull-merge-retry exists for. */
conflictOnce?: { key: string; value: unknown }
+ /** Reject attach RPCs whose method is in this map — after recording the call
+ * so tests can see the staging attempt even when it throws. */
+ failAttach?: Record<string, unknown>
/** Reject every prompt.submit with this — a fatal, non-recoverable failure. */
failEverySubmitWith?: unknown
/** Reject only the FIRST prompt.submit — the 4001 reap the retry recovers. */
@@ -293,6 +296,10 @@ export function createGroupGateway(options: GatewayOptions = {}): ScriptedGatewa
runtime: String(params.session_id ?? '')
})
+ if (Object.hasOwn(options.failAttach ?? {}, method)) {
+ throw options.failAttach![method]
+ }
+
return method === 'file.attach'
? { attached: true, ref_text: `@file:attachments/${String(params.name ?? 'attachment')}` }
: { attached: true }