feat(backend): system-aware LLM prompt context (#137) #208
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/137-system-aware-prompts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Backend issue of the v3.9.0 Game-Aware Systems pillar. Targets the integration branch. Builds on #133.
Closes #137.
What
Replaces the bare free-text
game_systeminterpolation in LLM prompts with the linked registry system'sprompt_hintwhen a campaign is linked — richer, consistent system context for the model — while free-form/unlinked campaigns keep byte-identical prompts.game_system_service.resolve_system_prompt_context(db, campaign): unlinked → rawcampaign.game_system(unchanged); linked → the system'sprompt_hint(elseshort_name). Usessqlalchemy.inspect().unloadedto check the relationship is loaded before touching it (avoids asyncMissingGreenlet), falling back to a DB fetch.summarise()←process_audio(reminder_tasks) + canonical-name re-summarise (sessions).generate_name_options()gains asystem_keyparam + a per-system_NAME_CATEGORY_DESCRIPTION_HINTS_BY_SYSTEMoverride map (pf2e player_character/npc use ancestry/heritage/class terminology); wired through the session route, the planning cache, and the prefetch task. The prefetch task now resolves context inside itstask_session()block (eager-loadinggame_system_ref) and capturessystem_keyas a plain string before the session closes.lore_service), preserving the'Unknown'fallback.Verification (Docker, py3.12)
test_system_aware_prompts.py) — no regressions. Coverage: linked-dnd5e prompts contain theprompt_hint; free-form campaigns yield the unchanged legacy string; the pf2e per-category override fires only when linked.Follow-ups flagged (out of scope here)
game_systemprompt sites remain: the NPC-fleshout backstory/statblock prompts (reminder_tasks.py, which #142 touches next) andgenerate_session_title_suggestions. Left for #142 / a small follow-up rather than widened here.BOT_CONTRACT_VERSIONstays 1.🤖 Generated with Claude Code