TouhouLittleMaid Agent Tweaks

Quick rating

Community listing page, reviews may not be monitored by the author.

TouhouLittleMaid Agent Tweaks

No reviews yet

A mod that enhances and expands the Agent features for the Touhou Little Maid Mod.

Mod Loaders
Minecraft

About

Description

TLM Agent Tweaks

An add-on for Touhou Little Maid that enhances its AI features with multiple API protocols / reasoning display / request retries / token and cost statistics.

Features

  • Multiple API protocols: Touhou Little Maid originally supports only OpenAI Chat Completions. This mod additionally supports OpenAI Responses and Anthropic Messages, with a protocol setting for each model site
  • Reasoning display: Supports scrolling the model's reasoning inside the "The maid is thinking…" bubble, switching back to tool-call hints while tools are running
  • Automatic request retries: Automatically retries rate-limited requests and certain server errors, with status messages shown in the bubble while waiting
  • Streaming request support: Supports streaming requests to models. If a site does not support streaming or a stream is interrupted, the mod can automatically send a non-streaming request to retrieve the result
  • Manual chat history compression: Touhou Little Maid originally supports only automatic compression. This mod lets you generate a history summary from the chat history screen while retaining recent conversations. A minimum token threshold can be set to avoid extra usage from frequent compression
  • Detailed token statistics: Tracks input, output, cache read, and cache write tokens separately, with per-player views and a server overview
  • Cost statistics: Set model prices for each site and calculate costs from token usage, with support for CNY and USD
  • Charts and player rankings: View player usage rankings, individual player details, and server-wide usage and cost trends over a selected time range

Requirements

Loader Minecraft Java Touhou Little Maid
NeoForge 1.21.1 21 1.5.3
Forge 1.20.1 17 1.5.3

Install the file that matches your Minecraft version and mod loader.

Cloth Config is an optional dependency that adds the Agent Tweaks configuration section to Touhou Little Maid's settings.

Installation

  1. Install the matching version of Touhou Little Maid and its required dependencies
  2. Place the matching jar for this mod in the mods folder
  3. Configure an available AI site and model in Touhou Little Maid

For single-player, install the mod normally. Multiplayer installation requirements are as follows:

Server Client Behavior
Installed Installed All features are available
Installed Not installed The player can join normally. Server-side request enhancements and statistics remain active, but the player cannot see this mod's buttons, statistics screens, or reasoning display
Not installed Installed The player cannot join; the client reports that the server is missing this mod

Usage

Configure the site protocol

Open Touhou Little Maid's LLM site editor and click "Protocol Settings" to the right of the URL field:

  • Chat Completions: Uses an OpenAI Chat Completions-compatible API
  • Responses: Uses the OpenAI Responses API
  • Anthropic Messages: Uses the Anthropic Messages API

There are two URL modes:

  • Base URL: The mod appends the API path for the selected protocol
  • Exact endpoint: Uses the complete request URL exactly as entered

The screen previews the final request URL for checking. Choose the protocol according to the API your provider actually offers; it is not detected automatically.

Per-player settings

Open the maid's AI chat input screen while looking at her (usually by pressing T), then click the 🧩 button on the left to open Agent Tweaks settings:

  • Show Thinking: On by default. Only affects the bubbles you see; it does not change model requests or affect other players
  • Token Stats: Opens the statistics screen; administrator permission is required

Reasoning display requires the model and site to actually return displayable reasoning content. It only changes the "The maid is thinking…" bubble. Reasoning is not written to chat history or sent to TTS, and the final answer's existing presentation is unchanged.

Manually compress chat history

Open the maid's chat history screen and click "Compress History" above "Clear History Chat":

  • Only the maid's owner can start compression
  • Summarizes older conversations to reduce context length
  • By default, the previous conversation's usage must reach the 8K-token threshold (adjustable by administrators), and there must be enough history to compress
  • Another compression cannot be started while one is running; the summary and history refresh when it finishes

Compression calls the model and consumes tokens. This is an additional manual option, not a replacement for Touhou Little Maid's original automatic compression.

Token and cost statistics

Go to Agent Tweaks settings → Token Stats:

  • Ranking: View usage by player, with different colors for the four token categories
  • Player: View detailed usage, cache hit rate, and costs; switch players with the dropdown
  • Server: View usage bar charts and cost trends for the selected time range

Usage is attributed to the maid's owner. Requests initiated by maids, such as self-talk and maid-to-maid chats, are also counted under their owner.

Viewing statistics and setting model prices requires OP permission level 2 by default. Administrators can change this requirement.

Set model prices

In the LLM site editor, click the price button on the corresponding model's row:

  • Enter separate prices for input, output, cache read, and cache write tokens
  • Prices are per million tokens
  • CNY and USD are configured independently, with no automatic exchange-rate conversion
  • Prices are saved separately for each site and model, so the same model can have different prices on different sites

Costs are for reference and estimation only; actual usage and charges are determined by the service provider.

  • Prices must be entered manually and are not fetched automatically
  • Historical costs are calculated using the current prices at query time; changing prices also changes the displayed historical costs
  • Usage depends on data returned by the API. Missing usage is not estimated, and actual charges from failed or interrupted requests may not be fully recorded

Global configuration

With Cloth Config installed, open the AI features → Agent Tweaks section in Touhou Little Maid's settings to adjust:

  • Manual Compress Threshold: 8K tokens by default
  • Enable token statistics: On by default
  • Stats view permission level: OP level 2 by default
  • Count summary requests in stats: On by default; includes usage from chat history compression summaries

Automatic retries and streaming fallback

Automatic retries are enabled by default:

  • For 429, 500, 502, 503, and 504, each request can be retried up to 2 additional times
  • Each retry waits 5 seconds first; site queuing may delay the actual send further
  • If a streaming request fails before response headers arrive, it has one additional chance to be resent as a streaming request
  • If the site explicitly does not support streaming, the stream is interrupted, or the streaming resend still fails, the request can be sent once more in non-streaming mode
  • A conversation and all of its tool-call continuations share a 240-second total time limit, rather than waiting indefinitely

Retries and fallbacks send new requests to the site, may incur additional charges, and are not guaranteed to succeed.

Compatibility with other Mods

TLM Self-Talk

  • Neither mod requires the other; they can be installed independently
  • When both are installed, Self-Talk's self-talk and maid-to-maid chat requests can also use this mod's protocol adaptation, request enhancements, and token statistics
  • Versions supporting unified navigation can switch between the two independent settings pages; other versions retain separate entry buttons
  • Self-talk, welcome greetings, maid-to-maid chats, and their prompts remain managed by Self-Talk

TLM MIMO-TTS

Can be used alongside the MiMo TTS add-on. This mod handles LLM requests and related display features; it does not replace MiMo TTS's speech synthesis.

License

MIT