fix: bridge tool-calls in copilot-acp adapter - #5460
Merged
Conversation
Enable Hermes tool execution through the copilot-acp adapter by:
- Passing tool schemas and tool_choice into the ACP prompt text
- Instructing ACP backend to emit <tool_call>{...}</tool_call> blocks
- Parsing XML tool-call blocks and bare JSON fallback back into
Hermes-compatible SimpleNamespace tool call objects
- Setting finish_reason='tool_calls' when tool calls are extracted
- Cleaning tool-call markup from response text
Fix duplicate tool call extraction when both XML block and bare JSON
regexes matched the same content (XML blocks now take precedence).
Cherry-picked from PR #4536 by MestreY0d4-Uninter. Stripped heuristic
fallback system (auto-synthesized tool calls from prose) and
Portuguese-language patterns — tool execution should be model-decided,
not heuristic-guessed.
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
Enables Hermes tool execution through the copilot-acp adapter. Previously, the adapter explicitly told the ACP backend "Do not emit OpenAI tool-call JSON" — the backend could only respond in prose, never actually calling tools.
Changes
tool_choiceinto the ACP prompt text so the backend knows what tools are available<tool_call>{...}</tool_call>blocksSimpleNamespaceobjectsfinish_reason='tool_calls'when tool calls are extractedFollow-up fix
Fixed duplicate tool call extraction bug in original PR — when both XML block regex and bare JSON regex matched the same content, the same tool call was extracted twice. XML blocks now take precedence; bare JSON fallback only runs when no XML blocks are found.
What was stripped from original PR
_heuristic_fallback_tool_calls) that auto-synthesized tool calls from prose — dangerous because it bypasses model judgmentValidation
Salvaged from PR #4536 by @MestreY0d4-Uninter — contributor authorship preserved in commit.