1Z0-1157-26 practice question 8 of 10

You are implementing an AI agent using LangChain that must retrieve product information from a database and compose recommendations. The agent needs to handle cases where the product database is temporarily unavailable. Which LangChain core abstractions should you combine to accomplish this, and what is the correct flow?

Full set: 67 questions
Answer options
A: Use a chat model for reasoning, define a tool that wraps the database call with retry logic, include it in the agent's tool set, and let the agent orchestration loop decide when to invoke the tool based on the user's request Correct answer
B: Hard-code all product recommendations in the prompt so the agent never needs to call external tools
C: Use only the LangChain prompt abstraction to store product data directly in the system message
D: Configure the chat model to call the database directly without wrapping it as a tool, since tools add unnecessary latency
E: Build a separate rule-based workflow instead of using LangChain agents since agents cannot handle tool failures
Correct Answer:
A. Use a chat model for reasoning, define a tool that wraps the database call with retry logic, include it in the agent's tool set, and let the agent orchestration loop decide when to invoke the tool based on the user's request
Explanation

In LangChain, agents decouple reasoning from execution by using a chat model as the reasoning engine and wrapping external capabilities as standardized tools. When connecting to an external database that may experience transient failures, best practices dictate encapsulating the database client logic inside a tool function that incorporates explicit retry strategies and error handling. The agent orchestration loop evaluates user input, decides when to call the database tool, receives the tool's execution results or fallback responses, and synthesizes a recommendation. This abstraction maintains system resilience while allowing the language model to dynamically decide execution timing based on conversational context.

Why Incorrect

B: Hard-coding recommendations in prompt templates prevents dynamic data fetching and fails when database product inventories change frequently. C: Storing product data inside system prompts causes context window overflow and cannot accommodate real-time, large-scale database lookup requirements. D: Large language models cannot natively connect directly to database servers without an intermediary tool wrapper that handles API execution. E: LangChain agents support robust error handling and retry mechanisms within tool implementations and agent control loops.

References

- LangChain Documentation: Agents, Tools, and Custom Tool Integration with Retry Strategies. https://python.langchain.com/docs/modules/agents/

- Oracle Developer Documentation: Integrating Generative AI and LLM Orchestration Frameworks with Autonomous Databases.

- Chase, H. (2022). LangChain Framework for Large Language Model Applications. https://github.com/langchain-ai/langchain

Scroll to Top