mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-21 08:15:23 -04:00
[PR #194] [CLOSED] fix(providers): add iteration cap to performAgentChain to prevent infinite loops #223
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/194
Author: @manusjs
Created: 3/11/2026
Status: ❌ Closed
Base:
master← Head:fix/agent-chain-iteration-cap📝 Commits (1)
8bc80d3fix(providers): add iteration cap to performAgentChain to prevent infinite loops📊 Changes
3 files changed (+110 additions, -5 deletions)
View changed files
📝
backend/pkg/providers/helpers.go(+15 -4)📝
backend/pkg/providers/performer.go(+11 -1)➕
backend/pkg/providers/performer_test.go(+84 -0)📄 Description
What
Adds a hard iteration cap to
performAgentChainand escalating error behaviour in the repeating-detector to prevent infinite loops when a model repeatedly calls the same tool.Fixes #175
Root Cause
performAgentChaininbackend/pkg/providers/performer.gois an unboundedfor {}loop. When the repeating detector fires it returns(message, nil)— a successful response — sowantToStopis never set and the loop continues. Production logs show 4800+ repeating-detector warnings in a single session.Changes
performer.go: AddedmaxAgentChainIterations = 100cap. Loop returns an error if exceeded.maxRepeatingBeforeAbort = 5) returns an actualerrorinstead of a nil-error message, so the error path inperformAgentChainfires.performer_test.go(new):TestAgentChainIterationCap— mocks a chain that never stops and asserts error is returned aftermaxAgentChainIterations.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.