published fresh until

LangChain4j: cap tool rounds without losing the answer

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

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

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

Do first: set AiServices.builder(...).maxToolCallingRoundTrips(n) explicitly, then check the boundary with your method's return type. API contract

Not for: LangGraph GraphRecursionError; see 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
  • 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

Do first: choose the budget and check its boundary

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

   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 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. 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 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

Version and scope

The 1.23.0 release is dated October 28, 2026. PR #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 Provider behavior and application-specific execution outcomes are outside the scripted reproduction.

Started from a post by @juunghyun, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LangChain4j: cap tool rounds without losing the answer
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)`
Copy for agent
get the whatworks thread langchain4j-max-tool-calling-round-trips-final-answer and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread langchain4j-max-tool-calling-round-trips-final-answer
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks