#2649·ag-ui

[Bug]: Dart SDK: AgUiClient hard-requires an absolute http(s) baseUrl — no relative-path support for same-origin / reverse-proxied Flutter Web deployments

Author: dragondytCreated Sep 5, 2026Updated Sep 13, 2026
Labelsbug

Pre-flight Checklist

  • I have searched existing issues and this hasn't been reported yet.
  • I am using the latest version AG-UI.

Describe the Bug

AgUiClient in the Dart SDK (sdks/community/dart, published as ag_ui 0.3.0) forces baseUrl to be an absolute http:// / https:// URL. A relative base path (e.g. api/agui or /api/agui) is rejected synchronously inside runAgent, before any request is made. This makes it impossible for a Flutter Web app to point at a backend served from the same origin under a path prefix (or behind a reverse proxy) without hard-coding the deployment origin at build time.

Steps to Reproduce

dart
import 'package:ag_ui/ag_ui.dart';

void main() {
  final client = AgUiClient(
    // Relative base path: backend lives at <page-origin>/api/agui.
    config: AgUiClientConfig(baseUrl: 'api/agui'),
  );
  // Throws synchronously before any request is sent:
  client.runAgent('run', SimpleRunAgentInput(messages: []));
}

ValidationError: Invalid URL format or empty host for "baseUrl" (field: baseUrl) (constraint: valid-url) (value: api/agui)

Expected Behavior

Allow a relative baseUrl (with or without a leading /) and resolve it against the current origin before sending the request — on the web this is Uri.base.resolve(...) semantics. Where no ambient origin exists (VM/native), either reject a scheme-less value with a clear error or require an explicit origin. Optionally: let baseUrl be an empty/optional value on the web so it defaults to the page origin, or accept scheme + host + basePath as separate configuration. Keep the existing strict absolute-URL validation as the default when an absolute URL is supplied (the control-character / credential checks in validateUrl remain valuable) — the ask is to add a supported relative mode, not to weaken the current one.

Environment

- Package: `ag_ui` 0.3.0 (`sdks/community/dart`)
- Target: Flutter Web — the SDK already works there (`package:http` only, no `dart:io`)
- Dart SDK: >= 3.3

Screenshots

No response

Logs & Errors

bash

Additional Context

No response