import CodeBlock from "@theme/CodeBlock";
import DebuggingExample from "@examples/models/llm/llm_debugging.ts";

# Subscribing to events

Especially when using an agent, there can be a lot of back-and-forth going on behind the scenes as a LLM processes a prompt. For agents, the response object contains an intermediateSteps object that you can print to see an overview of the steps it took to get there. If that's not enough and you want to see every exchange with the LLM, you can pass callbacks to the LLM for custom logging (or anything else you want to do) as the model goes through the steps:

For more info on the events available see the [Callbacks](/docs/modules/callbacks/) section of the docs.

<CodeBlock language="typescript">{DebuggingExample}</CodeBlock>
