Skip to content

Commit 81159b4

Browse files
committed
fix: Also skip INITIAL_PROMPT for continuation sessions
When PARENT_SESSION_ID is set, this is a child session continuing from a parent - skip the initial prompt since the conversation already has context from the parent session.
1 parent 0ad3263 commit 81159b4

File tree

1 file changed

+8
-4
lines changed
  • components/runners/claude-code-runner

1 file changed

+8
-4
lines changed

components/runners/claude-code-runner/main.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,19 @@ async def lifespan(app: FastAPI):
9898

9999
logger.info("Adapter initialized - fresh client will be created for each run")
100100

101-
# Check if this is a restart/resume (initial prompt was already sent)
102-
# We use our own marker file since Claude SDK's internal state location varies
101+
# Check if this is a restart/resume or continuation
102+
# - Marker file: session was already initialized (resume)
103+
# - Parent session ID: this is a child session continuing from parent
103104
initial_prompt_marker = Path(workspace_path) / ".initial_prompt_sent"
105+
parent_session_id = os.getenv("PARENT_SESSION_ID", "").strip()
104106

105-
# Check for INITIAL_PROMPT and auto-execute (only if this is first run)
107+
# Check for INITIAL_PROMPT and auto-execute (only if this is a fresh start)
106108
initial_prompt = os.getenv("INITIAL_PROMPT", "").strip()
107-
if initial_prompt and not initial_prompt_marker.exists():
109+
if initial_prompt and not initial_prompt_marker.exists() and not parent_session_id:
108110
logger.info(f"INITIAL_PROMPT detected ({len(initial_prompt)} chars), will auto-execute after 3s delay")
109111
asyncio.create_task(auto_execute_initial_prompt(initial_prompt, session_id, initial_prompt_marker))
112+
elif initial_prompt and parent_session_id:
113+
logger.info(f"INITIAL_PROMPT detected but this is a continuation (parent={parent_session_id[:12]}...) - skipping")
110114
elif initial_prompt:
111115
logger.info(f"INITIAL_PROMPT detected but marker exists - skipping auto-execution (session resume)")
112116

0 commit comments

Comments
 (0)