@cloudflare/think@0.4.0
cloudflare/agents@cloudflare/think@0.4.0Apr 23, 2026by github-actions[bot]
AI Summary
This release aligns the `Think` class generics with `Agent` and `AIChatAgent`, changing from `Think<Env, Config>` to `Think<Env, State, Props>` which extends `Agent<Env, State, Props>`. The `configure()` and `getConfig()` methods remain but now use method-level generics instead of class-level generics.
Key Highlights
- `Think` now uses `Think<Env, State, Props>` and extends `Agent<Env, State, Props>`
- Subclasses get properly typed `this.state`, `this.setState()`, `initialState`, and `this.ctx.props`
- The previous `Config` class generic is removed
- `configure()` and `getConfig()` now use method-level generics (e.g., `this.getConfig<MyConfig>()`)
- Aligns Think with the typing pattern used by `Agent` and `AIChatAgent`
Breaking Changes
- The second type parameter of `Think` (previously used for `Config`) is removed
- Code using `Think<Env, MyConfig>` must be updated to `Think<Env>` and use method-level generics
- Direct `configure(...)` / `getConfig()` call sites relying on class-level `Config` type need updating
Full Release Notes
### Minor Changes
- [#1350](https://github.com/cloudflare/agents/pull/1350) [`3a1140f`](https://github.com/cloudflare/agents/commit/3a1140fa561fdff5d1925f0c2b3b7436af8b483f) Thanks [@threepointone](https://github.com/threepointone)! - Align `Think` generics with `Agent` / `AIChatAgent`.
`Think` is now `Think<Env, State, Props>` and extends `Agent<Env, State, Props>`, so subclasses get properly typed `this.state`, `this.setState()`, `initialState`, and `this.ctx.props`. The previous `Config` class generic is removed.
`configure()` and `getConfig()` remain, but the config type is now specified at the call site via a method-level generic:
```ts
// Before
export class MyAgent extends Think<Env, MyConfig> {
getModel() {
const tier = this.getConfig()?.modelTier ?? "fast";
// ...
}
}
// After
export class MyAgent extends Think<Env> {
getModel() {
const tier = this.getConfig<MyConfig>()?.modelTier ?? "fast";
// ...
}
}
```
This is a breaking change for anyone using the second type parameter of `Think`. Update the class declaration and any direct `configure(...)` / `getConfig()` call sites that relied on the class-level `Config` type.