AI / LangGraph LangChain Interview questions
What is AgentExecutor?
AgentExecutor is the runtime loop that drives an agent to completion. It takes an agent (which decides actions) and a list of tools (which execute those actions), and repeatedly calls the agent, executes the selected tool, feeds the observation back, and repeats until the agent returns an AgentFinish or a stopping condition is reached.
from langchain.agents import AgentExecutor
executor = AgentExecutor(
agent=agent,
tools=tools,
verbose=True, # print each step
max_iterations=10, # prevent infinite loops
return_intermediate_steps=True, # include tool call history in output
handle_parsing_errors=True, # auto-retry if output parse fails
)
result = executor.invoke({"input": "Find the CEO of Anthropic"})
print(result["output"]) # final answer
print(result["intermediate_steps"]) # list of (AgentAction, observation)
Key configuration options: max_iterations prevents runaway loops, max_execution_time adds a wall-clock timeout, early_stopping_method controls whether the agent generates a final answer when max_iterations is hit or just stops, and handle_parsing_errors retries if the LLM produces malformed output instead of crashing the loop.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
