Skip to main content

Logging and tracing

You can pass the verbose flag when creating an agent to enable logging of all events to the console. For example:

You can also enable tracing by setting the LANGCHAIN_TRACING environment variable to true.

npm install @langchain/openai
import { initializeAgentExecutorWithOptions } from "langchain/agents";
import { OpenAI } from "@langchain/openai";
import { Calculator } from "langchain/tools/calculator";
import { SerpAPI } from "@langchain/community/tools/serpapi";

const model = new OpenAI({ temperature: 0 });
const tools = [
new SerpAPI(process.env.SERPAPI_API_KEY, {
location: "Austin,Texas,United States",
hl: "en",
gl: "us",
new Calculator(),

const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "zero-shot-react-description",
verbose: true,

const input = `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`;

const result = await executor.invoke({ input });


{ output: '2.2800773226742175' }

API Reference: