feat: introduce MAX_TOOL_CALL_ROUNDS constant and add includeEncryptedReasoningContent method to OpenAiResponsesApiDialect
This commit is contained in:
@@ -38,6 +38,8 @@ public interface BaseAgent {
|
|||||||
|
|
||||||
static final ObjectMapper objectMapper = new ObjectMapper();
|
static final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
int MAX_TOOL_CALL_ROUNDS = 6;
|
||||||
|
|
||||||
default String name() {
|
default String name() {
|
||||||
throw new UnsupportedOperationException("Name must be implemented in the agent");
|
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 (!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");
|
parseException = new IllegalStateException("Too many tool call rounds");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,21 @@ public interface OpenAiResponsesApiDialect {
|
|||||||
return List.of();
|
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
|
* Caps the number of built-in tool calls the Responses API may execute during a
|
||||||
* single request.
|
* single request.
|
||||||
|
|||||||
@@ -879,7 +879,7 @@ public class ResponsesApiClient implements Client{
|
|||||||
|
|
||||||
private List<String> createIncludeList(final ModelProfile modelProfile, final boolean store) {
|
private List<String> createIncludeList(final ModelProfile modelProfile, final boolean store) {
|
||||||
final var include = new LinkedHashSet<>(this.responsesDialect().include(modelProfile));
|
final var include = new LinkedHashSet<>(this.responsesDialect().include(modelProfile));
|
||||||
if (!store) {
|
if (!store && this.responsesDialect().includeEncryptedReasoningContent(modelProfile)) {
|
||||||
include.add(OpenAiResponsesApiDialect.INCLUDE_REASONING_ENCRYPTED_CONTENT);
|
include.add(OpenAiResponsesApiDialect.INCLUDE_REASONING_ENCRYPTED_CONTENT);
|
||||||
}
|
}
|
||||||
return List.copyOf(include);
|
return List.copyOf(include);
|
||||||
|
|||||||
Reference in New Issue
Block a user