fix(claude-cli): --resume for continuing turns (reusing --session-id errored on turn 2)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 22:18:13 +10:00
parent c73be6681f
commit 1e8bbca2a5
2 changed files with 11 additions and 1 deletions

View File

@@ -52,6 +52,11 @@ spacesScopedRouter.post('/turn',
const { agent, convo } = await resolveConversation(req.params.space_id);
const { text, view } = req.body;
// Resume the claude session if this conversation already had turns (the CLI
// keys session history by --session-id; first turn creates it, rest --resume).
const priorTurns = (await messages.listByConversation(convo.id)).length;
const resume = priorTurns > 0;
await messages.append(convo.id, { role: 'user', body: text });
res.writeHead(200, {
@@ -105,6 +110,7 @@ spacesScopedRouter.post('/turn',
try {
result = await runClaudeTurn({
sessionId: convo.id,
resume,
systemPrompt: SYSTEM,
userText: text,
mcpConfigPath,