fix: resolve interrupt/send message desync in Claude agent
After interrupt(), the SDK query iterator is done and cannot be reused. Previously we cached the dead query, so messages sent after interrupt got no response. Changes: - Clear this.query and this.input after interrupt() completes - Await pending interrupt before calling ensureQuery() in processPrompt - Check for turn supersession after awaiting interrupt - Pass resume: sessionId when creating new query to preserve history - Reduce abort test sleep from 60s to 15s (same coverage, faster) - Add SDK behavior test to verify interrupt() makes query done 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
@@ -545,15 +545,9 @@ export class AgentManager {
|
||||
}
|
||||
|
||||
try {
|
||||
const cancellation = pendingRun.return(
|
||||
undefined as unknown as AgentStreamEvent
|
||||
);
|
||||
void cancellation.catch((error) => {
|
||||
console.error(
|
||||
`[AgentManager] Failed to cancel run for agent ${agentId}:`,
|
||||
error
|
||||
);
|
||||
});
|
||||
// Await the generator's .return() to ensure the finally block runs
|
||||
// and pendingRun is properly cleared before we return.
|
||||
await pendingRun.return(undefined as unknown as AgentStreamEvent);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
|
||||
Reference in New Issue
Block a user