Simplify compaction: remove proactive abort, use Agent.continue() for retry
- Add agentLoopContinue() to pi-ai for resuming from existing context - Add Agent.continue() method and transport.continue() interface - Simplify AgentSession compaction to two cases: overflow (auto-retry) and threshold (no retry) - Remove proactive mid-turn compaction abort - Merge turn prefix summary into main summary - Add isCompacting property to AgentSession and RPC state - Block input during compaction in interactive mode - Show compaction count on session resume - Rename RPC.md to rpc.md for consistency Related to #128
This commit is contained in:
@@ -407,6 +407,11 @@ export class InteractiveMode {
|
||||
}
|
||||
}
|
||||
|
||||
// Block input during compaction (will retry automatically)
|
||||
if (this.session.isCompacting) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Queue message if agent is streaming
|
||||
if (this.session.isStreaming) {
|
||||
await this.session.queueMessage(text);
|
||||
@@ -604,10 +609,6 @@ export class InteractiveMode {
|
||||
compactionComponent.setExpanded(this.toolOutputExpanded);
|
||||
this.chatContainer.addChild(compactionComponent);
|
||||
this.footer.updateState(this.session.state);
|
||||
|
||||
if (event.willRetry) {
|
||||
this.showStatus("Compacted context, retrying...");
|
||||
}
|
||||
}
|
||||
this.ui.requestRender();
|
||||
break;
|
||||
@@ -743,6 +744,14 @@ export class InteractiveMode {
|
||||
|
||||
renderInitialMessages(state: AgentState): void {
|
||||
this.renderMessages(state.messages, { updateFooter: true, populateHistory: true });
|
||||
|
||||
// Show compaction info if session was compacted
|
||||
const entries = this.sessionManager.loadEntries();
|
||||
const compactionCount = entries.filter((e) => e.type === "compaction").length;
|
||||
if (compactionCount > 0) {
|
||||
const times = compactionCount === 1 ? "1 time" : `${compactionCount} times`;
|
||||
this.showStatus(`Session compacted ${times}`);
|
||||
}
|
||||
}
|
||||
|
||||
async getUserInput(): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user