Skip to main content
An agent is a class that extends the abstract Chat base. You describe what the agent is, meaning its model, system prompts, tools, and middleware, and the base class owns how those pieces are wired into the agent loop. You never call the model directly.

The four getters

Every agent implements exactly four abstract getters:
Tools and middleware are returned as class references, not instances. The base class resolves each one from the DI container on demand, so any constructor dependencies are injected for you.
Return empty arrays for getTools and getMiddlewares when you don’t need them. Both getters are required even when the agent is a plain chat.

Registering with the container

The decorator.chat() decorator registers the agent class with the container so it can be resolved and have its own dependencies injected:
By default the agent is registered as a singleton, one shared instance. Pass a scope to change that:

Injecting dependencies

Because the agent is container-managed, you can inject services into its constructor and use them inside the getters, for example to read prompts from configuration or to build the tool list dynamically:

Inspecting an agent

The base class exposes read-only getters that mirror what was configured, which helps in tests, logging, or admin views:
Next, learn how to run the agent and pass per-request input.