[GM Workbench] Random table generator (B3) #147

Closed
opened 2026-07-15 22:02:53 +00:00 by claude-bot · 1 comment
Contributor

Motivation / Context

GMs frequently want a quick dN table for an arbitrary prompt — "complications in the sewers," "what's in the noble's pocket" — the kind of improv aid classic GM toolkits (donjon, random-table books) provide but nothing in Quest Board does today. Per the report's catalog (§3, Group B), this is a commodity generator (table-stakes, not a hosted-service differentiator by itself) but cheap to ship once the tool registry exists, and its output — a reusable document-type lore entry — plugs directly into the existing wiki so tables survive across sessions instead of living in a GM's notes app.

Approach

  • Register a random_table tool in GENERATOR_TOOLS (generation_service.py, #136).
  • Inputs: free-text prompt, optional lore grounding (reuses lore_context from #136's context builders when the GM wants the table to reference specific entries — e.g. "rumors heard at the Salt Griffin," grounded in that tavern's lore entry).
  • Output: a dN table (d6/d12/d20, GM-selectable or inferred from entry count) via generate_structured_text in JSON mode — structured as {die_size, entries: [{roll, text}]}. Small/fast output → runs inline (sync_allowed=True), same pattern as names.
  • Output landing: written to GenerationResult (scratch, #138) by default; "Save as lore entry" creates a LoreEntry with LoreType.document (per §3's "Output lands" column) so tables are browsable and reusable at the table via the wiki, rendered as a markdown table in body.
  • Frontend: minimal form (prompt input, optional lore picker, die-size select) + result card rendering the table, following the same lightweight-panel approach as issue 4 (#141) pending the full workbench UI (#153).

Dependencies

  • #134 (LLM core), #136 (workbench endpoint + tool registry + context builders), #138 (scratchpad) — Phase 0 foundation, per the report's 1→2→3 chain.

Out of scope

  • Weighted/nested table rolling logic (e.g. roll-a-table-that-points-to-another-table) — single flat dN table only.
  • In-app dice rolling / roll simulation — the table is generated text; rolling against it is a GM/VTT action outside this tool's scope.
  • Loot tables specifically — covered by the dedicated loot parcel generator (A4, #149), which has structured item/value fields the generic table tool does not.

Acceptance criteria

  • random_table tool registered and reachable via POST /api/campaigns/{campaign_id}/workbench/random_table/generate, GM-only.
  • Given a free-text prompt, returns a dN table with the correct number of entries for the chosen die size (e.g. d6 → 6 entries).
  • Optional lore grounding visibly influences table content when provided.
  • Result appears in GenerationResult history.
  • "Save as lore entry" creates a LoreEntry with entry_type=document containing the table.
## Motivation / Context GMs frequently want a quick dN table for an arbitrary prompt — "complications in the sewers," "what's in the noble's pocket" — the kind of improv aid classic GM toolkits (donjon, random-table books) provide but nothing in Quest Board does today. Per the report's catalog (§3, Group B), this is a commodity generator (table-stakes, not a hosted-service differentiator by itself) but cheap to ship once the tool registry exists, and its output — a reusable `document`-type lore entry — plugs directly into the existing wiki so tables survive across sessions instead of living in a GM's notes app. ## Approach - Register a `random_table` tool in `GENERATOR_TOOLS` (`generation_service.py`, #136). - **Inputs**: free-text prompt, optional lore grounding (reuses `lore_context` from #136's context builders when the GM wants the table to reference specific entries — e.g. "rumors heard at the Salt Griffin," grounded in that tavern's lore entry). - **Output**: a dN table (d6/d12/d20, GM-selectable or inferred from entry count) via `generate_structured_text` in JSON mode — structured as `{die_size, entries: [{roll, text}]}`. Small/fast output → runs inline (`sync_allowed=True`), same pattern as names. - **Output landing**: written to `GenerationResult` (scratch, #138) by default; **"Save as lore entry"** creates a `LoreEntry` with `LoreType.document` (per §3's "Output lands" column) so tables are browsable and reusable at the table via the wiki, rendered as a markdown table in `body`. - Frontend: minimal form (prompt input, optional lore picker, die-size select) + result card rendering the table, following the same lightweight-panel approach as issue 4 (#141) pending the full workbench UI (**#153**). ## Dependencies - **#134** (LLM core), **#136** (workbench endpoint + tool registry + context builders), **#138** (scratchpad) — Phase 0 foundation, per the report's 1→2→3 chain. ## Out of scope - Weighted/nested table rolling logic (e.g. roll-a-table-that-points-to-another-table) — single flat dN table only. - In-app dice rolling / roll simulation — the table is generated text; rolling against it is a GM/VTT action outside this tool's scope. - Loot tables specifically — covered by the dedicated loot parcel generator (A4, #149), which has structured item/value fields the generic table tool does not. ## Acceptance criteria - `random_table` tool registered and reachable via `POST /api/campaigns/{campaign_id}/workbench/random_table/generate`, GM-only. - Given a free-text prompt, returns a dN table with the correct number of entries for the chosen die size (e.g. d6 → 6 entries). - Optional lore grounding visibly influences table content when provided. - Result appears in `GenerationResult` history. - "Save as lore entry" creates a `LoreEntry` with `entry_type=document` containing the table.
Author
Contributor

Done — merged to feat/v3.10-gm-workbench via PR #220 (batched with #144 + #149).

random_table tool registered on the #136 engine: a d6/d12/d20 roll table for any prompt (die size restricted to 6/12/20), optionally lore-grounded, persisting a GenerationResult (#138). Frontend RandomTableGenerator renders the table and reuses the shared WorkbenchResultActions bar — "Save as lore entry" with entry_type=document and a rendered markdown table as the body. Tolerant parser renumbers rolls 1..n and truncates to die size. No new API/models/migrations.

Verified: backend 712 passed (incl. test_workbench_random_table.py), frontend 372 passed, ruff + eslint clean.

Done — merged to `feat/v3.10-gm-workbench` via PR #220 (batched with #144 + #149). `random_table` tool registered on the #136 engine: a d6/d12/d20 roll table for any prompt (die size restricted to 6/12/20), optionally lore-grounded, persisting a `GenerationResult` (#138). Frontend `RandomTableGenerator` renders the table and reuses the shared `WorkbenchResultActions` bar — **"Save as lore entry"** with `entry_type=document` and a rendered markdown table as the body. Tolerant parser renumbers rolls 1..n and truncates to die size. No new API/models/migrations. Verified: backend 712 passed (incl. `test_workbench_random_table.py`), frontend 372 passed, ruff + eslint clean.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/Quest-Board#147
No description provided.