mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-16 13:04:07 +00:00
Fix runtime memory review issues
Address runtime memory review feedback around sqlite compatibility, shutdown ordering, and endpoint validation. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
9c5dde8615
commit
9e11f49d17
3 changed files with 171 additions and 52 deletions
|
|
@ -348,6 +348,7 @@ export class AgentSession {
|
|||
private _baseSystemPrompt = "";
|
||||
private _memoryManager: RuntimeMemoryManager;
|
||||
private _memoryWriteQueue: Promise<void> = Promise.resolve();
|
||||
private _memoryDisposePromise: Promise<void> | null = null;
|
||||
|
||||
constructor(config: AgentSessionConfig) {
|
||||
this.agent = config.agent;
|
||||
|
|
@ -540,7 +541,7 @@ export class AgentSession {
|
|||
await this._checkCompaction(msg);
|
||||
|
||||
if (msg.stopReason !== "error") {
|
||||
this._enqueueMemoryPromotion(event.messages);
|
||||
this._enqueueMemoryPromotion([...this.agent.state.messages]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -696,9 +697,7 @@ export class AgentSession {
|
|||
dispose(): void {
|
||||
this._disconnectFromAgent();
|
||||
this._eventListeners = [];
|
||||
void this._memoryWriteQueue.finally(() => {
|
||||
this._memoryManager.dispose();
|
||||
});
|
||||
void this._disposeMemoryManager();
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
|
@ -889,6 +888,31 @@ export class AgentSession {
|
|||
}
|
||||
}
|
||||
|
||||
private async _disposeMemoryManager(): Promise<void> {
|
||||
if (this._memoryDisposePromise) {
|
||||
await this._memoryDisposePromise;
|
||||
return;
|
||||
}
|
||||
|
||||
this._memoryDisposePromise = (async () => {
|
||||
try {
|
||||
await this._agentEventQueue;
|
||||
} catch {
|
||||
// Event processing failures should not block shutdown.
|
||||
}
|
||||
|
||||
try {
|
||||
await this._memoryWriteQueue;
|
||||
} catch {
|
||||
// Memory writes are best-effort during shutdown too.
|
||||
}
|
||||
|
||||
this._memoryManager.dispose();
|
||||
})();
|
||||
|
||||
await this._memoryDisposePromise;
|
||||
}
|
||||
|
||||
private _enqueueMemoryPromotion(messages: AgentMessage[]): void {
|
||||
this._memoryWriteQueue = this._memoryWriteQueue
|
||||
.catch(() => undefined)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue