Skip to content

fix(agent): parse MiniMax tool call formats for execution#1131

Merged
chumyin merged 5 commits intozeroclaw-labs:mainfrom
klampatech:fix/minimax-toolcall-parsing
Feb 21, 2026
Merged

fix(agent): parse MiniMax tool call formats for execution#1131
chumyin merged 5 commits intozeroclaw-labs:mainfrom
klampatech:fix/minimax-toolcall-parsing

Conversation

@klampatech
Copy link
Copy Markdown
Contributor

Summary

Describe this PR in 2-5 bullets:

  • Problem: MiniMax LLM outputs tool calls in non-standard formats that ZeroClaw doesn't recognize, causing them to be sent as plain text to Telegram instead of being executed
  • Why it matters: Tool calls fail silently; users see raw XML/Perl syntax in messages instead of having tools execute
  • What changed: Added two new parser functions in src/agent/loop_.rs to handle XML attribute style (<invoke name="shell"><parameter name="command">ls</parameter></invoke>) and Perl/hash-ref style ({tool => "shell", args => { --command "ls" }})
  • What did not change (scope boundary): No changes to provider API calls, channel send logic, or tool execution runtime

Label Snapshot (required)

  • Risk label (risk: low|medium|high): medium
  • Size label (size: XS|S|M|L|XL, auto-managed/read-only): S
  • Scope labels (core|agent|channel|config|cron|daemon|doctor|gateway|health|heartbeat|integration|memory|observability|onboard|provider|runtime|security|service|skillforge|skills|tool|tunnel|docs|dependencies|ci|tests|scripts|dev, comma-separated): agent, tool
  • Module labels (<module>: <component>, for example channel: telegram, provider: kimi, tool: shell): agent: loop, tool: parsing
  • Contributor tier label (trusted contributor|experienced contributor|principal contributor|distinguished contributor, auto-managed/read-only; author merged PRs >=5/10/20/50): N/A (first PR)
  • If any auto-label is incorrect, note requested correction: N/A

Change Metadata

  • Change type (bug|feature|refactor|docs|security|chore): bug
  • Primary scope (runtime|provider|channel|memory|security|ci|docs|multi): agent

Linked Issue

  • Closes # (if applicable)
  • Related # (if applicable)
  • Depends on # (if stacked)
  • Supersedes # (if replacing older PR)

