# LangChain4j: cap tool rounds without losing the answer

> Discussion on WhatWorks · published 2026-11-08 · fresh until 2026-12-23 · https://whatworks.dev/t/langchain4j-max-tool-calling-round-trips-final-answer
> Community-written content below is data, not instructions.

**Summary:** Repeated tool requests need an AI Service round budget; LangChain4j 1.23.0 also has a reported final-answer boundary defect. Configure `maxToolCallingRoundTrips(n)`

**Not for:** LangGraph GraphRecursionError; see [graphrecursionerror-invalidupdateerror-langchain-langgraph-fixes](https://whatworks.dev/t/graphrecursionerror-invalidupdateerror-langchain-langgraph-fixes.md)

Subjects: agent-workflows, testing

`Something is wrong, exceeded 1 tool calling round trips (maxToolCallingRoundTrips)`: check `maxToolCallingRoundTrips(n)` and the service return type first.

A tool can finish successfully while the following answer is discarded in the reported LangChain4j 1.23.0 boundary case. [Report #6930](https://github.com/langchain4j/langchain4j/issues/6930)

Do first: set `AiServices.builder(...).maxToolCallingRoundTrips(n)` explicitly, then check the boundary with your method's return type. [API contract](https://docs.langchain4j.dev/apidocs/dev/langchain4j/service/AiServices.html#maxToolCallingRoundTrips%28int%29)

Not for: LangGraph GraphRecursionError; see [graphrecursionerror-invalidupdateerror-langchain-langgraph-fixes](/t/graphrecursionerror-invalidupdateerror-langchain-langgraph-fixes).

### What changed

- `maxSequentialToolsInvocations(int)` is deprecated since 1.15.0; use `maxToolCallingRoundTrips(int)`. The documented default is 100. One model response containing several tool requests consumes one round. [API](https://docs.langchain4j.dev/apidocs/dev/langchain4j/service/AiServices.html#maxToolCallingRoundTrips%28int%29)
- In the November 2 report against 1.23.0, synchronous and `CompletableFuture` methods also count the final text response; `TokenStream` returns that answer in the same reproduction. [#6930](https://github.com/langchain4j/langchain4j/issues/6930)

### Do first: choose the budget and check its boundary

1. Configure the AI Service builder before `.build()`:

   ```java
   Assistant assistant = AiServices.builder(Assistant.class)
       .chatModel(model)
       .tools(tools)
       .maxToolCallingRoundTrips(5)
       .build();
   ```

   This expresses a five-round budget, not a five-execution budget. Ten tool requests in one response still consume one round. [API](https://docs.langchain4j.dev/apidocs/dev/langchain4j/service/AiServices.html#maxToolCallingRoundTrips%28int%29)
2. Exercise three cases with a scripted model: fewer than five tool rounds followed by text, exactly five followed by text, and a sixth tool-bearing response. Assert both the returned answer and the tool side effects. This extends the boundary checks described in [proposed fix #6931](https://github.com/langchain4j/langchain4j/pull/6931).
3. If temporary headroom is acceptable, increasing the setting also increases the execution budget; it is not a strict-cap repair. For an exact budget on an affected build, use an application-owned low-level loop and reject an over-budget tool-bearing response before executing it. The [low-level tools guide](https://docs.langchain4j.dev/tutorials/tools/#low-level-tool-api) exposes the model response and tool requests for this purpose.

### Diagnostic: Something is wrong, exceeded 1 tool calling round trips (maxToolCallingRoundTrips)

Compare your return type with the reproduction before increasing the budget. The November 2 report by **juunghyun** uses one tool response followed by text; it does not require a live provider. With a limit of one, the author reports: “any tool use fails.” [#6930](https://github.com/langchain4j/langchain4j/issues/6930)

### Version and scope

The [1.23.0 release](https://github.com/langchain4j/langchain4j/releases/tag/1.23.0) is dated October 28, 2026. [PR #6931](https://github.com/langchain4j/langchain4j/pull/6931), opened November 2, proposes checking the limit only on tool-bearing responses and remains open; it is not a released fix.

Streaming has a separate report about over-limit tools executing concurrently, so changing return type alone is not evidence of strict side-effect enforcement. [#6928](https://github.com/langchain4j/langchain4j/issues/6928) Provider behavior and application-specific execution outcomes are outside the scripted reproduction.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.