Skip to content

Preserve turns that exceed the tool round limit - #7

Merged
paoloanzn merged 1 commit into
mainfrom
fix/preserve-tool-limit-turn
Aug 6, 2026
Merged

Preserve turns that exceed the tool round limit#7
paoloanzn merged 1 commit into
mainfrom
fix/preserve-tool-limit-turn

Conversation

@paoloanzn

@paoloanzn paoloanzn commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Closes #5

Summary

  • preserve and persist turns that reach the configured tool-round limit
  • pair final unexecuted function calls with explicit non-execution outputs so the transcript remains valid for continuation
  • record resumable failures in a generic <turn_aborted> item containing the terminal error
  • add an integration scenario that reaches the default 64-round ceiling, continues, and verifies persistence

Testing

  • make test (36 tests, 0 failures)

Summary by CodeRabbit

  • Bug Fixes

    • Added handling for tool-round limits, ensuring pending tool calls receive clear non-execution errors.
    • Preserved limited or interrupted turns so conversations can continue reliably.
    • Returned the underlying error consistently when execution is interrupted or usage limits are reached.
  • Tests

    • Added coverage for tool-round limits, continuation requests, preserved tool calls, and associated error messages.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The API now handles tool-round exhaustion as an abort condition. It records non-executed function calls with error outputs, preserves the limited turn, returns the original error, and supports continuation. Integration tests cover the 64-round scenario.

Changes

Tool-round limit handling

Layer / File(s) Summary
Abort and tool-call recording
api.cpp
The API detects tool-round exhaustion, records an error for each unexecuted function call, preserves the turn for resumption, and returns the underlying error for interrupted, usage-limited, and tool-round-limited turns.
Limit scenario integration tests
tests/mock-server.rb, tests/005-interruption.sh
The mock server simulates 64 tool-call rounds and continuation. Tests verify the over-limit call, its non-execution output, the continuation request, and persisted conversation history.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: preserving turns that exceed the tool round limit.
Linked Issues check ✅ Passed The changes address issue #5 by persisting limited turns, preserving tool calls, and enabling continuation after the tool-round limit.
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on tool-round-limit handling, turn persistence, and continuation behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/preserve-tool-limit-turn

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/005-interruption.sh (1)

58-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Verify the complete persisted abort record.

T5.6 checks only for call_round_64. Also assert that the conversation log contains the non-execution output and the <turn_aborted> item. This prevents a transcript-invalid persistence regression from passing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/005-interruption.sh` around lines 58 - 59, Update the T5.6 assertion
around the persisted conversation log to verify the complete abort record, not
just call_round_64: assert that the matching JSONL transcript also contains the
non-execution output and the <turn_aborted> item, preserving the existing
expected successful process result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/005-interruption.sh`:
- Around line 58-59: Update the T5.6 assertion around the persisted conversation
log to verify the complete abort record, not just call_round_64: assert that the
matching JSONL transcript also contains the non-execution output and the
<turn_aborted> item, preserving the existing expected successful process result.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3577357b-7d7b-43f2-87c0-053547b658d7

📥 Commits

Reviewing files that changed from the base of the PR and between 8ea30c9 and f963196.

📒 Files selected for processing (3)
  • api.cpp
  • tests/005-interruption.sh
  • tests/mock-server.rb

@paoloanzn
paoloanzn merged commit e1370bc into main Aug 6, 2026
9 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.

(bug) hitting turn limit result in the entire turn getting dropped out of the conversation history

1 participant