Unexpected WebSearchTool loop for some prompts when using additional tools
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Área
- api, testing-qa
Línea de trabajo
Comienza ejecutando el testUnexpectedWebsearchLoop proporcionado con query1 y query2, ambas configuraciones de herramientas y los dos tipos de WebSearchTool. Sigue la ruta de streaming de la Responses API y la salida de ResponseAccumulator para determinar si las llamadas repetidas se originan en el SDK o en el backend. Se considera terminado cuando se haya explicado la reproducción y se hayan restaurado el tamaño de salida esperado y el comportamiento de maxToolCalls, o cuando el issue se haya escalado con evidencias.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hey there,
I'm encountering unexpected behavior when using the built-in WebSearchPreview tool in conjunction with other tools in Responses API streaming-mode. Sometimes WebSearchTool gets stuck in an unexpected loop resulting in multiple search queries and multiple text messages. Sometimes both the queries and text messages from the LLM are even identical.
I'm not sure if this is a bug in the OpenAI Java SDK or in the OpenAI backend WebSearchPreview itself. If it's not a library bug, please forward this issue to an OpenAI developer, as I've figured out a few details about the issue which might be helpful.
Observed behavior:
- WebSearch called
- OutputText deltas sent
- WebSearch called again
- OutputText deltas sent
- rinse repeat
- Final Response contains multiple TextMessages and WebSearchMessages
Expected behavior:
- WebSearch called
- OutputText deltas sent
- Final Response contains just 1 TextMessage and 1 WebSearchMessage
When does the problem occur?
- Only for some prompts (problem never occurs for some prompts and almost always for other prompts, see examples below)
- Only when additional tools are added (problem never occurs with only WebSearchTool present)
- The problem also occurs when using
WebSearchTool.Type.WEB_SEARCH_PREVIEW_2025_03_11instead ofWebSearchTool.Type.WEB_SEARCH_PREVIEW.
How to reproduce the issue?
Here's unit test which reproduces the problem 99% of the time (on my machine at least). The test contains two queries: query1 almost always fails and query2 always succeeds in a dozen of tries. When using query1 and removing the line .addTool(BookTool::class.java), then query1 also always succeeds. So the problem is directly tied to number of tools added to the request.
Also WebSearchTool ignores .maxToolCalls(2) and often gets called more than twice.
@Test
fun testUnexpectedWebsearchLoop() {
// test fails with this query when using additional tools
val query1 = "Suche im Internet nach den Preisen von Amazon Bedrock in Deutschland und erkläre, wie sich die Preise zusammensetzen."
// test succeeds with this query regardless of additional tools
val query2 = "Suche nach Neuigkeiten im deutschen Buchmarkt."
val params = ResponseCreateParams.builder()
.input(query1)
.model(ChatModel.GPT_4_1)
.temperature(1.0)
.addTool(BookTool::class.java) // test succeeds without this additional tool
.addTool(
WebSearchTool.builder()
.type(WebSearchTool.Type.WEB_SEARCH_PREVIEW)
// .type(WebSearchTool.Type.WEB_SEARCH_PREVIEW_2025_03_11) // same behavior
.searchContextSize(WebSearchTool.SearchContextSize.LOW)
.userLocation(
WebSearchTool.UserLocation.builder()
.country("DE")
.build()
)
.build()
)
.promptCacheKey("demo")
.maxToolCalls(2)
.store(false)
.build()
val responseAccumulator = ResponseAccumulator.create()
client.responses().createStreaming(params).use { streamingResponse ->
streamingResponse.stream()
.peek(responseAccumulator::accumulate)
.forEach {
if (it.isWebSearchCallInProgress()) {
println(">> webSearchCallInProgress")
}
}
}
val output = responseAccumulator.response().output()
Assertions.assertEquals(2, output.size)
}
Please let me know if you need more information to reproduce the issue.
- Lenguaje dominante
- Kotlin
- Estrellas
- 1.5k
- Forks
- 264
- Merge medio
- 13 h 31 min
- PR fusionados (30 d)
- 89
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openai/openai-java
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
openai/openai-java#890 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
openai/openai-java#886 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
openai/openai-java#802 · 2 comentarios · 3 reacciones ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
openai/openai-java#755 · 1 comentario ·
-
bug sdk
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
openai/openai-java#652 · 2 comentarios ·
Todos los issues de openai/openai-java
Issues similares
-
[Bug] 统计页面无法重置token和汇率 Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
AAswordman/Operit#1265 · 3 comentarios ·
-
The extension stopped working. AbiertoSource is down
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
keiyoushi/extensions-source#19317 ·
-
Tambahkan bahasa Indonesia Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
acristescu/OnlineGo#216 ·
-
Remove custom segment colors Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
libre-tube/LibreTube#8803 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100