fix(agents): add error handling to orphaned message cleanup (#2262)
This commit is contained in:
parent
dce7925e2a
commit
2d09f8e615
@ -56,6 +56,7 @@ Status: unreleased.
|
|||||||
- **BREAKING:** Gateway auth mode "none" is removed; gateway now requires token/password (Tailscale Serve identity still allowed).
|
- **BREAKING:** Gateway auth mode "none" is removed; gateway now requires token/password (Tailscale Serve identity still allowed).
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
- Agents: add error handling to orphaned message cleanup to prevent message processing queue from blocking. (#2262)
|
||||||
- Gateway: suppress AbortError and transient network errors in unhandled rejections. (#2451) Thanks @Glucksberg.
|
- Gateway: suppress AbortError and transient network errors in unhandled rejections. (#2451) Thanks @Glucksberg.
|
||||||
- TTS: keep /tts status replies on text-only commands and avoid duplicate block-stream audio. (#2451) Thanks @Glucksberg.
|
- TTS: keep /tts status replies on text-only commands and avoid duplicate block-stream audio. (#2451) Thanks @Glucksberg.
|
||||||
- Security: pin npm overrides to keep tar@7.5.4 for install toolchains.
|
- Security: pin npm overrides to keep tar@7.5.4 for install toolchains.
|
||||||
|
|||||||
@ -713,18 +713,26 @@ export async function runEmbeddedAttempt(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Repair orphaned trailing user messages so new prompts don't violate role ordering.
|
// Repair orphaned trailing user messages so new prompts don't violate role ordering.
|
||||||
const leafEntry = sessionManager.getLeafEntry();
|
try {
|
||||||
if (leafEntry?.type === "message" && leafEntry.message.role === "user") {
|
const leafEntry = sessionManager.getLeafEntry();
|
||||||
if (leafEntry.parentId) {
|
if (leafEntry?.type === "message" && leafEntry.message.role === "user") {
|
||||||
sessionManager.branch(leafEntry.parentId);
|
if (leafEntry.parentId) {
|
||||||
} else {
|
sessionManager.branch(leafEntry.parentId);
|
||||||
sessionManager.resetLeaf();
|
} else {
|
||||||
|
sessionManager.resetLeaf();
|
||||||
|
}
|
||||||
|
const sessionContext = sessionManager.buildSessionContext();
|
||||||
|
activeSession.agent.replaceMessages(sessionContext.messages);
|
||||||
|
log.warn(
|
||||||
|
`Removed orphaned user message to prevent consecutive user turns. ` +
|
||||||
|
`runId=${params.runId} sessionId=${params.sessionId}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const sessionContext = sessionManager.buildSessionContext();
|
} catch (err) {
|
||||||
activeSession.agent.replaceMessages(sessionContext.messages);
|
log.error(
|
||||||
log.warn(
|
`Failed to repair orphaned user message, continuing anyway. ` +
|
||||||
`Removed orphaned user message to prevent consecutive user turns. ` +
|
|
||||||
`runId=${params.runId} sessionId=${params.sessionId}`,
|
`runId=${params.runId} sessionId=${params.sessionId}`,
|
||||||
|
{ error: err instanceof Error ? err.message : String(err) },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user