Skip to content

Commit 31dca90

Browse files
committed
fix: consume ACP agent greeting on cold-start before first real prompt
When an acpx session is created or reconnected, the ACP agent (e.g. Claude Code) emits a cold-start greeting ("The model has been set to …") as its first response. This greeting is returned as the result of the first real pipeline prompt, causing stage outputs like goal.md to contain the greeting text instead of actual research content. Add a disposable warm-up prompt ("Respond with OK") in _ensure_session() immediately after session creation. This consumes the greeting so that subsequent chat() calls receive genuine responses. Reproducer: researchclaw run --topic "..." --mode co-pilot → Stage 1 goal.md contains "The model has been set to … How can I help you?" instead of a SMART research goal.
1 parent 08d9d2c commit 31dca90

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

researchclaw/llm/acp_client.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,13 @@ def _abs_cwd(self) -> str:
197197
return os.path.abspath(self.config.cwd)
198198

199199
def _ensure_session(self) -> None:
200-
"""Find or create the named acpx session."""
200+
"""Find or create the named acpx session.
201+
202+
After creating or reconnecting a session, sends a disposable warm-up
203+
prompt. Without this, the agent's cold-start greeting (e.g. "The
204+
model has been set to …") is returned as the response to the first
205+
real prompt, swallowing the actual request.
206+
"""
201207
if self._session_ready:
202208
return
203209
acpx = self._resolve_acpx()
@@ -225,6 +231,20 @@ def _ensure_session(self) -> None:
225231
raise RuntimeError(
226232
f"Failed to create ACP session: {result.stderr.strip()}"
227233
)
234+
235+
# Warm-up: consume the agent's cold-start greeting so it does not
236+
# pollute the first real prompt's response.
237+
try:
238+
subprocess.run(
239+
[acpx, "--approve-all", "--ttl", "0", "--cwd", self._abs_cwd(),
240+
self.config.agent, "-s", self.config.session_name,
241+
"Respond with OK"],
242+
capture_output=True, text=True, encoding="utf-8",
243+
errors="replace", timeout=60,
244+
)
245+
except Exception: # noqa: BLE001
246+
logger.debug("ACP warm-up prompt failed (non-fatal)")
247+
228248
self._session_ready = True
229249
logger.info("ACP session '%s' ready (%s)", self.config.session_name, self.config.agent)
230250

0 commit comments

Comments
 (0)