fix: cap agent abort and disconnect partial saves to the parent expiry

The agents /chat/abort endpoint and the resumable disconnect handler save a
partial response through saveMessage without saveConvo following, but did not
pass capExpiryToConversation. In an ephemeral deployment with a parent that
already has an earlier active expiredAt, the partial response got a freshly
computed later deadline and outlived its conversation.

Pass the same cap metadata used by the other message-only abort path so the
partial response cannot outlive its parent. If generation later completes, the
normal response-end save re-stamps the message with a fresh deadline.
This commit is contained in:
Marco Beretta 2026-06-22 09:58:55 +02:00
parent 7ff0b73511
commit 571de8c3db
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
3 changed files with 9 additions and 2 deletions

View file

@ -335,7 +335,10 @@ const ResumableAgentController = async (req, res, next, initializeClient, addTit
interfaceConfig: req?.config?.interfaceConfig,
},
partialMessage,
{ context: 'api/server/controllers/agents/request.js - partial response on disconnect' },
{
context: 'api/server/controllers/agents/request.js - partial response on disconnect',
capExpiryToConversation: true,
},
);
logger.debug(

View file

@ -289,6 +289,7 @@ describe('Agent Abort Endpoint', () => {
}),
expect.objectContaining({
context: 'api/server/routes/agents/index.js - abort endpoint',
capExpiryToConversation: true,
}),
);
});

View file

@ -347,7 +347,10 @@ router.post('/chat/abort', configMiddleware, async (req, res) => {
interfaceConfig: req?.config?.interfaceConfig,
},
responseMessage,
{ context: 'api/server/routes/agents/index.js - abort endpoint' },
{
context: 'api/server/routes/agents/index.js - abort endpoint',
capExpiryToConversation: true,
},
);
logger.debug(`[AgentStream] Saved partial response for: ${jobStreamId}`);
} catch (saveError) {