# Subscribing to events

import CodeBlock from "@theme/CodeBlock";
import DebuggingExample from "@examples/models/chat/chat_debugging.ts";

Especially when using an agent, there can be a lot of back-and-forth going on behind the scenes as a Chat Model 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 Chat Model, you can pass callbacks to the Chat Model 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>
