Skip to content

Fix PersonaToolExecutor: 4 bugs breaking tool calls (#368)#400

Merged
joelteply merged 2 commits intomainfrom
fix/tool-executor-368
Mar 25, 2026
Merged

Fix PersonaToolExecutor: 4 bugs breaking tool calls (#368)#400
joelteply merged 2 commits intomainfrom
fix/tool-executor-368

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

Summary

  • String(v) destroying object/array paramsString({foo:1})"[object Object]" (unrecoverable). Fixed with JSON.stringify for non-primitives in both PersonaToolExecutor and AgentToolExecutor
  • Force-text at 3 iterations too aggressive — Frontier models (Anthropic/OpenAI) now get 10 iterations before forced text (was 3). Enables read→edit→test→fix chains
  • Double correction eliminated — Added executeCorrectedToolCall() so PersonaToolExecutor doesn't re-correct through executeToolCall()
  • Loop detection side-effect — Result mapping was re-calling isLoopDetected() (which has side effects). Now uses pre-partitioned set
  • Tool group example bias — code-read group's only example was code/search, teaching LLMs to search instead of read known files. Now shows both with guidance

Also filed #399 (persona response latency) and added to gap analysis Phase 2.

Test plan

  • TypeScript compilation clean
  • Deployed via npm start (133s)
  • AI QA: asked personas to use code/read on src/package.json
  • Fireworks AI: correct (1.0.8900)
  • DeepSeek Assistant: correct (1.0.8900)
  • Groq Lightning: tool executed (385 lines read)
  • All personas used code/read not code/search

🤖 Generated with Claude Code

…correction, tool group bias

Four bugs fixed in the tool execution pipeline (#368):

1. String(v) destroying object/array params — JSON.stringify for non-primitives
2. Force-text at 3 iterations too aggressive — tiered by provider capability
3. Double correction eliminated — executeCorrectedToolCall skips re-correction
4. Loop detection side-effect in result mapping — use pre-partitioned set
5. ToolGroupRegistry code-read example biased toward code/search over code/read

QA validated: Fireworks AI, DeepSeek, Groq Lightning, Local Assistant all
successfully used code/read to read src/package.json after deployment.

Also: filed #399 (persona response latency), added to gap analysis Phase 2.
Copilot AI review requested due to automatic review settings March 25, 2026 04:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes multiple defects in the persona/agent tool execution pipeline that were causing incorrect tool parameter passing, premature tool-loop termination, double-correction, and loop-detection side effects; it also updates tool-group prompting guidance to reduce model bias toward searching instead of reading.

Changes:

  • Preserve structured tool parameters by JSON-stringifying object/array inputs when converting native tool calls to internal ToolCall format.
  • Add executeCorrectedToolCall() to avoid double-correcting already-corrected tool calls, and remove loop-detection re-invocation with side effects.
  • Increase provider-tiered “force text” threshold to allow longer tool chains for frontier models; update tool-group examples/guidance and planning docs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/system/user/server/modules/PersonaToolExecutor.ts Avoids re-correction by calling executeCorrectedToolCall() and updates native tool-call param stringification.
src/system/user/server/modules/PersonaAgentLoop.ts Makes “force text” threshold provider-tiered, allowing longer tool chains for capable providers.
src/system/tools/server/AgentToolExecutor.ts Adds executeCorrectedToolCall(), improves native param serialization, and fixes loop-detection side-effect behavior during result mapping.
src/system/rag/sources/ToolGroupRegistry.ts Adjusts code-read group description/example to encourage code/read for known files.
docs/planning/ALPHA-GAP-ANALYSIS.md Updates gap analysis to include #399 and status/details for #368.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants