Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

feat(review): pluggable per-model tokenizer for exact token counts

Open
#239 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java

Research direction

Start by reading the implementation of the TokenCounter interface and the per-model configuration introduced by issues #53 and #50. Then inspect langchain4j's built-in estimators for OpenAI, Anthropic, and Gemini and how the budgeter uses them. Done means matching models use their provider estimator, unmatched models fall back to jtokkit, and self-calibration from API token usage continues.

Written by the indexing model from the issue text.

Description

enhancement java

Problem

The large-diff token budgeting (#53) ships with a single jtokkit (OpenAI BPE) encoding as the estimate for all providers, self-calibrated from the usage.prompt_tokens the API echoes back. That's exact for OpenAI models but approximate for others (e.g. DeepSeek/Gemini/Anthropic use different vocabularies). For closer budgeting on non-OpenAI models, make the estimator pluggable.

Proposed (enhancement — jtokkit stays the default)

  • Keep the TokenCounter interface introduced by #53; the default stays jtokkit (OpenAI BPE) for any model without a better estimator.
  • Reuse langchain4j's built-in per-provider token estimators rather than rolling our own — langchain4j already ships estimators for OpenAI, Anthropic, and Gemini. Wire the matching one behind TokenCounter, keyed by the configured model/provider, for better estimates on those specific models.
  • Fall back to jtokkit when no provider estimator matches; the budgeter keeps self-calibrating from usage.prompt_tokens regardless, so estimates only improve.

No conflict with #53

This plugs in behind the same TokenCounter interface #53 introduces — #53 ships jtokkit-default; #239 swaps in the langchain4j per-provider estimator per model. Nothing in #53 changes.

Depends on

#53 — introduces TokenCounter + the jtokkit default + the per-model config surface (#50). Post-v0.3.0 enhancement.

Dominant language
Java
Stars
35
Forks
7
Avg merge
9h 23m
Merged PRs (30d)
154

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from devops-thiago/ThrillhouseBot

All issues in devops-thiago/ThrillhouseBot

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.