mini-kode icon indicating copy to clipboard operation
mini-kode copied to clipboard

Make custom-provider context budgets account for the stock prompt and tools

Open cenab opened this issue 2 months ago • 0 comments

Mini-Kode's custom OpenAI-compatible endpoint route works at the transport layer, but its stock request can exceed a provider's context limit before the first user turn.

At 4e7f9767e5ca320ce4866a4743d2cc633a6952da, I built the CLI and ran Say Hello in an empty temporary directory with the complete MINIKODE_API_KEY, MINIKODE_BASE_URL, and MINIKODE_MODEL tuple. The request contained the unmodified system prompt and all ten built-in tools. For Tsubasa Fast and Pro, the real API's conservative input estimator counted 32,696–32,698 tokens. Adding the API's default 512-token output budget exceeds either model's 32,768-token context limit. A controlled SSE response decoded successfully, but validating the actual captured request against the real schema and context preflight failed; this is not a successful hosted inference test.

The current implementation has no custom-provider context or output-budget fields in src/config/types.ts. src/agent/executor.ts always sends the stock prompt and all tools, and automatic compression starts at a fixed 115,000 tokens. src/llm/client.ts leaves the output limit unset.

A provider-neutral improvement would make the context/output budget configurable, account for the system prompt and tool descriptions before sending, and provide an explicit way to reduce the initial request for smaller models. Compaction alone cannot fix an oversized initial request. No tool descriptions or capabilities should be silently dropped.

Suggested validation:

  • A custom 32,768-token provider with an explicit output reserve can complete the first ordinary turn using the actual stock request builder.
  • Oversized initial prompts receive a clear local error before HTTP.
  • Conversation compaction uses the configured budget rather than the fixed 128K assumption.
  • Existing defaults and explicit custom-provider credential precedence remain covered.

The same controlled CLI check confirmed that a wrong key returns 401 and that requiring TSUBASA_API_KEY in the shell before setting MINIKODE_API_KEY prevents fallback to unrelated OpenAI or DeepSeek keys. Build and typecheck passed. The untouched source's full suite passed 260 tests, with two failures in PromptInput.test.tsx; no provider integration has been committed.

A maintainer's preferred scope would help keep any follow-up change small.

cenab avatar Sep 28 '26 03:09 cenab