From e97db7f5b76fceb0832e30ceba286037839fa978 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Tue, 30 Jun 2026 22:27:13 +0200 Subject: [PATCH] Action rejection capability --- tools/engine.py | 4 ++-- tools/run.py | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/engine.py b/tools/engine.py index 9d332be..3a8a4ef 100644 --- a/tools/engine.py +++ b/tools/engine.py @@ -57,9 +57,9 @@ class GameEngine: else: state.append_llm_log(f"\n[VALIDATION REJECTED] {reason}") return TurnResult( - book_log=f"", + book_log="", log_entry=f"You can't do that — {reason}.", - user_prompt=auto_prompt(""), + user_prompt=f"*Your action \"{player_action}\" was rejected: {reason}*", ) system = build_system_prompt() diff --git a/tools/run.py b/tools/run.py index 461cf3e..5096d1f 100755 --- a/tools/run.py +++ b/tools/run.py @@ -204,6 +204,7 @@ class ChaosTUI(App): self._settings_loaded = True def _begin_game(self): + self._last_narrative: str = "" if LAST_PROMPT_PATH.exists(): saved = LAST_PROMPT_PATH.read_text().strip() if saved: @@ -446,11 +447,19 @@ class ChaosTUI(App): if result.book_log: state.archive_turn(result.book_log) state.apply_state(result) - self._display_scene(result) - if result.user_prompt: - LAST_PROMPT_PATH.write_text(result.user_prompt.strip()) - self._last_prompt = result.user_prompt - self._last_result = result + if result.book_log or not result.user_prompt: + self._display_scene(result) + else: + if self._last_narrative: + self._set_narrative(f"{self._last_narrative}\n\n---\n\n{result.user_prompt}") + self._enable_input() + else: + self._display_scene(result) + if result.book_log: + self._last_result = result + if result.user_prompt: + LAST_PROMPT_PATH.write_text(result.user_prompt.strip()) + self._last_prompt = result.user_prompt self._append_debug("✔ turn complete") def _on_generation_error(self, error: Exception, traceback_str: str) -> None: @@ -481,6 +490,7 @@ class ChaosTUI(App): inp.focus() def _set_narrative(self, text: str) -> None: + self._last_narrative = text self.query_one("#play-narrative", Static).update(RichMarkdown(text)) self.query_one("#play-scroll", VerticalScroll).scroll_home(animate=False)