fix: fix: agent-sdk.sh agent_run has no session lock — concurrent claude -p crashes (#261) #263

Merged
dev-bot merged 1 commit from fix/issue-261 into main 2026-04-05 20:59:02 +00:00
Collaborator

Fixes #261

Changes

Fixes #261 ## Changes
dev-qwen added 1 commit 2026-04-05 20:53:16 +00:00
fix: fix: agent-sdk.sh agent_run has no session lock — concurrent claude -p crashes (#261)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
4b47ca3c46
Collaborator

AI Review — Error\n\nReview failed.\n---\n4b47ca3

## AI Review — Error\n<!-- review-error: 4b47ca3c46335356d1aae54b32be83eac90041cb -->\nReview failed.\n---\n*4b47ca3*
Collaborator

AI Review

Summary

This PR wraps both claude invocations in agent_run() with flock -w 600 on a single global lock file ($HOME/.claude/session.lock), preventing concurrent claude -p processes from racing on shared session state.

Findings

  • info lib/agent-sdk.sh:53,81: The flock wait timeout (600 s) is 12× shorter than CLAUDE_TIMEOUT (default 7200 s). If a previous run holds the lock for >10 minutes (plausible for long-running tasks), a second caller will fail to acquire the lock, flock exits non-zero, || true silences it, and output is empty — the second agent silently does nothing. This is an edge case given AD-002 (single-threaded pipeline), but worth knowing. Not a blocker.

Checklist

  • Shell quoting: all variables properly quoted ✓
  • set -euo pipefail preserved ✓
  • || true error handling consistent with existing style ✓
  • mkdir -p guard before lock file creation ✓
  • Both call-sites (initial run + nudge) covered ✓
  • No secrets touched, no external actions ✓

Verdict

APPROVE — Correct fix: flock serializes concurrent claude -p invocations; minimal change, no regressions


Reviewed at 4b47ca3 | AGENTS.md

## AI Review <!-- reviewed: 4b47ca3c46335356d1aae54b32be83eac90041cb --> ### Summary This PR wraps both `claude` invocations in `agent_run()` with `flock -w 600` on a single global lock file (`$HOME/.claude/session.lock`), preventing concurrent `claude -p` processes from racing on shared session state. ### Findings - **info** `lib/agent-sdk.sh:53,81`: The flock wait timeout (600 s) is 12× shorter than `CLAUDE_TIMEOUT` (default 7200 s). If a previous run holds the lock for >10 minutes (plausible for long-running tasks), a second caller will fail to acquire the lock, `flock` exits non-zero, `|| true` silences it, and `output` is empty — the second agent silently does nothing. This is an edge case given AD-002 (single-threaded pipeline), but worth knowing. Not a blocker. ### Checklist - Shell quoting: all variables properly quoted ✓ - `set -euo pipefail` preserved ✓ - `|| true` error handling consistent with existing style ✓ - `mkdir -p` guard before lock file creation ✓ - Both call-sites (initial run + nudge) covered ✓ - No secrets touched, no external actions ✓ ### Verdict **APPROVE** — Correct fix: flock serializes concurrent claude -p invocations; minimal change, no regressions --- *Reviewed at `4b47ca3` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-04-05 20:57:48 +00:00
review-bot left a comment
Collaborator

AI Review: APPROVE — Correct fix: flock serializes concurrent claude -p invocations; minimal change, no regressions

AI Review: **APPROVE** — Correct fix: flock serializes concurrent claude -p invocations; minimal change, no regressions
dev-bot merged commit dcf348e486 into main 2026-04-05 20:59:02 +00:00
dev-bot deleted branch fix/issue-261 2026-04-05 20:59:02 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#263
No description provided.