fix: /version command + recover qwen tool calls from text content#41
Merged
Conversation
This was referenced May 23, 2026
Closed
Closes #40, closes #36. /version (#40): /version and /v slashes now print SmallCode version, description, Node and platform info, sourced from package.json. Tool extractor (#36): when a model emits a tool invocation as JSON inside message.content (qwen2.5-coder:14b on Ollama, hermes, llama3 GGUFs) instead of structured tool_calls, lift it out automatically. Recognises tool_call tags, fenced JSON, bare JSON, and OpenAI/named-tool/named-args shapes. Tolerates qwen trailing-comma JSON. Conservative — unknown tool names are not extracted. Wired into bin/smallcode.js, src/api/index.js, and src/session/parallel_executor.js. README + CHANGELOG updated. 13 new E2E test cases (.test-workspace, gitignored).
Doorman11991
force-pushed
the
fix/issues-36-40
branch
from
May 23, 2026 10:57
43570d0 to
1443551
Compare
Doorman11991
added a commit
that referenced
this pull request
May 23, 2026
Kothulhu94
pushed a commit
to Kothulhu94/smallcode
that referenced
this pull request
May 29, 2026
…orman11991#41) Closes Doorman11991#40, closes Doorman11991#36. /version (Doorman11991#40): /version and /v slashes now print SmallCode version, description, Node and platform info, sourced from package.json. Tool extractor (Doorman11991#36): when a model emits a tool invocation as JSON inside message.content (qwen2.5-coder:14b on Ollama, hermes, llama3 GGUFs) instead of structured tool_calls, lift it out automatically. Recognises tool_call tags, fenced JSON, bare JSON, and OpenAI/named-tool/named-args shapes. Tolerates qwen trailing-comma JSON. Conservative — unknown tool names are not extracted. Wired into bin/smallcode.js, src/api/index.js, and src/session/parallel_executor.js. README + CHANGELOG updated. 13 new E2E test cases (.test-workspace, gitignored). Co-authored-by: DanTheMan181 <283874042+Doorman11991@users.noreply.github.com>
Kothulhu94
pushed a commit
to Kothulhu94/smallcode
that referenced
this pull request
May 29, 2026
Bundles two merged fixes since 1.0.2: * PR Doorman11991#41 (closes Doorman11991#36, Doorman11991#40): tool-call extractor for qwen2.5-coder + /version slash command * PR Doorman11991#39: SSRF guard hardening — IPv4-mapped IPv6 alias bypass + browser redirect re-validation
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.
Summary
Closes #40, closes #36.
#40 —
/versionreturns "Unknown"Reporter ran
/versionand gotUnknown: /version. Type /help. The command was advertised by the command palette and the help table but never had a handler.Added
case '/version': case '/v':tobin/commands.js. Readspackage.jsonso the value can never drift, prints the description andNode X on platform/archfor support context./versionis now in/helpand the README command table.#36 — qwen2.5-coder:14b spills tool JSON into chat
Reporter pointed Ollama at qwen2.5-coder:14b and asked “what files are in this directory?”. Instead of the tool running, the raw
<tool_call>{"name":"shell",...}</tool_call>blob landed in chat.Root cause: some local-model + Ollama OpenAI-compat combinations emit the tool invocation as text in
message.contentrather than populating the structuredtool_callsfield. The agent loop inbin/smallcode.jsonly checksmessage.tool_calls, so the call is treated as plain prose.Added
src/tools/tool_call_extractor.js— a defensive recovery layer that runs immediately after the model response is decoded. It detects four shapes and lifts them into the propertool_callsfield:<tool_call>{...}</tool_call>— Hermes / qwen2.5 native template```json ... ```and```tool_call ... ```fenced blocks{ "function": { "name", "arguments" } },{ "name", "arguments" }, and{ "tool", "args" }body formsOther niceties:
message.contentso the user doesn't see it twice.Wired into the three response-handling sites that exist today:
bin/smallcode.js(interactive agent loop),src/api/index.js(programmatic SDK), andsrc/session/parallel_executor.js(parallel-step planner). All three already-structured-tool_calls paths continue working unchanged.Verification
E2E tests in
.test-workspace/(workspace-local, gitignored):tool_call_extractor_test.js— 10 cases including all four shapes, multiple calls per message, unknown-tool rejection, prose passthrough, trailing-comma repair, and the OpenAI-shaped variant. 10/10 pass.version_command_test.js— verifies/version,/v, and that unknown slashes still report "Unknown:". 3/3 pass.Existing
tui_unit_test.jsstill passes 11/11.Files
src/tools/tool_call_extractor.js— new (168 lines)bin/commands.js—/version+/vcases,/helplinebin/smallcode.js— extractor call afterresponse.choices[0].messagesrc/api/index.js— same wiring for the SDK pathsrc/session/parallel_executor.js— same wiring for parallel stepsREADME.md—/versionrow in the command tableCHANGELOG.md— Unreleased entry