nanocoder
nanocoder copied to clipboard
[Bug] Ordinary tags like <kbd> or <T> are removed from assistant prose when the same reply contains a tool call
Description
When a reply contains a tool call, the parser removes tool-call text from the prose. The removal deletes any <tag>text</tag> pair, not only calls to real tools, so ordinary tags in the prose are lost. It does not happen on replies without a tool call.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at eb7dee57)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
- Call
stripEmbeddedToolCallText('Press <kbd>Ctrl</kbd>+<kbd>C</kbd>. Generic <T>x</T>. Done.')(used when native tool calls came back with the reply). - Call
parseToolCalls('Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop. <read_file><path>a.ts</path></read_file>', ['read_file'])and readcleanedContent.
Expected Behavior
Only the tool call is removed: Press <kbd>Ctrl</kbd>+<kbd>C</kbd>. Generic <T>x</T>. Done. and Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop.
Actual Behavior
"Press +. Generic . Done."
"Press + to stop."
Without a tool call (parseToolCalls('Press <kbd>Ctrl</kbd>... Done.', ['read_file'])) the prose is returned unchanged.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/tool-calling/xml-parser.ts:444(removeToolCallsFromContent): remove only elements whose name is one of the offered tool names. PasstoolNamesthrough fromtool-parser.ts:341(stripEmbeddedToolCallText) and:430(parseToolCalls).- Add tests for both examples above.