Fix PersonaToolExecutor: 4 bugs breaking tool calls (#368)#400
Merged
Fix PersonaToolExecutor: 4 bugs breaking tool calls (#368)#400
Conversation
…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.
Contributor
There was a problem hiding this comment.
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
ToolCallformat. - 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.
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
String({foo:1})→"[object Object]"(unrecoverable). Fixed withJSON.stringifyfor non-primitives in bothPersonaToolExecutorandAgentToolExecutorexecuteCorrectedToolCall()so PersonaToolExecutor doesn't re-correct throughexecuteToolCall()isLoopDetected()(which has side effects). Now uses pre-partitioned setcode/search, teaching LLMs to search instead of read known files. Now shows both with guidanceAlso filed #399 (persona response latency) and added to gap analysis Phase 2.
Test plan
npm start(133s)code/readonsrc/package.jsoncode/readnotcode/search🤖 Generated with Claude Code