Claus Ibsen created CAMEL-26203:
-----------------------------------

             Summary: camel-langchain4j-web-search - a WebSearchRequest bean in 
the registry replaces the message body on every endpoint
                 Key: CAMEL-26203
                 URL: https://issues.apache.org/jira/browse/CAMEL-26203
             Project: Camel
          Issue Type: Bug
          Components: camel-langchain4j-web-search
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of langchain4j-web-search 
(CAMEL-24961, PR #28401).

h4. 1. A single WebSearchRequest bean in the registry silently replaces the 
body on every endpoint

The {{webSearchRequest}} option of {{LangChain4jWebSearchConfiguration}} (main 
2a465aa4814c, line 59) is {{autowired = true}}. With one {{WebSearchRequest}} 
bean in the registry every langchain4j-web-search endpoint uses it, and 
{{LangChain4jWebSearchProducer}} (lines 46-49) builds the request from the body 
only when that option is null, so the search terms in the body are ignored. The 
bean's {{maxResults}} is then used too (line 70): unless it is 1 (it is null 
when not set) the output becomes a List instead of a single result (line 95). 
Checked on 4.24.0-SNAPSHOT with a fake {{WebSearchEngine}}.

Proposed: do not autowire {{webSearchRequest}} (it is an advanced, per-endpoint 
option).

h4. 2. With maxResults=1 a result without content gives null, like no result

With {{maxResults=1}} and {{resultType=CONTENT}} (the default), 
{{computeResponse}} (line 98) sets the body to {{content()}} of the first 
result, which is null when the engine returns only a title, link and snippet. 
The route cannot tell this from "no result" (line 90 also sets null). Checked 
on 4.24.0-SNAPSHOT with a fake {{WebSearchEngine}}.

Proposed: fall back to the snippet when the content is null, or document that 
CONTENT may be null for a found result.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to