Skip to content

fix: bridge tool-calls in copilot-acp adapter - #4536

Closed
MestreY0d4-Uninter wants to merge 1 commit into
NousResearch:mainfrom
MestreY0d4-Uninter:fix/copilot-acp-tool-calls
Closed

fix: bridge tool-calls in copilot-acp adapter#4536
MestreY0d4-Uninter wants to merge 1 commit into
NousResearch:mainfrom
MestreY0d4-Uninter:fix/copilot-acp-tool-calls

Conversation

@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a major behavioral gap in the copilot-acp adapter where Hermes would often respond with intent text ("vou executar...") but make zero tool calls.

What changed

  • Updated agent/copilot_acp_client.py to:
    • include available tool schemas (tools) and tool_choice hints in the ACP prompt bridge
    • remove the strict anti-tool JSON instruction and replace it with explicit tool-call emission guidance
    • parse structured tool calls returned in text (<tool_call>{...}</tool_call> and JSON-shaped fallbacks)
    • map parsed calls back into Hermes/OpenAI-compatible tool_calls with proper finish_reason="tool_calls"
    • add conservative heuristic fallback for ACP prose-only responses (initially terminal requests; plus explicit vision request URL fallback path)

Why

In copilot-acp mode, Hermes could claim action but fail to execute tools. This breaks core tool-use guarantees.

Validation

Executed automated ACP battery against enabled CLI toolsets with --provider copilot-acp and claude-sonnet-4.6.

  • Passed: 10 / 11
  • Failing: vision

Notes on vision failure

Failure appears to be provider/runtime capability mismatch in ACP path (tool listed at UI level but not actually exposed/usable in runtime path), not parser regression.

Evidence artifacts (local run):

  • /tmp/acp_toolsets_progress.log
  • /tmp/acp_toolsets_report.json

Impact

  • Restores practical tool execution for copilot-acp path across terminal/file/code_execution/delegation/skills/memory/session_search/todo/web toolsets.
  • Keeps behavior bounded via conservative fallback rules.

Follow-ups (recommended)

  • Add focused tests for ACP tool-call text parsing and fallback synthesis in tests/.
  • Investigate ACP vision runtime availability contract.

@robert-hoffmann

Copy link
Copy Markdown

ah nice, this was annoying, especially since copilot is one of the cheapest SOTA options

@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor Author

ah nice, this was annoying, especially since copilot is one of the cheapest SOTA options
I've made some more progress with Github Copilot. I'll publish it soon.

@robert-hoffmann

Copy link
Copy Markdown

@MestreY0d4-Uninter yeah the annoying thing was tool calls in acp were broken, and the fine grained pat token : is broken too (i think)

https://github.com/github/copilot-cli
image

https://github.com/settings/personal-access-tokens/new
image

@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor Author

Thanks — I kept this PR intentionally narrow around the ACP tool-call bridging fix.

The additional ACP work I’ve been doing locally is already split into separate follow-up branches (session/context persistence, integration, and delegation reasoning/defaults), and I’ll submit those separately so this PR stays a straightforward bugfix.

@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor Author

I’ve now pushed and opened the follow-up work as draft PRs so it doesn’t get lost to upstream drift while this one is pending.

They are intentionally marked as drafts and each one explicitly depends on #4536:

All three were rebased onto current main and revalidated before opening.

@robert-hoffmann

Copy link
Copy Markdown

Thanks for sharing, like that i can integrate and test while waiting for them to update their code, which does seem kinda slow

@robert-hoffmann

robert-hoffmann commented Apr 6, 2026

Copy link
Copy Markdown

I sent them a request on discord to see if they can accelerate this fix

Btw the merge status seems to have gone red 🥺

teknium1 pushed a commit that referenced this pull request Apr 6, 2026
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.
teknium1 pushed a commit that referenced this pull request Apr 6, 2026
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.
@teknium1

teknium1 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Merged via PR #5460. Your commit was cherry-picked onto current main with your authorship preserved in git log. Stripped the heuristic fallback system and Portuguese-specific patterns (adapter should be language-agnostic), and fixed a duplicate tool call extraction bug. Thanks for the contribution!

@teknium1 teknium1 closed this Apr 6, 2026
Tommyeds pushed a commit to Tommyeds/hermes-agent that referenced this pull request Apr 12, 2026
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 NousResearch#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.
@MestreY0d4-Uninter
MestreY0d4-Uninter deleted the fix/copilot-acp-tool-calls branch April 27, 2026 01:42
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
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 NousResearch#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.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 28, 2026
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 NousResearch#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.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
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 NousResearch#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.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
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 NousResearch#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.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
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 NousResearch#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants