Skip to content

Dart Chat App

This example focuses on how agentos-sdk-dart and chatkit_dart fit together.

If you are using an AI coding tool, treat this page as reference truth for ChatKit integration structure.
If the generated Flutter chat integration disagrees with the docs, compare it against the minimal skeleton here first.

text
Use the AgentOS Dart chat app example as the reference shape and generate a ChatKit integration in my Flutter project that stays as close to that structure as possible.

Requirements:
- Use AgentOsConfig for connection info
- Use ChatKitRuntime for shared session management and background preconnect
- Use AgentSidebar as the chat UI entry point
- Preserve host-page control over config save, logout, and bridge decisions
- Do not blur the responsibilities of chatkit_dart and agentos_sdk

Typical structure

A minimal Flutter chat app usually includes:

  • AgentOsConfig for baseUrl, bundleId, and other connection info
  • ChatKitRuntime for shared session management and background preconnect
  • AgentSidebar as the chat UI entry point
  • a host page that owns config persistence, logout, and bridge decisions

Minimal integration skeleton

dart
late final ChatKitRuntime runtime;

@override
void initState() {
  super.initState();
  runtime = ChatKitRuntime(config: config);
  unawaited(runtime.start());
}

@override
Widget build(BuildContext context) {
  return AgentSidebar(
    runtime: runtime,
    config: config,
    onConfigSaved: (next) async {
      runtime.updateConfig(next);
    },
    onLogout: () async {
      await runtime.stop();
    },
  );
}

Follow-up suggestions

  • If you want custom copy, use AgentSidebarStrings
  • If you want to inject business tools, pass tool into AgentSidebar
  • If you need system-event handling, make onSystemCallApp the central decision point

AI mistakes to watch for

  • Treating ChatKit as the capability-layer SDK and skipping agentos_sdk
  • Removing host ownership over config persistence and logout
  • Omitting ChatKitRuntime, which weakens shared message flow and background preconnect
  • Auto-executing system-call bridging without any trust or policy checks

Manual verification checklist

  • Does the structure still look like AgentOsConfig -> ChatKitRuntime -> AgentSidebar -> host decision point?
  • Does it preserve host callbacks such as onConfigSaved and onLogout?
  • Does it leave explicit positions for tool injection and onSystemCallApp?