539
540
pipeline.attachRematerializer(async (_reason) => {
541
>
const liveMode = readClaudePermissionMode(this._configurationService, this._storageUri) ?? this._permissionModeFallback;
claudeAgentSession.ts
542
>
try {
543
>
const { mcpServers: rebuildMcp, allowedTools: rebuildAllowedTools } = await this._buildStartupToolWiring(ctx.serverToolHost);
544
>
const rebuildAgentName = await resolveClaudeAgentName(this._provisionalAgent, this._fileService, this._logService, this.sessionId);
545
>
const rebuildAbort = new AbortController();
546
>
const rebuildOptions = await buildOptions(
547
>
{
548
>
sessionId: this.sessionId,
549
>
workingDirectory: this.workingDirectory!,
550
>
model: this._provisionalModel,
551
>
abortController: rebuildAbort,
552
>
permissionMode: liveMode,
553
>
canUseTool: ctx.canUseTool,
554
>
onElicitation: ctx.onElicitation,
555
>
isResume: true,
556
>
resumeSessionAt: this._pendingResumeSessionAt,
557
>
mcpServers: rebuildMcp,
558
>
allowedTools: rebuildAllowedTools,
559
>
plugins: this.clientCustomizationsDiff.consume(this._desiredClientPluginPaths()),
560
>
agent: rebuildAgentName,
561
>
},
562
>
ctx.transport,
563
>
data => this._logService.error(`[Claude SDK stderr] ${data}`),
564
>
);
565
>
this._logService.info(`[Claude] session ${this.sessionId}: resume rebuild agent=${rebuildOptions.agent ?? '(none)'}`);
566
>
const rebuildWarm = await this._sdkService.startup({ options: rebuildOptions });
567
>
// Rebuild succeeded with the anchor applied — clear it so it
568
>
// isn't re-applied. A throw above keeps it staged (handled in the
569
>
// catch alongside the tool/customization diffs) so the next send
570
>
// retries the truncation instead of dropping the restore.
571
>
this._pendingResumeSessionAt = undefined;
572
>
return { warm: rebuildWarm, abortController: rebuildAbort };
573
>
} catch (err) {
574
this.toolDiff.markDirty();
575
this.clientCustomizationsDiff.markDirty();