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

tj context shows unweighted re-read shares and names ended sessions as action items

Open
#593 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Read tokenjam/cli/cmd_context.py and tokenjam/cli/cmd_tokenmaxx.py at the cited lines, then inspect the quota-weighted properties in tokenjam/core/context_diagnostic.py. Find the relevant CLI tests and check how they verify the displayed shares and reclaim advice. Done means both commands use quota-weighted headline shares and show only aggregate reclaim guidance, without naming ended sessions.

Written by the indexing model from the issue text.

Description

bug help wanted

Problem

tj context (cli/cmd_context.py) has two defects that a sibling command already fixed for itself.

1. Raw, unweighted re-read shares. cmd_context.py:137 and :218 render diag.reread_share / c.reread_share directly — a raw ratio of re-read tokens to total tokens. Cache-read tokens are billed (and rate-limited) well below a fresh input token, so a raw token-count ratio overstates how much of a user's actual quota re-reading consumes. ContextDiagnostic already exposes a quota-weighted version of the same figure: quota_weighted_reread_share (core/context_diagnostic.py:389) and quota_weighted_work_share (core/context_diagnostic.py:403), both computed from the per-turn TurnComposition.quota_weighted_reread_share (core/context_diagnostic.py:267). cmd_context.py doesn't read either property. Neither does cmd_tokenmaxx.py, which also renders the raw diag.reread_share (cli/cmd_tokenmaxx.py:111).

2. A reclaim list that names already-ended sessions. cmd_context.py:214-225 lists up to three individual compact_candidates by session id ("session <id> — X% re-read... → /compact mid-session... to reclaim that quota"). compact_candidates is built by _compact_candidates() (core/context_diagnostic.py:825), which groups TurnComposition rows by session_id over the full queried window (turns = load_turn_compositions(conn, since, until, agent_id) at core/context_diagnostic.py:567) — it has no concept of "still active." So the printed advice to run /compact "mid-session" routinely names sessions that have already ended, which is not actionable: a closed session can't be compacted.

Expected

  • tj context and tj tokenmaxx render the quota-weighted shares (quota_weighted_reread_share / quota_weighted_work_share) as their headline percentages, the same way another command in this codebase already does. Raw token-ratio shares may still be shown, but only under an explicit "raw tokens" label if kept for debugging — never presented as the quota share.
  • The reclaim section stops naming individual past sessions. It should report an aggregate instead (how many of the analyzed sessions crossed the compact threshold, and what share of the window's re-read tokens they represent), with a note that only the live session is actually actionable.

Where to look

  • tokenjam/cli/cmd_context.py:137 and :218 — raw reread_share reads
  • tokenjam/cli/cmd_context.py:214-225 — the per-session reclaim list
  • tokenjam/cli/cmd_tokenmaxx.py:111 — raw diag.reread_share read
  • tokenjam/core/context_diagnostic.py:267,389,403 — the existing quota-weighted properties to reuse
  • tokenjam/core/context_diagnostic.py:825 — _compact_candidates(), which has no "still live" filter

Done when

  • No default tj context or tj tokenmaxx output presents a raw token ratio as a quota share.
  • Neither command's default output names an individual ended session as something to act on; the reclaim message is aggregate-only.
Dominant language
Python
Stars
122
Forks
35
Avg merge
1d 18h
Merged PRs (30d)
8

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 Metabuilder-Labs/tokenjam

All issues in Metabuilder-Labs/tokenjam

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.