Same order assistant in both frameworks against a local fake OpenAI server: starter bean collision, wire differences, tool failure and loop bounds, observability meters, MCP-first tools, and a compile check of the 2025 article's snippets and Maven coordinates. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01G8ikz8xdWuTP5yun8DZ1hk
42 lines
2.9 KiB
Plaintext
42 lines
2.9 KiB
Plaintext
# The same order assistant in Spring AI and in LangChain4j, one question: "Where is ORD-1001?"
|
|
|
|
Spring AI : ChatClient.builder(model).defaultSystem(..).defaultTools(new SpringAiTools(orders))
|
|
LangChain4j: AiServices.builder(Support.class).chatModel(model).tools(new Lc4jTools(orders))
|
|
|
|
Spring AI answer : Done: "Order ORD-1001: Status=SHIPPED, ETA=2026-10-14"
|
|
LangChain4j answer : Done: Order ORD-1001: Status=SHIPPED, ETA=2026-10-14
|
|
HTTP requests sent : Spring AI 2, LangChain4j 2. Tool body executed: Spring AI 1, LangChain4j 1.
|
|
|
|
What differs on the wire (computed from the four bodies below):
|
|
top-level fields : Spring AI [messages, model, tools], LangChain4j [messages, model, stream, tools]
|
|
tool schema : Spring AI has $schema=true additionalProperties=true; LangChain4j has $schema=false additionalProperties=false
|
|
tool result message: Spring AI sent "\"Order ORD-1001: Status=SHIPPED, ETA=2026-10-14\"", LangChain4j sent "Order ORD-1001: Status=SHIPPED, ETA=2026-10-14"
|
|
|
|
--- Spring AI, request 1
|
|
fields: [messages, model, tools]
|
|
system: "You are a customer support agent. Use the tools for order questions. Be concise."
|
|
user: "Where is ORD-1001?"
|
|
tool getOrderStatus - Get current order status by order ID params {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"orderId":{"type":"string","description":"The unique identifier of the order"}},"required":["orderId"],"additionalProperties":false}
|
|
|
|
--- Spring AI, request 2
|
|
fields: [messages, model, tools]
|
|
system: "You are a customer support agent. Use the tools for order questions. Be concise."
|
|
user: "Where is ORD-1001?"
|
|
assistant: tool_call getOrderStatus {"orderId":"ORD-1001"}
|
|
tool: ""Order ORD-1001: Status=SHIPPED, ETA=2026-10-14""
|
|
tool getOrderStatus - Get current order status by order ID params {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"orderId":{"type":"string","description":"The unique identifier of the order"}},"required":["orderId"],"additionalProperties":false}
|
|
|
|
--- LangChain4j, request 1
|
|
fields: [messages, model, stream, tools]
|
|
system: "You are a customer support agent. Use the tools for order questions. Be concise."
|
|
user: "Where is ORD-1001?"
|
|
tool getOrderStatus - Get current order status by order ID params {"type":"object","properties":{"orderId":{"type":"string","description":"The unique identifier of the order"}},"required":["orderId"]}
|
|
|
|
--- LangChain4j, request 2
|
|
fields: [messages, model, stream, tools]
|
|
system: "You are a customer support agent. Use the tools for order questions. Be concise."
|
|
user: "Where is ORD-1001?"
|
|
assistant: tool_call getOrderStatus {"orderId":"ORD-1001"}
|
|
tool: "Order ORD-1001: Status=SHIPPED, ETA=2026-10-14"
|
|
tool getOrderStatus - Get current order status by order ID params {"type":"object","properties":{"orderId":{"type":"string","description":"The unique identifier of the order"}},"required":["orderId"]}
|