fix(pi): preserve non-terminal continuation guards

Keep the base Pi and Prime willContinue guard while settling terminal OMP events directly. Add regression coverage so sibling runtimes cannot publish a false completion after conflict resolution.
This commit is contained in:
Merge Sim
2026-08-30 15:11:08 -07:00
parent f173226664
commit 24042fb3fb
2 changed files with 22 additions and 1 deletions
@@ -86,4 +86,22 @@ describe('OMP agent_end contract', () => {
vi.useRealTimers()
}
})
it('preserves non-terminal agent_end handling for Pi and Prime', async () => {
vi.useFakeTimers()
try {
for (const kind of ['pi', 'prime-agent'] as const) {
const harness = createAgentStatusExtensionHarness({ kind })
const context = { isIdle: vi.fn(() => true) }
await harness.callHook('agent_end', { willContinue: true }, context)
await vi.advanceTimersByTimeAsync(1_000)
expect(postedHookNames(harness.fetchMock)).toEqual([])
expect(context.isIdle).not.toHaveBeenCalled()
}
} finally {
vi.useRealTimers()
}
})
})
+4 -1
View File
@@ -171,8 +171,11 @@ export function getPiAgentStatusHandlerSourceLines(kind: PiAgentKind): string[]
'',
" pi.on('agent_end', (event, ctx) => {",
...captureSessionMetadata,
' if (event?.willContinue === true) {',
' clearPendingAgentEndCheck()',
' return',
' }',
' if (isOmpRuntime()) {',
' if (event?.willContinue === true) return',
' postAgentEndOnce()',
' return',
' }',