Fix race condition bug in session file check

Co-authored-by: pavelfeldman <883973+pavelfeldman@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-07-21 03:32:24 +00:00
parent bb9de30ef9
commit e35f0ac562

View File

@ -148,13 +148,17 @@ export class Context {
}
private async _logSessionEntry(toolName: string, params: Record<string, unknown>, snapshotFile?: string) {
if (!this.config.saveSession || !this._sessionFile)
if (!this.config.saveSession)
return;
// Ensure session file is initialized before proceeding
if (this._sessionFileInitialized)
await this._sessionFileInitialized;
// After initialization, session file should always be defined when saveSession is true
if (!this._sessionFile)
throw new Error('Session file not initialized despite saveSession being enabled');
const entry = [
`- ${toolName}:`,
' params:',