[Game Systems] System-aware LLM prompt context #137
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Motivation/Context
Every LLM feature that references the game system today does the same shallow thing:
append the raw free-text string to the campaign name. This gives the model no real
context about the system's conventions, and static category hints (e.g. "class or
role") assume D&D-ish vocabulary regardless of what's actually being played. With the
GameSystemregistry (#133) storing a curatedprompt_hintper system, prompts cangive the model real, consistent context instead of a bare string — while free-form
campaigns keep exactly today's behaviour (registry hint is simply absent).
Approach
Replace the bare
(game_system)string interpolation with the registry'sprompt_hint(falling back to today's raw-string behaviour when the campaign has nogame_system_id) in each of these call sites:summarise(transcript, campaign_name, game_system, …)builds
context = campaign_name + (f" ({game_system})" if game_system else "")atwebapp/backend/app/services/audio_service.py:436-454. Swap in the resolvedprompt_hintwhen a system is linked. Called from the audio pipeline Celery task(
webapp/backend/app/tasks/reminder_tasks.py:1539,1618-1628) and the canonical-namere-summarise path (
webapp/backend/app/routers/sessions.py:303-311).generate_name_options(…, game_system, …)uses the identicalinterpolation (
audio_service.py:759-780). The static, system-agnostic_NAME_CATEGORY_DESCRIPTION_HINTSdict (audio_service.py:163-218) gains optionalper-system overrides — e.g. a pf2e
player_characterhint mentionsancestry/heritage/class instead of the generic "class or role" phrasing. Callers:
session-scoped generator (
routers/sessions.py:251-260), campaign planning cache(
routers/campaigns.py:3129-3137), and the prefetch Celery task(
webapp/backend/app/tasks/planning_tasks.py:72-84).f"Game system: {campaign.game_system or 'Unknown'}"—lore_service.py:720. Swap inthe resolved system name/hint the same way.
Use the resolution helper from #133 to get the effective display string/hint per
campaign; no call site should read
campaign.game_systemdirectly once this lands —they go through the helper so free-form and linked campaigns are handled uniformly.
Free-form campaigns (
game_system_id IS NULL) keep today's exact prompt text — this ispurely additive richness for linked campaigns, not a rewrite of the free-text path.
Dependencies
prompt_hinton registryrows and the resolution helper this issue calls into.
Out of scope
statsJSONB storage, orgenerate_structured_text/json_modeusagefor stat blocks — that's issue 4 and issue 6 (the #130 upgrade).
answer_question) — it doesn't usegame_systemtoday(
audio_service.py:926-934) and this issue doesn't add it.prompt_hintcopy for dnd5e/pf2e beyond a reasonablefirst draft — can be refined post-ship without further migration.
Acceptance criteria
summarise,generate_name_options, and the lore-extraction prompt all consume theregistry
prompt_hint(via the resolution helper) when the campaign has a linkedsystem, and fall back to today's raw-string behaviour when it doesn't.
_NAME_CATEGORY_DESCRIPTION_HINTSsupports a per-system override path withoutbreaking the existing generic hints for free-form/unlinked campaigns.
game_system_id IS NULL— verified byexisting tests continuing to pass unmodified.
hint; a free-form campaign produces the unchanged legacy prompt string.
beyond what the resolution helper already provides.
claude-bot referenced this issue2026-07-15 22:01:33 +00:00
Picking this up on
feat/137-system-aware-prompts(PR to target thefeat/v3.9-game-aware-systemsintegration branch), in parallel with #140.Approach: a new
game_system_service.resolve_system_prompt_context(db, campaign)that returns the linked system'sprompt_hint(from #133's registry) when linked, else the raw free-textgame_system— wired intosummarise,generate_name_options(+ optional per-system_NAME_CATEGORY_DESCRIPTION_HINTSoverrides), and the lore-extraction prompt. Free-form/unlinked campaigns keep byte-identical prompts (existing tests unmodified). No bot API change.Done and verified — merged into the integration branch via PR #208.
Verification (Docker, py3.12): full backend suite 632 passed (+14 new in
test_system_aware_prompts.py), no regressions. Confirmed: linked-dnd5e campaigns get the registryprompt_hintinsummarise/generate_name_options/ lore-extraction prompts; free-form campaigns produce byte-identical legacy prompts; the pf2e per-category name-hint override fires only when linked.Delivered:
resolve_system_prompt_context(db, campaign)helper (safe async relationship handling viainspect().unloaded), wired into the named call sites;generate_name_optionsper-system category-hint overrides; a real db-lifecycle fix in the name-prefetch task (resolve context inside thetask_session()block, capturesystem_keyas a string before the session closes).Follow-up flagged: two more raw-
game_systemprompt sites (NPC-fleshout backstory/statblock, which #142 touches next; andgenerate_session_title_suggestions) — left out of this issue's named scope, tracked for #142 / a small follow-up.Closing; ships to
mainwith the v3.9.0 release.