
dart_agent_core now supports full lifecycle hooks for building AI agent loops in Flutter
I’ve been working on dart_agent_core, a Dart package for running AI agents directly inside Flutter apps, without needing a Python or Node backend for the agent loop. The latest update adds a unified AgentHook pipeline plus observation-only AgentController events. This is useful if you are building agent loops or runtime/eval harnesses. Instead of only sending a prompt and waiting for a final answer, you can now intercept the loop as it runs:
- Use beforeModelCall to inject temporary context, change tools, adjust model config, or return a synthetic model response.
- Use afterModelCall to validate a response, retry, or replace the final model message.
- Use beforeToolCall to approve, deny, defer, or rewrite tool calls.
- Use afterToolCall to normalize tool results, inject follow-up context, or stop the loop.
- Use onTurnCompletion to continue the loop when the model stops too early.
- Use persistence hooks to decide when state should be saved.
- Use AgentController events for tracing, debugging, evals, and Flutter UI updates.