Skip to content

cli: lean tool catalog exists but is off by default, and MCP server schemas join the prefix unbounded #1856

Description

@macanderson

Problem

Two compounding prefix-size defects:

  1. crates/stella-cli/src/discovery.rs:130-138: lean_from_env gates the 13-tool lean core behind STELLA_LEAN_TOOLS; unset = full ~46-tool catalog (~6k+ tokens of descriptions alone before JSON envelope) at position 0 of every request. The activation machinery (tool_search, ActivatedTools) is built and tested — it is simply not the default.
  2. crates/stella-mcp/src/toolset.rs:501-518: every enabled MCP server's tools are forwarded with description and input_schema uncapped, from a remote server. One chatty MCP server with 50–100 tools can exceed the whole recall+memory+rules budget combined; nothing bounds it.

Fix direction

  • Measure lean-mode's activation rate on the bench corpus before flipping any default (each activation mutates the schema block = one prefix invalidation; the trade is ~70% smaller prefix vs ~4-5 invalidations/session).
  • Cap MCP schema contribution per server (bytes), truncating descriptions with a note, and surface a boot warning when a server blows the cap.

Verify

Witness for the cap: a fake MCP client with a 100KB schema set yields a bounded serialized block plus warning. For lean: bench arm comparison (cache ratio + task success), not just token counts.

Constraints

Schema-block changes invalidate the tools cache tier once per change — batch with other prefix-affecting PRs where possible. Related: #1848 (schema sort), #1837/#1839 (breakpoints/TTL).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Important — next in linearea:clistella-cli — commands, flags, wiring

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions