Feat/mcp tooling#48
Open
jlee-kitware wants to merge 4 commits into
Open
Conversation
Add a "Log tool calls to the server console" toggle in the vtk-mcp settings (off by default, disabled without a server URL). When on, each tool call logs its name, arguments, and a short result at INFO level, and the loop logs when it hits the round cap without a final response. The flag threads from state through generate to the tool-calling loop; when off, behavior is unchanged.
Quantized local models (e.g. qwen2.5-coder via Ollama) often return a tool call as plain content instead of populating tool_calls, so finish_reason is "stop" and the agentic loop never ran the tool: tools appeared dead even though the model was trying to call them. Detect a tool call that arrived as text (a bare JSON object with name/arguments, or a <tool_call> block) whose name matches a known tool, execute it, and feed the result back like a native call. Answers, which are explanation/code tagged, are never misread as calls.
log_tool_calls was session-only, so it reset to off every launch. Include it in the exported config and restore it on startup, alongside mcp_url/top_k.
Add a setting to skip get_enriched_context so the model works from tools instead of a large pre-injected RAG block (which also frees ~4.5k tokens of context). Threaded from state through generate; persisted in config; off by default. Note: on its own this does not make a confident quantized local model call tools under tool_choice="auto"; deterministic post-validation is the reliable path and is a separate change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #47, which is stacked on #46. The diff here is only the four commits on top.
Tool calls from local models were silently discarded. Against Ollama, vtk-mcp appeared
to do nothing: the server was reachable, tools were sent, and the model was deciding to call
them, but nothing ran. Quantized local models often emit the call as plain JSON in the
message content instead of populating
tool_calls, so the response comes back withfinish_reason: "stop"and the loop treated the JSON as the final answer. We now detect atool call that arrived as text (bare JSON, or a
<tool_call>block) whose name matches aknown tool, execute it, and feed the result back like a native call. Anyone running against
a local backend is affected by this.
Logging. A "Log tool calls to the server console" setting (off by default). Each call
logs its name, arguments, and a short result as it happens. Previously there was no way to
tell whether the model was using tools at all. Persists in config.
Agentic retrieval toggle. Optionally skip the pre-injected RAG context, which runs to
roughly 4.5k tokens and is a large share of a 16k local context window. Note it does not by
itself make a confident quantized model call tools under
tool_choice="auto". Off bydefault.
Known gap. Tool use is still opportunistic: I used qwen2.5-coder-32b-ctx16 and asked about the streamtracer API, the model
answered from memory and hallucinated
SetMaximumErrorTolerance(reallySetMaximumError),which a
vtk_get_class_infocall would have caught. The fix is deterministicpost-validation, calling the vtk-mcp validators on generated code ourselves. Follow-up.