fix(cli): auto-continue max iterations in --yolo mode#1737
Open
frntn wants to merge 4 commits intodocker:mainfrom
Open
fix(cli): auto-continue max iterations in --yolo mode#1737frntn wants to merge 4 commits intodocker:mainfrom
frntn wants to merge 4 commits intodocker:mainfrom
Conversation
When running in non-interactive mode with --yolo (e.g. `cagent exec --yolo`), reaching max_iterations triggers a stdin prompt that fails immediately with "Failed to read input, exiting..." since stdin is piped or closed. This fix proposal makes --yolo consistent: it now auto-approves iteration extensions just like it auto-approves tool calls. A safety cap of 5 extensions (+50 iterations) prevents infinite loops. TL;DR : in --yolo mode, cagent now auto-approve the "max-iterations" continuation (up to 5 times) instead of prompting stdin (which fails immediately in non-interactive/piped contexts) Signed-off-by: Matthieu FRONTON <m@tthieu.fr>
The JSON event loop (`--json`) did not handle MaxIterationsReachedEvent at all, causing the runtime to hang on resumeChan indefinitely. Apply the same auto-continue logic as the normal output path: auto-approve in --yolo mode (with safety cap), reject otherwise. Signed-off-by: Matthieu FRONTON <m@tthieu.fr>
Cover --yolo auto-continue behavior for MaxIterationsReachedEvent in both normal and JSON output modes, including safety cap enforcement. Signed-off-by: Matthieu FRONTON <m@tthieu.fr>
Deduplicate MaxIterationsReachedEvent logic between JSON and normal output modes into a single helper with a ternary return type (continue/stop/prompt). Signed-off-by: Matthieu FRONTON <m@tthieu.fr>
Contributor
|
I'm not really sure of this.. The max iterations feature was designed exactly for this purpose, to not iterate forever. Auto approving that confirmation prompt silently when using IMHO a better approach is just to set |
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.
Problem
When running
cagent exec --yoloin non-interactive mode (stdin closed/piped),hitting the max iterations limit triggers a stdin prompt that immediately fails
with "Failed to read input, exiting...".
This is inconsistent:
--yoloauto-approves tool calls but not iteration extensions.Fix
--yolomode (capped at 5 to prevent infinite loops)MaxIterationsReachedEventin JSON output mode (was completely missing, causing runtime hang)handleMaxIterationsAutoApprovehelper to avoid duplication between normal and JSON pathsTest plan
golangci-lint run ./pkg/cli/...→ 0 issuesgo test ./pkg/cli/...→ 16/16 PASS