Discover external assistant agents from models endpoint

Merged
JJ
2mo ago
+600-73

Summary

  • discover available external agents from the authenticated sibling /v1/models endpoint
  • require users to select a returned agent and send its ID verbatim as the chat-completions model
  • keep the external gateway in control of the underlying LLM while retaining the legacy routing-header override
  • add an External AI information panel, configuration docs, environment examples, and regression coverage

Test plan

  • PARALLEL_WORKERS=1 bundle exec rails test test/models/assistant/external/model_catalog_test.rb test/models/assistant/external/client_test.rb test/models/assistant/external_config_test.rb test/controllers/settings/hostings_controller_test.rb
  • bundle exec rubocop app/controllers/settings/hostings_controller.rb app/models/assistant/external.rb app/models/assistant/external/client.rb app/models/assistant/external/model_catalog.rb app/models/setting.rb test/controllers/settings/hostings_controller_test.rb test/models/assistant/external/client_test.rb test/models/assistant/external_config_test.rb test/models/assistant/external/model_catalog_test.rb
  • bundle exec erb_lint app/views/settings/hostings/_assistant_settings.html.erb
  • visually verified /settings/hosting in self-hosted mode with a local gateway returning multiple agent IDs

Summary by CodeRabbit

  • New Features
    • External assistant settings let you choose a model discovered through the configured gateway. The selected model is validated, and discovery or loading errors are shown in settings.
    • Settings include guidance about endpoint configuration, model discovery, routing, and request errors.
  • Configuration
    • External assistant requests use the selected model, defaulting to openclaw/main when none is selected. The legacy agent ID is used only when no model is selected.
    • When a changed endpoint does not offer the current model, settings ask you to select another.
  • Documentation
    • Added setup guidance for the external chat assistant, including required configuration and streaming support.