module

GameTools

Constants

TOOL_NAMES = ["roll_dice", "get_character_stats", "modify_hp", "get_inventory", "add_to_inventory", "remove_from_inventory", "inspect_item", "get_current_room", "move_to_room", "add_companion", "update_companion", "remove_companion", "get_companions", "remember", "get_journal"]

List of all tool names for reference

Class methods

build_tools(state : GameState) : Array(Anthropic::Tool)

Build the array of all game tools for use with Tool Runner.

Prompt caching: the tool schemas never change between turns, so the last tool is tagged with an ephemeral cache breakpoint. This caches the whole tools array server-side, cutting input-token cost and latency on repeat.

Source
create_add_companion_tool(state : GameState) : Anthropic::Tool

Create add companion tool. Locks in a named NPC so its name persists across turns instead of drifting (e.g. an imp familiar summoned once should keep its name for the rest of the adventure).

Source
create_add_inventory_tool(state : GameState) : Anthropic::Tool

Create add to inventory tool

Source
create_get_companions_tool(state : GameState) : Anthropic::Tool

Create get companions tool (read-only).

Source
create_get_inventory_tool(state : GameState) : Anthropic::Tool

Create inventory view tool (read-only)

Source
create_get_journal_tool(state : GameState, cache : Anthropic::CacheControl | Nil = nil) : Anthropic::Tool

Create get journal tool (read-only).

cache enables Anthropic prompt caching on this tool definition. It is set on the LAST tool in the array (see build_tools) so the entire tool set is treated as a single stable cached prefix — every turn sends the same 15 tool schemas, so caching them avoids reprocessing ~2k tokens per request.

Source
create_get_room_tool(state : GameState) : Anthropic::Tool

Create current room tool (read-only)

Source
create_get_stats_tool(state : GameState) : Anthropic::Tool

Create character stats tool (read-only)

Source
create_inspect_item_tool(state : GameState) : Anthropic::Tool

Create inspect item tool (read-only)

Source
create_modify_hp_tool(state : GameState) : Anthropic::Tool

Create HP modification tool

Source
create_move_room_tool(state : GameState) : Anthropic::Tool

Create move to room tool

Source
create_remember_tool(state : GameState) : Anthropic::Tool

Create remember tool — writes a free-form fact to the journal so it persists across turns (NPC names not traveling with you, quest details, world lore, promises, passwords, ...).

Source
create_remove_companion_tool(state : GameState) : Anthropic::Tool

Create remove companion tool.

Source
create_remove_inventory_tool(state : GameState) : Anthropic::Tool

Create remove from inventory tool

Source
create_roll_dice_tool

Create the dice rolling tool

Source
create_update_companion_tool(state : GameState) : Anthropic::Tool

Create update companion tool (rename and/or re-describe).

Source