Skip to content

fix: tool call history loop in local agent#20

Merged
chocks merged 6 commits into
mainfrom
fix/tool-call-history-loop
Mar 8, 2026
Merged

fix: tool call history loop in local agent#20
chocks merged 6 commits into
mainfrom
fix/tool-call-history-loop

Conversation

@chocks
Copy link
Copy Markdown
Owner

@chocks chocks commented Mar 8, 2026

Summary

  • Fix tool call loop: Include tool_calls in assistant messages pushed to conversation history so the model can correlate tool results with prior requests — without this, the model re-issues tool calls each round until MAX_TOOL_ROUNDS (5), causing a ~30-60s "loop" during simple prompts
  • Filter malformed tool calls: Validate tool_calls entries before processing to prevent TypeError crashes from null/undefined entries returned by some models (e.g. qwen3)

Test plan

  • New test: assistant message history includes tool_calls after tool execution
  • New test: malformed tool_calls (null/undefined entries) treated as no tool calls
  • All 130 existing tests pass
  • TypeScript build clean

🤖 Generated with Claude Code

chocks and others added 6 commits March 7, 2026 20:31
The tool-calling loop in LocalAgent omitted tool_calls from assistant
messages pushed to conversation history. This caused the model to not
correlate tool results with prior requests, re-issuing tool calls each
round until MAX_TOOL_ROUNDS. Also filters malformed tool call entries
to prevent TypeError crashes from null/undefined entries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
qwen3:8b's thinking mode generates hundreds of hidden reasoning tokens
even for simple prompts, causing multi-minute response times. Switch to
qwen2.5-coder:7b which is code-focused, has no thinking overhead, and
responds much faster. Also strip <think> tags from responses in case
any model leaks thinking content.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…vailable

Instead of exiting with a manual install message, fall back to
`curl -fsSL https://ollama.com/install.sh | sh` on macOS when
Homebrew is not found — matching the officially recommended method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chocks chocks merged commit d765343 into main Mar 8, 2026
4 checks passed
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.

1 participant