feat(agent): add per-task session persistence for Claude Code resumption
Store the Claude Code session ID and working directory when a task completes. On the next task for the same (agent, issue) pair, look up the prior session and pass --resume <session_id> to Claude Code so the agent retains conversation context across multiple tasks on the same issue. Changes: - Migration 020: add session_id and work_dir columns to agent_task_queue - CompleteAgentTask stores session_id and work_dir on completion - GetLastTaskSession query retrieves prior session for (agent, issue) - ClaimTaskByRuntime handler populates prior_session_id in response - Daemon passes ResumeSessionID through to Claude backend Execute() - Claude backend adds --resume flag when ResumeSessionID is set
This commit is contained in:
parent
42f72371bd
commit
ffda18c809
13 changed files with 147 additions and 49 deletions
|
|
@ -74,10 +74,18 @@ RETURNING *;
|
|||
|
||||
-- name: CompleteAgentTask :one
|
||||
UPDATE agent_task_queue
|
||||
SET status = 'completed', completed_at = now(), result = $2
|
||||
SET status = 'completed', completed_at = now(), result = $2, session_id = $3, work_dir = $4
|
||||
WHERE id = $1 AND status = 'running'
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetLastTaskSession :one
|
||||
-- Returns the session_id and work_dir from the most recent completed task
|
||||
-- for a given (agent_id, issue_id) pair, used for session resumption.
|
||||
SELECT session_id, work_dir FROM agent_task_queue
|
||||
WHERE agent_id = $1 AND issue_id = $2 AND status = 'completed' AND session_id IS NOT NULL
|
||||
ORDER BY completed_at DESC
|
||||
LIMIT 1;
|
||||
|
||||
-- name: FailAgentTask :one
|
||||
UPDATE agent_task_queue
|
||||
SET status = 'failed', completed_at = now(), error = $2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue