tools.set_conversation_choices module

Structured flavor-choice buttons for normal conversation (non-game).

Stores choice rows in Redis for the Discord send pipeline. Unlike set_game_choices, this does not touch game session state or the game:choices: Redis key.

async tools.set_conversation_choices.run(choices, ctx=None)[source]

Persist non-game flavor choices for the outbound Discord renderer.

Backs the set_conversation_choices tool: it lets the bot attach a few gray secondary buttons under an ordinary chat reply without involving any game session or starting a countdown. Each incoming choice is validated – the list is capped at 10, the emoji is normalized against a unicode-emoji regex (with a fallback so a malformed emoji never blocks the button), and the label is truncated to 70 characters. The cleaned list is then stored as JSON under the per-channel Redis key conversation:choices:{channel_id} with a 300-second TTL; a Redis failure is logged but does not fail the call. The outbound renderer in game_ui/components.py later reads that key (and deletes it after consuming) to draw the buttons, deliberately keeping it separate from the game:choices: key used by set_game_choices.

Registered via this module’s TOOL_NAME / TOOL_DESCRIPTION / TOOL_PARAMETERS metadata and exposed as the module-level run handler; dispatched by name from the inference worker’s tool loop, not called directly elsewhere in the repo.

Parameters:
  • choices (list[dict[str, str]]) – A list of choice dicts, each with an emoji and a label; only the first 10 valid entries are kept.

  • ctx (ToolContext | None) – The active ToolContext supplying channel_id and the Redis client, or None.

Return type:

str

Returns:

A JSON string with success true, the kept choices_count, and an instruction note, or a JSON error object when there is no context, no input, or nothing survives validation.