Skip to content

still getting stuck in infinite loops sometimes#231

Merged
derekmisler merged 1 commit into
docker:mainfrom
derekmisler:implement-max-iterations
Jun 11, 2026
Merged

still getting stuck in infinite loops sometimes#231
derekmisler merged 1 commit into
docker:mainfrom
derekmisler:implement-max-iterations

Conversation

@derekmisler

@derekmisler derekmisler commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Deprecates the /review comment command in favor of re-requesting review from docker-agent in the PR sidebar. Increases timeout limits to accommodate complex reviews, adds iteration limits to prevent agent loops, and improves timeout error messaging with context about diff size.

Changes

  • Deprecate /review command: Posts a deprecation notice when used; users should re-request review from docker-agent in the PR sidebar instead
  • Increase timeout limits: Workflow timeout 35→50 min, agent timeout 30→45 min to handle larger/more complex diffs
  • Add agent iteration limits: Set max_iterations: 40 for drafter and max_iterations: 20 for verifier to prevent infinite loops
  • Improve timeout messaging: Timeout errors now distinguish between small diffs (likely agent loop) and large diffs (likely complexity), with actionable guidance
  • Update documentation: Clarify primary trigger (sidebar review request), mark /review as deprecated, and explain re-trigger workflow

Test plan

  • Verify /review comment posts deprecation notice and review still completes
  • Confirm timeout messages display correctly for both small and large diffs
  • Check that agent iteration limits prevent runaway loops while allowing normal reviews to complete

@derekmisler derekmisler self-assigned this Jun 8, 2026
@derekmisler derekmisler changed the title feat(filter-diff): support glob patterns in exclude-paths (#224) still getting stuck in infinite loops sometimes Jun 8, 2026

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🔴 CRITICAL

The new "Post /review deprecation notice" step has two bugs that prevent it from ever posting successfully. Both reference step IDs that do not exist in this workflow job.

Comment thread .github/workflows/review-pr.yml Outdated
Comment thread .github/workflows/review-pr.yml Outdated
@derekmisler
derekmisler force-pushed the implement-max-iterations branch 2 times, most recently from b59e389 to 28ec0d1 Compare June 8, 2026 15:25
@derekmisler
derekmisler marked this pull request as ready for review June 8, 2026 15:34

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The changes are well-structured and address the infinite loop problem effectively. Adding max_iterations caps (drafter:40, verifier:20) and increasing timeouts (agent 1800→2700s, job 35→50 min) are straightforward and correct. The deprecation of /review in favour of sidebar review-request is a clean UX improvement. Two minor messaging issues were noted as inline comments.

Comment thread .github/workflows/review-pr.yml Outdated
Comment thread review-pr/action.yml Outdated
@derekmisler
derekmisler force-pushed the implement-max-iterations branch from 28ec0d1 to 4137f2b Compare June 8, 2026 16:07
@derekmisler
derekmisler requested review from Sayt-0 and aheritier June 10, 2026 10:53

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION

This PR correctly addresses infinite loops with max_iterations limits, increases timeouts, and deprecates the /review command. One finding warrants verification before merge.

Summary of changes reviewed:

  • ✅ Timeout increase (1800s → 2700s) and workflow limit (35 → 50 min) — straightforward and well-commented
  • ✅ Deprecation notice step — correctly fires on issue_comment with is_review == 'true'; bot-loop guards prevent the posted notice from re-triggering the workflow
  • $TIMEOUT_BODY shell quoting — double-quoting correctly prevents word splitting; backticks in hardcoded strings are safe
  • ⚠️ max_iterations schema validity — see inline comment


drafter:
model: sonnet
max_iterations: 40

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] max_iterations field validity in cagent YAML schema v6 is unconfirmed — if unrecognized, infinite loop prevention is silently ineffective

The file history for review-pr/agents/pr-review.yaml shows a suspicious pattern:

  1. Commit a588b69 added max_iterations to the drafter
  2. Commit 724b3f7 ("fix(review-pr): schema mismatch, chunk size, and timeout diagnostics") followed shortly after
  3. This PR re-adds max_iterations to both drafter and verifier

If commit 724b3f7 removed max_iterations specifically because it caused a schema validation error in cagent v6, then re-adding it here would either silently fail (field ignored → infinite loop prevention is a no-op) or cause agents to fail to start. Since the entire purpose of this PR is to fix infinite loops via max_iterations, silently ignored limits would leave the root problem unresolved.

Suggested verification: Check whether max_iterations appears in the cagent v6 agent schema documentation, or review the diff of commit 724b3f7 to confirm what the schema mismatch actually was (output schema vs. agent config schema). If max_iterations is a valid v6 field, this is fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the question! After investigating, I believe there's a conflation between two different things here:

  1. Hook-based max_iterations — this was removed in PR fix(review-pr): remove unsupported before_llm_call hooks from drafter and verifier agents #200 (commit d634a35), where max_iterations was set via a hooks.before_llm_call mechanism.
  2. Top-level max_iterations config field — this is a separate, natively supported field in the agent config schema and was not affected by that removal.

The commit you cited (724b3f7) only renamed output schema field names and did not touch max_iterations.

I verified this in the docker-agent source: max_iterations exists in pkg/config/ types from v6 through the latest (v10). All versions use strict YAML parsing (DisallowUnknownField()), which means any unrecognized field would cause the agent to crash rather than be silently ignored — so this field is definitely valid and actively supported.

Happy to share the specific source references if that would help!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the thorough investigation and clarification! You're absolutely right — I conflated the hook-based iteration control (removed in PR #200) with the native max_iterations config field, which has always been supported in the schema.

Your point about DisallowUnknownField() is particularly reassuring: if max_iterations were invalid, the agents would fail to start rather than silently ignoring the limit. That eliminates the "silent failure" risk I was concerned about. Given that verification, this change should work as intended.

Appreciate you taking the time to trace through the commit history and source code!

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The changes look correct. All three hypothesized bugs were investigated and dismissed after careful analysis:

Investigated: backtick escaping in gh api -f body="..." calls — The \`` sequences in the new deprecation notice and timeout body strings are valid bash. In YAML run: |literal blocks,`passes verbatim to bash as backslash+backtick. Within bash double-quoted strings,`escapes the backtick (per the bash manual: *"The backslash retains its special meaning only when followed by:$, `` ``, ", ``, or newline"*), producing a literal backtick character — no command substitution occurs. The posted comments will render correctly with backtick-wrapped names.

CHUNK_COUNT branching logic — The three-way conditional (-z, = "1", else) correctly handles all cases: missing step output, single-chunk diff, and multi-chunk diff. The env var propagation from steps.chunk-diff.outputs.chunk_count is correct.

max_iterations in agent YAML — Confirmed valid per project history: this is a natively supported top-level field in the agent config schema (strict DisallowUnknownField() parsing means invalid fields crash at startup, so its acceptance proves validity).

Other changes — Timeout increase (1800→2700 s), workflow timeout (35→50 min), and the deprecation notice step ordering (notice posts before review proceeds, || echo ensures continue-on-error behavior) are all correct.

@derekmisler
derekmisler enabled auto-merge (squash) June 10, 2026 20:12
@derekmisler
derekmisler merged commit 4cf01d7 into docker:main Jun 11, 2026
16 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.

3 participants