Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions packages/app/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,11 @@ export default function App() {
void refreshPlugins(pluginScope());
void refreshMcpServers();
},
abortSession: async (sessionID: string) => {
const c = client();
if (!c) return;
await abortSessionTyped(c, sessionID);
},
});

const {
Expand Down
10 changes: 10 additions & 0 deletions packages/app/src/app/context/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export function createSessionStore(options: {
setSseConnected: (connected: boolean) => void;
markReloadRequired?: (reason: ReloadReason, trigger?: ReloadTrigger) => void;
onHotReloadApplied?: () => void;
abortSession?: (sessionID: string) => Promise<void>;
}) {

const sessionDebugEnabled = () => options.developerMode();
Expand Down Expand Up @@ -177,6 +178,7 @@ export function createSessionStore(options: {
const invalidToolDetectionSet = new Set<string>();
const syntheticContinueEventTimesBySession = new Map<string, number[]>();
const syntheticContinueLoopLastWarnAtBySession = new Map<string, number>();
const syntheticContinueAutoAbortedSessions = new Set<string>();

const skillPathPattern = /[\\/]\.opencode[\\/](skill|skills)[\\/]/i;
const skillNamePattern = /[\\/]\.opencode[\\/](?:skill|skills)[\\/]+([^\\/]+)/i;
Expand Down Expand Up @@ -432,6 +434,14 @@ export function createSessionStore(options: {
threshold: COMPACTION_LOOP_WARN_THRESHOLD,
windowMs: COMPACTION_DIAGNOSTIC_WINDOW_MS,
});

// Abort the session to break the infinite loop (issue #777).
// Only abort once per session to avoid abort spam.
if (!syntheticContinueAutoAbortedSessions.has(sessionID) && options.abortSession) {
syntheticContinueAutoAbortedSessions.add(sessionID);
sessionWarn("compaction:synthetic-continue-loop:aborting", { sessionID });
void options.abortSession(sessionID);
}
};

const addError = (error: unknown, fallback = "Unknown error") => {
Expand Down