Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (agy): unwrap a transcript envelope only when its inner payload is itself valid

[._.]/ Adam Eivy77724075b379
diff --git a/server/lib/agentSentinel.js b/server/lib/agentSentinel.js
index 220a09752f..640662984e 100644
--- a/server/lib/agentSentinel.js
+++ b/server/lib/agentSentinel.js
@@ -139,7 +139,11 @@ export async function extractSentinelPayloadFromTranscript(transcript, isPayload
// Two shapes reach a transcript: the documented `{ summary, payload }`
// envelope the agent should have written to the sentinel, and the BARE
// payload object — what a model answering in the terminal actually prints.
- const candidate = 'payload' in parsed ? parsed.payload : parsed;
+ // Unwrap only when the inner value is ITSELF a valid payload: a bare
+ // deliverable that merely happens to carry a `payload` key would otherwise
+ // be discarded in favour of a nested value the hook can't use.
+ const unwrap = 'payload' in parsed && isPayload(parsed.payload);
+ const candidate = unwrap ? parsed.payload : parsed;
if (!isPayload(candidate)) continue;
const summary = typeof parsed.summary === 'string' ? parsed.summary : '';
return { summary, payload: candidate };
diff --git a/server/lib/agentSentinel.test.js b/server/lib/agentSentinel.test.js
index f305ae387f..a8fcff028e 100644
--- a/server/lib/agentSentinel.test.js
+++ b/server/lib/agentSentinel.test.js
@@ -146,6 +146,14 @@ describe('extractSentinelPayloadFromTranscript', () => {
expect(payload).not.toBeNull();
});
+ it('keeps a bare deliverable that merely carries its own \`payload\` key', async () => {
+ // Unwrapping unconditionally would hand the hook the nested value and drop
+ // the answer the model actually printed.
+ const transcript = '{"analysis":"a","proposal":null,"payload":"unrelated"}';
+ const { payload } = await extractSentinelPayloadFromTranscript(transcript, isReasonerPayload);
+ expect(payload).toEqual({ analysis: 'a', proposal: null, payload: 'unrelated' });
+ });
+
it('yields no payload for malformed or partial JSON', async () => {
expect(await extractSentinelPayloadFromTranscript('{"analysis":"cut off mid-thoug', isReasonerPayload))
.toEqual({ summary: '', payload: null });