Skip to content

fix(container): multi-turn FIFO persistence - #16

Merged
mariuspruvot merged 1 commit into
mainfrom
worktree-fix+fifo-multi-turn
Apr 18, 2026
Merged

fix(container): multi-turn FIFO persistence#16
mariuspruvot merged 1 commit into
mainfrom
worktree-fix+fifo-multi-turn

Conversation

@mariuspruvot

Copy link
Copy Markdown
Owner

Summary

  • Root cause: --input-format stream-json exits after each conversation turn by design (exit 0, terminal_reason: "completed"). The single long-lived process approach never worked for multi-turn.
  • Fix: Replace with per-turn invocations -- first turn uses claude -p "$PROMPT", subsequent turns read from FIFO and use claude -c -p "$CONTENT" (--continue) to resume with full context from Claude's local session store.
  • Also: Simplify send_message() to write raw content instead of stream-json wrapper; ensure newline-terminated FIFO writes for read compatibility; add write_to_container to FakeDockerClient and 3 new tests for send_message.

Changes

File What
infra/docker/claude-runner/entrypoint.sh Per-turn loop with claude -c -p, signal handling for clean shutdown
apps/api/src/helprs/modules/container/service.py Raw content in send_message(), newline-terminated write_to_container()
apps/api/tests/modules/container/test_service.py write_to_container on FakeDockerClient, 3 new TestSendMessage tests
CLAUDE.md Document multi-turn architecture, updated stream-json protocol notes

Test plan

  • All 31 container service tests pass (including 3 new send_message tests)
  • Full test suite: 226/228 pass, 2 pre-existing failures unrelated to this change
  • Ruff + ESLint clean
  • Manual e2e: start a challenge-me session, answer Q1, verify Claude continues with Q2 instead of exiting

Claude Code CLI in --input-format stream-json mode exits after each turn
by design. Replace the single long-lived process with per-turn invocations:
first turn uses `claude -p`, subsequent turns use `claude -c -p` (--continue)
reading from a FIFO loop. Also simplifies send_message to write raw content
instead of stream-json wrapper, and ensures newline-terminated FIFO writes.
@mariuspruvot
mariuspruvot merged commit e2854c9 into main Apr 18, 2026
8 of 10 checks passed
@mariuspruvot
mariuspruvot deleted the worktree-fix+fifo-multi-turn branch April 18, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant