feat: Replace ChatAgent single_iteration with max_iteration #2483
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.
This is a test using Jules, PR automaticlly generated by Jules Agent
Replaces the boolean
single_iteration
parameter inChatAgent
with an integermax_iteration
to provide more flexible control over the number of model calling iterations within a single agent step.Key changes:
ChatAgent.__init__
now acceptsmax_iteration: Optional[int] = None
.max_iteration
isNone
(default): No explicit limit on internal model/tool iterations (mimics oldsingle_iteration=False
).max_iteration=1
: Agent performs one model call; if a tool is called, the step ends after tool execution (mimics oldsingle_iteration=True
).max_iteration=N > 1
: Agent performs up to N model calls and tool executions within a step.ChatAgent.step
andChatAgent.astep
updated to respectmax_iteration
.ChatAgent.clone
method updated to carry overmax_iteration
.ChatAgent
updated to reflect the new parameter.ChatAgent
usingsingle_iteration
have been updated:single_iteration=True
changed tomax_iteration=1
.single_iteration=False
(explicitly set) changed tomax_iteration=None
.max_iteration=None
.test/agents/test_chat_agent.py
have been updated and new tests added to cover variousmax_iteration
scenarios (1, N, None) and ensure graceful termination.Description
Describe your changes in detail (optional if the linked issue already contains a detailed description of the changes).
Checklist
Go over all the following points, and put an
x
in all the boxes that apply.Fixes #issue-number
in the PR description (required)pyproject.toml
anduv lock
If you are unsure about any of these, don't hesitate to ask. We are here to help!