fix: correct volatile context placement in RAG query generation template

This commit is contained in:
vegu-ai-tools
2026-05-01 13:52:17 +03:00
parent a5808f9de0
commit a05b3fbd33
2 changed files with 19 additions and 4 deletions

View File

@@ -49,6 +49,7 @@
- "Game Loop Actor Iter: Fixed a bug where the `game_loop_actor_iter` event was only firing for player turns, so agents that listen for actor iteration (like passive narration) silently skipped AI turns."
- "OpenRouter: Fixed redundant provider/model list fetches when multiple OpenRouter clients are configured. Concurrent `status()` calls all saw the fetched-flag as still false and each kicked off its own HTTP request; the fetches are now serialized with an asyncio lock and double-checked locking so only one request runs."
- "Character Prompts: Fixed duplicated character description in prompts. When the LLM-generated character sheet contained a `description` attribute (common — the extractor often emits one), it was rendered alongside the standalone description field, repeating the same text twice. Templates that render both now filter `description` out of the sheet (case-insensitive). Affects the dialogue, narrator, director (voice assignment), and creator (dialogue examples, dialogue instructions, character goals, contextual generate) prompt paths."
- "RAG Query Generation: Fixed the analyze-text-and-generate-rag-queries template (used by the long-term memory retrieval flow) ignoring the volatile context placement setting. Dynamic instructions and the passed-in RAG context were always pinned at the top of the prompt, defeating prompt caching even when it was enabled on the client/agent. Volatile pieces are now split out and positioned via volatile_context_placement, matching the rest of the prompt set."
improvements:
- "System Prompt Override Indicators: The system prompt override list now shows a pencil icon next to entries that have an active override, making it easy to see which prompts have been customized."
- "Search Strictness: The distance_mod embedding preset value is now a float (was int) with a range of 0.12.0, allowing both tighter and looser similarity matching. A 'Search Strictness' slider is now available in the Context Database UI, letting users tune search sensitivity on the fly. Changes persist to the active embedding preset immediately."

View File

@@ -10,20 +10,34 @@ Override example:
{% set rendered_context -%}
<|SECTION:CONTEXT|>
{% include "extra-context-static.jinja2" %}
{% include "extra-context-dynamic.jinja2" %}
{% if extra_context %}{% for context in extra_context %}{{ context }}
---
{% endfor %}{% endif %}
<|CLOSE_SECTION|>
{% if include_character_context %}{% include "character-context.jinja2" %}{% endif %}
{% endset %}
{# END RENDERED CONTEXT #}
{# VOLATILE CONTEXT #}
{% set volatile_inner -%}
{% include "extra-context-dynamic.jinja2" %}
{% if extra_context %}{% for context in extra_context %}{{ context }}
---
{% endfor %}{% endif %}
{%- endset %}
{% set volatile_context_text -%}
{% if volatile_inner.strip() %}<|SECTION:DYNAMIC CONTEXT|>
{{ volatile_inner }}
<|CLOSE_SECTION|>
{% endif %}
{%- endset %}
{# END VOLATILE CONTEXT #}
{# RENDER PROMPT #}
{% set volatile_placement = volatile_context_placement() %}
{{ rendered_context }}
{% if volatile_placement != "after_history" %}{{ volatile_context_text }}{% endif %}
<|SECTION:SCENE|>
{{ text }}
<|CLOSE_SECTION|>
{% if volatile_placement == "after_history" %}{{ volatile_context_text }}{% endif %}
<|SECTION:TASK|>
You are assisting with an ongoing story. You have access to a vector database containing factual information about the characters, locations, events, and lore of this narrative world. Your task is to generate up to {{ num_queries }} specific, targeted queries to gather additional context for the current scene or conversation.