Fix #4355: Make session write lock timeout configurable #4371
+127
−34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4355 - Sub-agents terminate prematurely with 'terminated' error due to session write lock timeout.
Problem
The session write lock timeout was hardcoded to 10 seconds in
session-write-lock.ts. When multiple subagents competed for session file locks, they would timeout after 10s, causing the HTTP stream to abort and producing a "terminated" error.Solution
Increased default timeout from 10s to 60s
Added configurable timeout option
sessionWriteLockTimeoutMsto agent defaults config schematimeoutMsChanges
src/config/zod-schema.agent-defaults.ts: Added config optionsrc/agents/session-write-lock.ts: Increased default + added explanatory commentsrc/agents/pi-embedded-runner/run/attempt.ts: Pass config valuesrc/agents/pi-embedded-runner/compact.ts: Pass config valueTesting
npm run lint- passed with 0 errorstimeoutMsstill works)Configuration Example
Users can now configure the timeout in their config file:
{ "agents": { "defaults": { "sessionWriteLockTimeoutMs": 120000 } } }AI-Assisted
This PR was created with assistance from Claude Code (Sonnet 4.5). The fix was identified through analysis of the issue report and codebase exploration.