agentleFS
aaziraniaazirani/flutter_agentify/.agents/skills/model-providers/SKILL.md

model-providers

Skill0 starsChanged 4 days agoMITView on GitHub

Which model servers the assistant can talk to, what a preset sets, and where a model's abilities are configured. Use when choosing, adding or debugging a model provider, a preset, tool calling, or "the assistant cannot reach the model".

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Don't load this for keeping the API key safe.

    line 8

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Model providers

Don't load this for keeping the API key safe; see secrets. For a server that holds the key, see backend-proxy.

Rule

The app reaches a model only through an LlmProvider built by buildProvider(presetId:, baseUrl:, apiKey:) from packages/flutter_agentify_core/lib/src/llm/provider_presets.dart. What a model can do (toolCalling, streaming, contextWindow, maxOutputTokens) belongs to the ModelConfig, never to the provider. Enforced by the provider conformance tests in packages/flutter_agentify_core/test/llm/conformance.dart, run by openai_compatible_provider_test.dart and anthropic_provider_test.dart in the same folder.

Why

One Ollama server can host a model with tool calling and one without. If abilities sat on the provider, the second model would be sent tools it cannot use. Every provider must also behave the same (stream text and tool calls, end with one LlmDone, report failures as LlmError), so the agent loop never needs to know which one it has.

How

  • Where the model runs is set in lib/ai/assistant_setup.dart: ModelMode.server, ModelMode.onDevice or ModelMode.both. lib/ai/model_route.dart picks who answers the next message (AnsweredBy); the route changes only between replies. ServerSetup holds the server's defaults; userEditable: false makes them final and leaves set_assistant_provider and set_api_key out of the registry. The Flutter Agentify guide Choose where the model runs explains the modes.
<!-- @on-device:begin -->
  • The model inside the app is packages/flutter_agentify_on_device (only in projects set up with --model both or on-device): EdgeAiEngine, OnDeviceProvider and the gemma4E2b spec. Its lifecycle is OnDeviceModelController in core. Test with FakeOnDeviceEngine and InMemoryLoadMarker from package:flutter_agentify_core/testing.dart; never download the model in a test.
<!-- @on-device:end -->
  • Presets: ollama, lm_studio, openai, openrouter, gemini, anthropic, custom. Everything except anthropic is an OpenAiCompatibleProvider; custom starts with an empty address. keyUse on each preset says whether it takes a key: none for ollama and lm_studio, optional for custom, required for the hosted ones. Each preset keeps its own key.
  • Each preset carries defaults, a ModelConfig. lib/ai/assistant_providers.dart copies it with the saved model name, toolCalling and contextWindow. The settings form (lib/presentation/settings/assistant_settings_section.dart) stores only the values that differ from the preset.
  • Small context windows: when the tool list would exceed AgentConfig.toolSearchShare (default 0.25) of the window, the session sends only the best matches plus a tool_search tool (packages/flutter_agentify_core/doc/agent-loop.md). Give an action searchHints so it is found.
  • Answer-only mode: when the model has toolCalling: false, or the server answers that tools are unsupported, the session sends no tools and the chat shows answerOnlyNotice. Do not work around it; turn the switch off for that model.
  • A phone cannot reach the computer's localhost. On a real device or emulator, the Ollama and LM Studio presets need the computer's address on the network (for example http://192.168.1.20:11434/v1), and the server must listen on that interface. Android emulators use 10.0.2.2 for the host machine. See permissions-and-platform for the cleartext and local-network settings this needs.
  • Web: the browser enforces CORS. Use a server that sends CORS headers, or your own proxy (backend-proxy). No key is entered or stored on web, so the settings form leaves out the presets whose keyUse is required.
  • Adding a provider means a class implementing LlmProvider, a row in the conformance run, and a preset. The full contract is in packages/flutter_agentify_core/doc/model-providers.md.

Anti-patterns

  • Hard-coding toolCalling: true for a provider instead of for a model.
  • Putting a model name or key in source to "make the preset work".
  • Treating a plain LlmError as final: check retryable, contextOverflow and toolsUnsupported first.
  • Testing against a real server. Use ScriptedProvider from package:flutter_agentify_core/testing.dart (see testing).

Verification

  • cd packages/flutter_agentify_core && dart test test/llm runs the conformance tests and provider_presets_test.dart.
  • test/presentation/settings/assistant_settings_section_test.dart covers the settings form.
  • test/ai/model_route_test.dart and test/ai/assistant_setup_test.dart cover the modes and the setup file.
<!-- @on-device:begin -->
  • tool/measure_on_device.sh -d <device> measures the in-app model on a real device.
<!-- @on-device:end -->
  • tool/check.sh runs all of it (see verify).

Related skills

  • secrets — where the key lives
  • backend-proxy — when the key must stay on a server
  • customizing-the-assistant — instructions and chat text
  • testing — scripting a model in tests

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.