any deliberately, not Record<string, unknown>: session state is a
genuinely dynamic bag created by the agent's state factory, and tool()
can only learn its real shape from an annotated context. The stricter
default made the ordinary spelling
(execute: (a, ctx) => ctx.state.cart.push(a)) a compile error even
though it runs correctly — and once aai build/aai deploy started
running the project's own tsc, that refused to publish working agents
without catching bugs.
Default type of
ctx.statewhen an agent does not declare one —any, so untyped state access compiles. Opt into real checking by annotating the context (ctx: ToolContext<Cart>), which also makes the agent verify the tool against its own state shape.