mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-05 07:07:04 +00:00
fix(codex): wait for manual compaction to finish (#1038)
* test: reproduce issue #982 * fix: wait for Codex manual compaction (closes #982) * test: cover Codex compaction turn completion
This commit is contained in:
@@ -833,6 +833,29 @@ describe('AppServerEventConverter', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('maps completed contextCompaction items and preserves the turn boundary', () => {
|
||||
const converter = new AppServerEventConverter();
|
||||
const events = converter.handleNotification('item/completed', {
|
||||
threadId: 'thread-1',
|
||||
turnId: 'turn-compact',
|
||||
item: { id: 'compact-item-1', type: 'contextCompaction' }
|
||||
});
|
||||
|
||||
expect(events).toEqual([
|
||||
{
|
||||
type: 'thread_compacted',
|
||||
thread_id: 'thread-1',
|
||||
turn_id: 'turn-compact',
|
||||
await_turn_completion: true
|
||||
},
|
||||
{
|
||||
type: 'context_compacted',
|
||||
thread_id: 'thread-1',
|
||||
turn_id: 'turn-compact'
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
it('ignores compacted notifications without thread ids', () => {
|
||||
const converter = new AppServerEventConverter();
|
||||
|
||||
|
||||
@@ -866,6 +866,23 @@ export class AppServerEventConverter {
|
||||
return events;
|
||||
}
|
||||
|
||||
if (itemType === 'contextcompaction') {
|
||||
if (method === 'item/completed') {
|
||||
const threadId = asString(eventScope.thread_id);
|
||||
const turnId = asString(eventScope.turn_id);
|
||||
if (threadId) {
|
||||
events.push({
|
||||
type: 'thread_compacted',
|
||||
thread_id: threadId,
|
||||
...(turnId ? { turn_id: turnId } : {}),
|
||||
await_turn_completion: true
|
||||
});
|
||||
events.push(scoped({ type: 'context_compacted' }));
|
||||
}
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
if (itemType === 'agentmessage') {
|
||||
if (method === 'item/completed') {
|
||||
if (this.completedAgentMessageItems.has(itemId)) {
|
||||
|
||||
Reference in New Issue
Block a user