Skip to content

Add pluggable provider routing for local and hosted backends#1

Open
Pro777 wants to merge 11 commits intomainfrom
Pro777/rowan-llm-ports
Open

Add pluggable provider routing for local and hosted backends#1
Pro777 wants to merge 11 commits intomainfrom
Pro777/rowan-llm-ports

Conversation

@Pro777
Copy link
Copy Markdown

@Pro777 Pro777 commented Apr 23, 2026

Summary

Downstream integration PR for Spitfire-Cowboy/ml-intern.

This branch does two distinct things:

  • pulls in the relevant upstream provider-layer work (#55, #60, #63, #66)
  • adds Rowan-specific runtime, policy, and config work on top of that provider layer

This is the fork-side answer to upstream issue huggingface/ml-intern#67.

Review map

1. Provider architecture and upstream-aligned changes

  • adapter-based LLM resolution
  • config-driven provider catalog
  • Bedrock support
  • model-switch auth hardening

2. Rowan and local-backend support

  • openrouter/<model>
  • lm_studio/<model>
  • opencode/<model>
  • opencode-go/<model>
  • mlx/<model>
  • ollama/<model>
  • bld/<model>
  • openai-compat/<model>

3. Rowan operator usability

  • local lane reachability hints in /model
  • opt-in rowan-mcp wiring from env
  • default safe allowlist for Rowan MCP tools
  • Rowan preset config profiles
  • runtime preset selection via env

Rowan-specific defaults

  • mlx/ -> MLX_SERVER_URL default http://localhost:8080/v1
  • ollama/ -> OLLAMA_BASE_URL default http://localhost:11434/v1
  • bld/ -> BLD_OLLAMA_BASE_URL default http://192.168.50.252:11434/v1

Rowan MCP behavior

  • ML_INTERN_ENABLE_ROWAN_MCP=1 auto-injects rowan-mcp if the config does not already define it
  • ROWAN_MCP_URL and optional ROWAN_MCP_TOKEN drive that injected server
  • empty Rowan auth headers are stripped before MCP client creation
  • default Rowan MCP exposure is a safe allowlist, not the full Rowan surface
  • policy overrides:
    • ROWAN_MCP_ALLOW_ALL_TOOLS=1
    • ROWAN_MCP_ALLOWED_TOOLS=...
    • ROWAN_MCP_BLOCKED_TOOLS=...

Config profiles

Available presets:

  • default
  • rowan
  • rowan_research_safe
  • rowan_ops_full

Selection:

  • ML_INTERN_CONFIG_PRESET=<preset>
  • ML_INTERN_CONFIG_PATH=/abs/path/to/config.json overrides preset selection

Tests

Ran:

uv run --with pytest pytest tests/ -v --tb=short

Result:

  • 29 passed

Upstream split

Reasonable upstream candidates:

  • generic OpenAI-compatible routing
  • provider registry/catalog shape
  • local backend ergonomics

Fork-only pieces:

  • Rowan MLX and BLD defaults
  • Rowan MCP wiring and policy surface
  • Rowan preset configs

andrejvysny and others added 7 commits April 22, 2026 22:19
POST /api/config/model and POST /api/session/{id}/model previously
accepted any authenticated HF user, letting non-members of
ml-agent-explorers flip a session onto anthropic/claude-opus-4-6
which is billed to the Space's ANTHROPIC_API_KEY.

Add a require_huggingface_member dependency and apply it to both
routes. Org name is configurable via HF_EMPLOYEE_ORG env var,
defaulting to 'huggingface'. check_org_membership already caches
positive results for 5 min so the extra whoami-v2 round-trip is
amortized.

Non-HF users keep working on the session's default model.
Route `bedrock/<model>` model IDs through LiteLLM's Bedrock adapter with
the same thinking/effort params as the `anthropic/` path. LiteLLM handles
AWS auth (access keys or bearer token for SSO). Also adds boto3 as a core
dependency (required by LiteLLM's Bedrock adapter).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Pro777
Copy link
Copy Markdown
Author

Pro777 commented Apr 23, 2026

Added a follow-up commit on this branch: local Rowan-style providers now expose reachability metadata in the model catalog, and CLI shows / for local lanes (, , , ).\n\nThis uses a short TTL probe against , can be disabled with , and is covered by tests.

@Pro777
Copy link
Copy Markdown
Author

Pro777 commented Apr 23, 2026

Follow-up on this branch: local Rowan-style providers now expose reachability metadata in the model catalog, and CLI /model shows lane up or lane down for local lanes (mlx/, ollama/, bld/, lm_studio/).

This uses a short TTL probe against each configured base URL plus /models, can be disabled with ML_INTERN_SKIP_PROVIDER_PROBES=1, and is covered by tests.

@Pro777
Copy link
Copy Markdown
Author

Pro777 commented Apr 23, 2026

Added Rowan MCP wiring on top of the provider work.

What changed:

  • ML_INTERN_ENABLE_ROWAN_MCP=1 now injects a rowan-mcp server automatically when the config does not already define one.
  • ROWAN_MCP_URL and optional ROWAN_MCP_TOKEN drive the injected server.
  • Empty MCP auth headers are stripped before client creation, so local Rowan setups do not send a junk Authorization: Bearer header.
  • Added config and tool-router tests for the new behavior.

This keeps Rowan MCP opt-in, env-driven, and usable for both local and remote/proxied deployments.

@Pro777
Copy link
Copy Markdown
Author

Pro777 commented Apr 23, 2026

Added default Rowan MCP policy on this branch.

ml-intern no longer exposes the full Rowan MCP surface by default. When rowan-mcp is configured, Rowan-owned tools now go through a safe allowlist focused on read/search/research actions. Queue mutation, notify, and other higher-risk Rowan tools stay hidden unless explicitly enabled.

Policy controls:

  • ROWAN_MCP_ALLOW_ALL_TOOLS=1 to disable the safe allowlist
  • ROWAN_MCP_ALLOWED_TOOLS=... to add specific tools
  • ROWAN_MCP_BLOCKED_TOOLS=... to force-block specific tools

Tests cover the default allowlist and the override behavior.

@Pro777
Copy link
Copy Markdown
Author

Pro777 commented Apr 23, 2026

Added two Rowan-ready preset configs on this branch.

Profiles:

  • configs/rowan_research_safe_config.example.json: mlx/..., lower iteration cap, intended to pair with the default Rowan MCP safe allowlist
  • configs/rowan_ops_full_config.example.json: bld/..., longer iteration cap, intended for stronger operator sessions

The existing configs/rowan_agent_config.example.json stays as the backward-compatible Rowan example. Tests now validate that both new preset configs load through the real config loader.

@Pro777
Copy link
Copy Markdown
Author

Pro777 commented Apr 23, 2026

Added runtime config selection on this branch.

You can now select Rowan profiles without copying files over configs/main_agent_config.json:

  • ML_INTERN_CONFIG_PRESET=default
  • ML_INTERN_CONFIG_PRESET=rowan
  • ML_INTERN_CONFIG_PRESET=rowan_research_safe
  • ML_INTERN_CONFIG_PRESET=rowan_ops_full

ML_INTERN_CONFIG_PATH=/abs/path/to/config.json overrides the preset choice.

Both interactive and headless entrypoints now use the shared resolver, and tests cover preset resolution, explicit path override, and bad preset rejection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants