Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions apps/code/src/main/services/agent/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,36 +637,34 @@ When creating pull requests, add the following footer at the end of the PR descr
let configOptions: SessionConfigOption[] | undefined;
let agentSessionId: string;

if (isReconnect && adapter === "codex" && config.sessionId) {
const existingSessionId = config.sessionId;
const loadResponse = await connection.loadSession({
sessionId: existingSessionId,
cwd: repoPath,
mcpServers,
});
configOptions = loadResponse.configOptions ?? undefined;
agentSessionId = existingSessionId;
} else if (isReconnect && adapter === "claude" && config.sessionId) {
if (isReconnect && config.sessionId) {
const existingSessionId = config.sessionId;

const posthogAPI = agent.getPosthogAPI();
if (posthogAPI) {
await hydrateSessionJsonl({
sessionId: existingSessionId,
cwd: repoPath,
taskId,
runId: taskRunId,
permissionMode: config.permissionMode,
posthogAPI,
log,
});
// Claude-specific: hydrate session JSONL from PostHog before resuming
if (adapter !== "codex") {
const posthogAPI = agent.getPosthogAPI();
if (posthogAPI) {
await hydrateSessionJsonl({
sessionId: existingSessionId,
cwd: repoPath,
taskId,
runId: taskRunId,
permissionMode: config.permissionMode,
posthogAPI,
log,
});
}
}

const systemPrompt = this.buildSystemPrompt(
credentials,
taskId,
customInstructions,
);

// Both adapters implement unstable_resumeSession:
// - Claude: delegates to SDK's resumeSession with JSONL hydration
// - Codex: delegates to codex-acp's loadSession internally
const resumeResponse = await connection.unstable_resumeSession({
sessionId: existingSessionId,
cwd: repoPath,
Expand Down
Loading