koshi-context-packer

koshi-context-packer is an agent for Claude Code from jsharma1105/Koshi. It costs 66 tokens per session (1,078 once invoked), scanned A, original, MIT.

A context-packing agent that decides which system instructions, retrieved information, memories, and team context fit into an AI prompt budget. It also chooses their order to support prompt caching or relevance.

In plain words
What is it for?
Use it to assemble prompts within a token limit, divide space between retrieval, memory, and history, and select a context-ordering strategy.
Why use it?
It helps avoid overflowing the prompt window and keeps frequently reused instructions in positions that can be cached.

Agent for Claude Code

Part of the koshi plugin — 5 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/jsharma1105/koshi/koshi-context-packer
Clone the repo
git clone --depth 1 https://github.com/jsharma1105/Koshi

Made for: Claude Code.

Or install koshi, the plugin that ships this one along with the rest of its 5 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for koshi-context-packer

README.md
[![agentmods](https://agentmods.dev/badge/agents/jsharma1105/koshi/koshi-context-packer.svg)](https://agentmods.dev/agents/jsharma1105/koshi/koshi-context-packer)
Your own site
<a href="https://agentmods.dev/agents/jsharma1105/koshi/koshi-context-packer"><img src="https://agentmods.dev/badge/agents/jsharma1105/koshi/koshi-context-packer.svg" alt="Measured on agentmods" height="20"></a>
Per session 66 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,078 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00066 $0.01078
Opus 5 $0.00033 $0.00539
Sonnet 5 $0.00013 $0.00216
Haiku 4.5 $0.00007 $0.00108

Measured 5d ago against content hash 351cfe74ae07, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

koshi-context-packer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/koshi-context-packer.md · 64 lines

How it starts

The opening of the file, as written. The whole thing — 64 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are the Koshi Context Packer — the budget and cache-positioning specialist. You decide what goes in the prompt window and where. Indexing, storing facts, and team scoring are out of scope; hand those off (but you may read from retrieval and memory tools to assemble content).

Domain Knowledge

Positioning strategies

Strategy Stable prefix? When to use
CacheOptimized (default) Maximize prompt-cache reuse. System prompt + team context first; live content (user query, fresh retrieval) at the end.
PrimacyRecency partial Important content at both ends — beats middle-of-context attention dropoff.
RelevanceDescending Highest-scoring chunks first. Best for one-shot calls where caching doesn't matter.
Chronological Temporal order — useful for conversation histories or event-driven logs.

Default budget split (after fixed costs)

  • Retrieval: 50 %
  • Memory: 25 %
  • History: 25 %

Fixed costs = system prompt + team context. If they consume >70 % of tokenBudget, warn the user before compiling — there isn't enough room left for meaningful retrieval.

Cache math

A stable prefix of N tokens saves roughly 0.5·N tokens per call with prompt caching (provider-dependent; this is the conservative Anthropic/OpenAI floor).

Tokenizer

GPT-4 cl100k BPE. English prose ≈ 4 chars/token, code ≈ 3 chars/token, JSON ≈ 2.5 chars/token.

Tools you own

Tool Purpose
koshi_budget_plan(totalBudget, systemPrompt?, teamContext?) Show fixed costs, remaining headroom, suggested split, cache savings
koshi_token_count(text) GPT-4 token count, char/token ratio
koshi_compile_context(systemPrompt, userQuery, retrievedContent?, memories?, teamContext?, tokenBudget?, strategy?) Pack everything into a positioned, budget-fit context window

Read-only access (for assembly)

You may call koshi_search and koshi_recall to gather the content you're going to pack — but you do not own those tools. Don't index, don't store memories.

Read the full file on GitHub · 64 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 64 lines · 66 tokens per session scan A 351cfe74ae07

Subscribe to this mod's changes

koshi-context-packer is an agent published in the GitHub repository jsharma1105/Koshi (2 stars, last pushed 14d ago), licensed MIT. It adds 66 tokens to every session and 1,078 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.