Update CHANGELOG and refactor ConversationAgent to prevent unnecessary stop-sequence injection

This commit is contained in:
vegu-ai-tools
2026-05-13 22:29:46 +03:00
parent 274306dafa
commit 9910100050
3 changed files with 14 additions and 14 deletions

View File

@@ -5,6 +5,7 @@
- "Pydantic Migration: Internal data models across the codebase converted to pydantic for stricter validation. No user-visible behavior changes."
fixes:
- "Game Loop Event: Fixed an internal scene-loop event being constructed with the wrong scene reference, surfaced by the pydantic migration."
- "Conversation Agent: Stopped injecting `#` into the LLM stop-sequence list on every conversation turn. The conversation agent's prompt-parameter hook now only wipes character-name stop sequences when the `inject_character_names_into_stop` setting is disabled, and is a no-op otherwise."
0.37.0:
features:
- "System Prompt Template Variable: Added {{ system_prompt }} template variable for system prompt overrides. Use it to include the default system prompt within a custom override, at both the app and client level."

View File

@@ -539,9 +539,5 @@ class ConversationAgent(MemoryRAGMixin, Agent):
def inject_prompt_paramters(
self, prompt_param: dict, kind: str, agent_function_name: str
):
if (
prompt_param.get("extra_stopping_strings") is None
or not self.inject_character_names_into_stop
):
if not self.inject_character_names_into_stop:
prompt_param["extra_stopping_strings"] = []
prompt_param["extra_stopping_strings"] += ["#"]

View File

@@ -297,13 +297,15 @@ class TestAllowRepetitionBreakAndInject:
conversation.allow_repetition_break("conversation", "build_prompt") is False
)
def test_inject_prompt_parameters_appends_hash(self, conversation_scene):
def test_inject_prompt_parameters_noop_with_inject_enabled_and_empty(
self, conversation_scene
):
_, conversation, _ = conversation_scene
params = {}
conversation.inject_prompt_paramters(params, "conversation", "converse")
# When inject_character_names_into_stop is True (default), the
# function still wraps with extra_stopping_strings = [], then adds "#".
assert params.get("extra_stopping_strings", []) == ["#"]
# When inject_character_names_into_stop is True (default) and no
# stopping strings are present, the function leaves params untouched.
assert "extra_stopping_strings" not in params
def test_inject_prompt_parameters_resets_when_inject_disabled(
self, conversation_scene
@@ -314,22 +316,23 @@ class TestAllowRepetitionBreakAndInject:
].value = False
params = {"extra_stopping_strings": ["EXISTING"]}
conversation.inject_prompt_paramters(params, "conversation", "converse")
# The function resets to [] when inject_character_names_into_stop is
# False, and then appends "#".
assert params["extra_stopping_strings"] == ["#"]
# When inject_character_names_into_stop is False, any stopping
# strings already populated (e.g. character names added by the
# client) are wiped.
assert params["extra_stopping_strings"] == []
def test_inject_prompt_parameters_preserves_existing_with_inject_enabled(
self, conversation_scene
):
_, conversation, _ = conversation_scene
# When inject_character_names_into_stop is True AND extra_stopping_strings
# is already a list, it is preserved (existing list + "#").
# is already populated, it is left untouched.
conversation.actions["generation_override"].config[
"inject_character_names_into_stop"
].value = True
params = {"extra_stopping_strings": ["EXISTING"]}
conversation.inject_prompt_paramters(params, "conversation", "converse")
assert params["extra_stopping_strings"] == ["EXISTING", "#"]
assert params["extra_stopping_strings"] == ["EXISTING"]
# ---------------------------------------------------------------------------