u/SparkleMing

dart_agent_core now supports full lifecycle hooks for building AI agent loops in Flutter
▲ 1 r/dartlang+1 crossposts

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.

Pub.dev Github

u/SparkleMing — 4 days ago
▲ 8 r/dartlang+1 crossposts

I built dart_agent_core — a Dart framework for stateful, tool-using AI agents

The reason I built it is simple: I wanted a Flutter app to run the agent loop itself, without needing a Python or Node backend service just to handle tool calls, memory, streaming, and state. I also added an eval system for the same reason. I wanted to test real agent behavior against the same Dart code used in production, instead of rewriting the agent in Python or Node just to use an existing eval framework. Hoping to get some feedback.

GitHub
Pub.dev

u/SparkleMing — 1 month ago