Docs: `tools_enabled` schema says it overrides `tool_profile`, but `tool_profile` takes precedence (inverted); also stale minimal/standard counts
Summary
The config schema documents tools_enabled as overriding tool_profile, but the actual (intended, test-pinned) precedence is the opposite. Following the documented behavior silently fails. There are also two stale tool-count strings in the tool_profile description.
Version: v3.8.15 (also current main @ d7f6d8e).
The documentation bug
config schema / config-keys.md says:
tools_enabled— Explicit list of enabled tool names (overrides tool_profile when non-empty)
But ToolProfile::from_config resolves in this order — tool_profile wins, tools_enabled is only consulted when no profile is pinned:
https://github.com/yvgude/lean-ctx/blob/v3.8.15/rust/src/core/tool_profiles.rs#L83-L119
/// Priority: LEAN_CTX_TOOL_PROFILE env > config tool_profile > config tools.enabled > default.
...
if let Some(ref profile_name) = cfg.tool_profile {
if let Some(profile) = Self::parse(profile_name) {
return profile; // <-- minimal/standard/power wins here
}
...
}
if !cfg.tools_enabled.is_empty() {
return Self::Custom(cfg.tools_enabled.clone()); // only reached if no profile pinned
}
This is intended and pinned by a test:
https://github.com/yvgude/lean-ctx/blob/v3.8.15/rust/src/core/tool_profiles.rs#L440 (tool_profile_takes_precedence_over_tools_enabled)
So the code is correct; the schema description is wrong (inverted).
Reproduction
# config.toml
tool_profile = "minimal"
tools_enabled = ["ctx_read", "ctx_shell", "ctx_search", "ctx_glob", "ctx_tree", "ctx_delta", "ctx_url_read"]
tools/list advertises the minimal set; tools_enabled is ignored. Removing/emptying tool_profile makes tools_enabled take effect. Verified via a raw JSON-RPC initialize + tools/list handshake (not just lean-ctx tools, which is display-only).
Stale tool counts (same description)
tool_profile description says minimal (6 tools), standard (17). Actual: minimal = 5, standard = 15 (MINIMAL_TOOLS / STANDARD_TOOLS; minimal lost ctx_symbol when #509 folded symbol lookup into ctx_search).
Fix
Doc-only. PR linked below corrects the schema string + the rustdoc on Config::tools_enabled + the generated config-keys.md, and the counts. No behavior change.
Proposed QoL (separate, optional): tool_profile = "" warns on its own default
tool_profile's documented default is "". But setting it to "" (a legitimate "unpin") logs:
WARN lean_ctx::core::tool_profiles: Unknown tool_profile '' in config, using default
because is_unpinned_alias only matches lean/lazy/reset:
https://github.com/yvgude/lean-ctx/blob/v3.8.15/rust/src/core/tool_profiles.rs#L132-L137
Treating empty/whitespace as unpinned would silence the spurious warning on the documented default:
matches!(name.trim().to_ascii_lowercase().as_str(), "" | "lean" | "lazy" | "reset")
Happy to fold this into the PR or send a follow-up if you'd take it.
Question: ctx_call injected into an explicit tools_enabled list
With a Custom set (no profile, explicit tools_enabled), the served tools/list still includes ctx_call, which can dispatch to every registered tool — bypassing the explicit allowlist. We worked around it with disabled_tools = ["ctx_call"]. Is ctx_call meant to always be advertised even for an explicit tools_enabled allowlist? If tools_enabled is meant to be "explicit and authoritative", silently adding the universal dispatcher seems to defeat the purpose — but it may be intended as the escape hatch. Either way, worth a doc note.