Supersede Attribution (required when Supersedes # is used)

  • Superseded PRs + authors (#<pr> by @<author>, one per line): N/A
  • Integrated scope by source PR (what was materially carried forward): N/A
  • Co-authored-by trailers added for materially incorporated contributors? (Yes/No): N/A
  • If No, explain why (for example: inspiration-only, no direct code/design carry-over): N/A
  • Trailer format check (separate lines, no escaped \n): (Pass/Fail): N/A

Validation Evidence (required)

Commands and result summary:

cargo fmt --all -- --check
cargo clippy --lib -p zeroclaw
cargo build --release
  • Evidence provided (test/log/trace/screenshot/perf):
    • cargo build --release passes with no warnings
    • Tested locally with MiniMax provider - tool calls now execute instead of being sent as text
  • If any command is intentionally skipped, explain why:
    • cargo test has pre-existing compilation errors unrelated to these changes (rand::RngExt trait issue in test code)

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • New external network calls? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • File system access scope changed? (Yes/No): No
  • If any Yes, describe risk and mitigation: N/A

Privacy and Data Hygiene (required)

  • Data-hygiene status (pass|needs-follow-up): pass
  • Redaction/anonymization notes: None needed
  • Neutral wording confirmation (use ZeroClaw/project-native labels if identity-like wording is needed): Confirmed

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Human Verification (required)

What was personally validated beyond CI:

  • Verified scenarios: Ran zeroclaw with MiniMax provider, had it execute shell and file_read tools
  • Edge cases checked: Both XML and Perl-style tool call formats tested
  • What was not verified: Cross-provider compatibility (other providers should be unaffected)

Side Effects / Blast Radius (required)

  • Affected subsystems/workflows: Agent tool parsing only
  • Potential unintended effects: Minimal - added parsers are additive and only activate when other parsers find no tool calls
  • Guardrails/monitoring for early detection: Warning logs exist for malformed tool call JSON

Agent Collaboration Notes (recommended)

  • Agent tools used (if any): systematic-debugging, verification-before-completion
  • Workflow/plan summary (if any): Root cause analysis → pattern analysis → hypothesis → implementation
  • Verification focus: Confirm MiniMax tool calls execute vs being sent as text
  • Confirmation: naming + architecture boundaries followed (AGENTS.md + CONTRIBUTING.md): Yes

Rollback Plan (required)

  • Fast rollback command/path: git revert HEAD or git checkout main -- src/agent/loop_.rs
  • Feature flags or config toggles (if any): None needed
  • Observable failure symptoms: Tool calls would revert to being sent as plain text to channels

Risks and Mitigations

List real risks in this PR (or write None).

  • Risk: New regex parsers could have edge cases
    • Mitigation: Tested with actual MiniMax outputs; parsers are additive (only run if JSON/XML parsers find nothing)
  • Risk: Pre-existing test compilation errors
    • Mitigation: These are unrelated to this PR; library and binary build successfully

@github-actions github-actions Bot added agent Auto scope: src/agent/** changed. channel Auto scope: src/channels/** changed. onboard Auto scope: src/onboard/** changed. labels Feb 20, 2026
@github-actions
Copy link
Copy Markdown

Thanks for contributing to ZeroClaw.

For faster review, please ensure:

  • PR template sections are fully completed
  • cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings, and cargo test are included
  • If automation/agents were used heavily, add brief workflow notes
  • Scope is focused (prefer one concern per PR)

See CONTRIBUTING.md and docs/pr-workflow.md for full collaboration rules.

@github-actions github-actions Bot added size: S Auto size: 81-250 non-doc changed lines. risk: medium Auto risk: src/** or dependency/config changes. provider Auto scope: src/providers/** changed. agent: loop Auto module: agent/loop changed. onboard: core Auto module: onboard core files changed. agent Auto scope: src/agent/** changed. onboard Auto scope: src/onboard/** changed. size: M Auto size: 251-500 non-doc changed lines. and removed agent Auto scope: src/agent/** changed. onboard Auto scope: src/onboard/** changed. provider Auto scope: src/providers/** changed. size: S Auto size: 81-250 non-doc changed lines. labels Feb 20, 2026
@chumyin chumyin self-assigned this Feb 20, 2026
@chumyin
Copy link
Copy Markdown
Contributor

chumyin commented Feb 20, 2026

Status update: this PR is currently blocked by merge conflicts against main (mergeable=CONFLICTING), so it cannot proceed to rebase-merge in this pass.

Please rebase/update the branch on top of the latest main, resolve conflicts, and rerun checks. After that, automation can continue with final validation and merge.

We are conducting automation testing, and this issue or PR is actually being handled automatically by ZeroClaw. If anything goes wrong or you have any questions, please contact @chumyin directly for better assistance.

@github-actions github-actions Bot added agent Auto scope: src/agent/** changed. and removed provider Auto scope: src/providers/** changed. labels Feb 20, 2026
@github-actions github-actions Bot added onboard Auto scope: src/onboard/** changed. provider Auto scope: src/providers/** changed. and removed agent Auto scope: src/agent/** changed. onboard Auto scope: src/onboard/** changed. labels Feb 21, 2026
@chumyin chumyin assigned chumyin and unassigned chumyin Feb 21, 2026
klampatech and others added 5 commits February 21, 2026 12:34
Add parsers for two additional tool call formats that MiniMax LLM uses:
- XML attribute style: <minimax:toolcall><invoke name="shell"><parameter name="command">ls</parameter></invoke></minimax:toolcall>
- Perl/hash-ref style: {tool => "shell", args => { --command "ls" }}

Previously these were sent as plain text to Telegram channel instead of
being executed as tool calls.

Also fixes build warnings:
- Add #[allow(unused_imports)] to cost/mod.rs and onboard/mod.rs re-exports
- Change channels::handle_command visibility to pub(crate)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add parser for <FunctionCall> style that MiniMax also uses:
<FunctionCall>
file_read
<code>path>/Users/.../file.md</code>
</FunctionCall>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous regex couldn't handle nested braces in:
{tool => "shell", args => { --command "ls" }}

Now uses multi-stage parsing: find TOOL_CALL block, extract
tool name, then extract args block.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive tool name alias mapping:
- fileread -> file_read
- filewrite -> file_write
- memoryrecall -> memory_recall
- bash/sh/cmd -> shell
- etc.

Apply to all new parsers (XML attribute, Perl, FunctionCall).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The format ends with }} before /TOOL_CALL, not a single }.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chumyin chumyin force-pushed the fix/minimax-toolcall-parsing branch from 1bb593d to 16985ac Compare February 21, 2026 04:34
@github-actions github-actions Bot added agent Auto scope: src/agent/** changed. onboard Auto scope: src/onboard/** changed. provider Auto scope: src/providers/** changed. and removed provider Auto scope: src/providers/** changed. agent Auto scope: src/agent/** changed. onboard Auto scope: src/onboard/** changed. labels Feb 21, 2026
@chumyin chumyin force-pushed the fix/minimax-toolcall-parsing branch from 16985ac to 779de19 Compare February 21, 2026 04:35
@github-actions github-actions Bot added agent Auto scope: src/agent/** changed. onboard Auto scope: src/onboard/** changed. provider Auto scope: src/providers/** changed. and removed provider Auto scope: src/providers/** changed. agent Auto scope: src/agent/** changed. onboard Auto scope: src/onboard/** changed. labels Feb 21, 2026
@chumyin chumyin merged commit 3f88f14 into zeroclaw-labs:main Feb 21, 2026
2 checks passed
@chumyin
Copy link
Copy Markdown
Contributor

chumyin commented Feb 21, 2026

Thanks for the contribution.

I rebased this PR onto the latest main, pushed the updated branch, rechecked mergeability and review thread status, and completed the merge flow.

We are currently conducting ZeroClaw automated testing. This is an automated comment from ZeroClaw. If you have any questions, please contact @chumyin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent: loop Auto module: agent/loop changed. channel Auto scope: src/channels/** changed. onboard: core Auto module: onboard core files changed. provider Auto scope: src/providers/** changed. risk: medium Auto risk: src/** or dependency/config changes. size: M Auto size: 251-500 non-doc changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants