feat: introduce MAX_TOOL_CALL_ROUNDS constant and add includeEncryptedReasoningContent method to OpenAiResponsesApiDialect

This commit is contained in:
extio-de
2026-05-15 00:00:17 +02:00
parent 63356ab5a7
commit 3cac418191
3 changed files with 19 additions and 2 deletions

View File

@@ -38,6 +38,8 @@ public interface BaseAgent {
static final ObjectMapper objectMapper = new ObjectMapper();
int MAX_TOOL_CALL_ROUNDS = 6;
default String name() {
throw new UnsupportedOperationException("Name must be implemented in the agent");
}
@@ -222,7 +224,7 @@ public interface BaseAgent {
}
if (!completion.toolCalls().isEmpty() && responseHandler instanceof final ToolCallingAgentResponseHandler toolCallingAgentResponseHandler) {
if (toolCallRounds >= 6) {
if (toolCallRounds >= MAX_TOOL_CALL_ROUNDS) {
parseException = new IllegalStateException("Too many tool call rounds");
break;
}

View File

@@ -64,6 +64,21 @@ public interface OpenAiResponsesApiDialect {
return List.of();
}
/**
* Controls whether encrypted reasoning payloads should be requested for
* stateless replay.
* <p>
* lm-lib defaults this to {@code true} so existing Responses tool-call loops keep
* working without additional configuration.
*
* @param modelProfile the resolved model profile for the request
* @return {@code true} to include encrypted reasoning content when replay is
* stateless, otherwise {@code false}
*/
default boolean includeEncryptedReasoningContent(final ModelProfile modelProfile) {
return true;
}
/**
* Caps the number of built-in tool calls the Responses API may execute during a
* single request.

View File

@@ -879,7 +879,7 @@ public class ResponsesApiClient implements Client{
private List<String> createIncludeList(final ModelProfile modelProfile, final boolean store) {
final var include = new LinkedHashSet<>(this.responsesDialect().include(modelProfile));
if (!store) {
if (!store && this.responsesDialect().includeEncryptedReasoningContent(modelProfile)) {
include.add(OpenAiResponsesApiDialect.INCLUDE_REASONING_ENCRYPTED_CONTENT);
}
return List.copyOf(include);