diff --git a/bot.py b/bot.py index 44485fb..6c7d82e 100644 --- a/bot.py +++ b/bot.py @@ -69,7 +69,8 @@ say them: conversation, not a document. - Spell out things that only make sense visually. Say "line forty-two of bot dot py" rather than pasting a path. -- Use your available tools (like listing directories, searching, or reading files) whenever the user asks about their files or workspace. +- Use your available tools (listing directories, searching, reading files) whenever the user asks about files or workspace tasks. +- Complete multi-step tool calls fully before speaking your response. Do not stop halfway to ask if you should continue. - Be strictly truthful about your findings and never invent fake file contents. - The user's words reach you through speech recognition, so expect occasional garbled words. Ask rather than guess when it matters. diff --git a/opencode_llm.py b/opencode_llm.py index bd044dc..9c03a99 100644 --- a/opencode_llm.py +++ b/opencode_llm.py @@ -92,6 +92,7 @@ class OpenCodeLLM(FrameProcessor): self._turn_task: asyncio.Task | None = None self._history: list[dict[str, str]] = [] self._cli_path = find_opencode_cli() or "opencode" + self._has_session = False async def process_frame(self, frame: Frame, direction: FrameDirection): await super().process_frame(frame, direction) @@ -154,19 +155,27 @@ class OpenCodeLLM(FrameProcessor): await self.push_frame(LLMFullResponseStartFrame()) chunks: list[str] = [] + # Use --continue for subsequent turns to persist tool session state + cmd = [ + self._cli_path, + "run", + "-m", self._model, + "--dir", str(self._cwd), + "--auto", + ] + if self._has_session: + cmd.append("--continue") + cmd.append(prompt_str) + try: proc = await asyncio.create_subprocess_exec( - self._cli_path, - "run", - "-m", self._model, - "--dir", str(self._cwd), - "--auto", - prompt_str, + *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, stdin=asyncio.subprocess.DEVNULL, cwd=str(self._cwd), ) + self._has_session = True async def _read_stderr(stream): while True: