Skip to content

feat: add model_policy=permissive for open-weight model routing#14

Merged
seanfromthepast merged 3 commits intomainfrom
feat/model-policy-permissive
Mar 12, 2026
Merged

feat: add model_policy=permissive for open-weight model routing#14
seanfromthepast merged 3 commits intomainfrom
feat/model-policy-permissive

Conversation

@realityinspector
Copy link
Collaborator

Summary

  • Adds model_policy field to GenerateRequest — when set to "permissive", auto-selects only open-weight/distillable models (DeepSeek, Llama, Qwen, Mistral)
  • New shared module app/core/model_policy.py with model licensing classification and registry-aware selection
  • Text routes through OpenRouter to best available permissive model (Llama Scout → Maverick → DeepSeek → Qwen → Mistral)
  • Images route directly to Pollinations (free, open-source) instead of Google Imagen
  • Pipeline now dynamically derives model_permissiveness from actual model used instead of hardcoded "restricted"
  • Explicit text_model/image_model in request always take precedence over policy

Motivation

Clockchain expander requires all generated content to use only permissive/distillable models. Previously Flash defaulted to Gemini, violating this policy.

Files Changed

File Changes
app/core/model_policy.py NEW — shared policy logic, permissive prefix list, registry-aware model selection
app/api/v1/timepoints.py Added model_policy field, resolve logic in sync/async/stream endpoints
app/core/pipeline.py Dynamic model_permissiveness derivation
app/core/llm_router.py Pollinations direct path for image generation

Test plan

  • Verify ruff passes on all changed files
  • Test sync generation with model_policy: "permissive" — should use Llama/DeepSeek for text, Pollinations for images
  • Test without model_policy — should use default models (Gemini)
  • Test with explicit text_model + model_policy — explicit model should win
  • Verify TDF payload has correct model_permissiveness value

Clockchain and other callers can now pass model_policy: "permissive" to
force generation through open-weight, distillable models (Llama, DeepSeek,
Qwen, etc.) instead of restricted frontier models (Gemini, Anthropic).

Changes:
- New app/core/model_policy.py: shared permissiveness/provider derivation
- GenerateRequest accepts model_policy field (all 3 endpoints)
- resolve_model_policy() auto-selects best permissive text + Pollinations image
- LLM router shortcuts to Pollinations when image_model contains "pollinations"
- Pipeline TDF payload derives model_permissiveness dynamically (was hardcoded)
@realityinspector realityinspector force-pushed the feat/model-policy-permissive branch from 0b3d270 to c53d0c7 Compare March 11, 2026 22:50
…eneration

When model_policy="permissive", the pipeline now skips the grounding step
(which requires Google Search API) so that the entire generation is routed
through OpenRouter + Pollinations with zero Google dependencies.
…ters

Adds LLMParams schema to GenerateRequest with fine-grained control over:
- temperature, max_tokens, top_p, top_k (all providers)
- frequency_penalty, presence_penalty, repetition_penalty (OpenRouter)
- stop sequences (all providers)
- thinking_level (Google Gemini)
- system_prompt_prefix/suffix for prompt injection

Request-level llm_params override agent defaults (e.g. temperature=0.3)
but agents retain their defaults when params are unset. Works alongside
model_policy and explicit text_model/image_model — all composable.

Expands OpenRouter provider to accept full parameter set and Google
provider to accept top_p, top_k, and stop sequences.
@seanfromthepast seanfromthepast merged commit 5a00a4e into main Mar 12, 2026
1 of 3 checks passed
realityinspector pushed a commit that referenced this pull request Mar 15, 2026
feat: add model_policy=permissive for open-weight model routing
@realityinspector realityinspector deleted the feat/model-policy-permissive branch March 15, 2026 14:16
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.

2 participants