Model Profiles — Hybrid-Ready
What this is
Two pieces of unfinished substrate, both surfaced by Hybrid Pipeline's Model routing §as-built note, that together "finish what role-tagged Model Profiles were built for":
The hybrid runtime doesn't consume role-tagged entries. ✅ Shipped 2026-08-04 — see As built. (Stated below as it stood before the build, because the contract paragraph that follows is what was implemented and is still the reference.)
model_profile_entries.role(0=Primary / 1=Beat / 2=Prose) already shipped end to end through repo/API/Workbench — but nothing in the hybrid runtime consumes a role-tagged entry yet. The hybrid legs run on flatHybridPipelineLlm.*settings with hardcoded beat/prose prompts, and no "Authentic over Comfort" Profile pairs the two roles. The column is a promise the runtime doesn't keep yet.The contract, stated with the arrow pointing the right way (an earlier draft had it backwards — "resolve Beat/Prose models from role-tagged entries" — corrected on review): an Entry is
model_identifier → Mode + optional param overrides(23_tables_model_profiles.sql:54-84). It carries no provider, preset, endpoint, or credential — a public Profile must stay credential-free, so an entry can never supply a model, only match one. Concrete execution always comes from the user/settings side (today the flatHybridPipelineLlm.*family — Provider / Endpoint / ApiKey / Model plus theProse*variants,SettingsKeys.cs:434-452; durably, an accessible concrete preset selected per role). Consuming role-tagged entries means: given the Beat leg's concrete model, match it against the Profile's same-role entries bymodel_identifier— the winning entry supplies that leg's Mode. Its stored parameter values are opt-in recommendations, not automatic overrides — Document Mode Editor is explicit that Entry parameters never auto-apply during resolution (the "Apply recommendations" flow is the only path they land through), and hybrid roles are not an exception (an earlier draft of this contract said "Mode and param overrides" — corrected on review; the schema comment's word "overrides" describes the column's intent, GME's recommendations rule governs its application). Effective params come from the leg's preset/user Generation settings, exactly as in classic. Then freeze the tuple —(profile, role, entry, mode, preset/provider/model, effective params)per leg — for the turn; the minimum meaning of "freeze" in this slice is resolve-once-per-accepted-turn carried on the pipeline context, deliberately independent of the Document Mode Editor plan-freeze. No same-role match → that leg keeps its selected model and today's behavior — which is not hardcoded prompts (a stale claim in an earlier draft): the legs already run the settings-bound seed Modes via theHybridPipelineLlm.BeatModeId/.ProseModeIdinterim bridge, with the hardcodedHybridPipelinePromptsconstants only as the last-resort fallback when those settings are unset or unresolvable (Hybrid Pipeline §4's as-built note). Entry consumption replaces the interim settings bridge, not the constants — a Profile that predates roles changes nothing.Pair-winner, tie-break, and provenance — the minimum contract piece 1 must pin (raised on external review, correct that it was unstated; implemented as specified — see As built):
- One Profile owns the pair. Packages bind multiple ordered Profiles, and the existing
resolver is one flat query across all bindings (
47_package_functions.sql:294-316— match tier → identifier length → binding order → entry order). Running that same per-role query independently for Beat and Prose could produce Beat from Profile A and Prose from Profile B — legal SQL, incoherent product: the language everywhere is "one Profile describes both halves." Decided: walk bound Profiles in binding order; the first Profile carrying any role-tagged (Beat/Prose) entry is the conversation's hybrid pair-owner, and both legs resolve strictly within it. A leg with no same-role match inside the pair-owner keeps seed-mode behavior — it does not fall through to the next bound Profile (pair coherence beats match rate; revisit only with evidence). - Frozen ≠ Guided's execution plan. This slice stays independent of the Document Mode Editor plan-freeze: the minimum freeze here is resolve once per accepted turn and carry the result on the pipeline context (exactly how the beat call's telemetry already rides the context today) — no mid-turn re-read of settings or entries. Folding into the full execution-plan machinery is the end-state when that ships, not a dependency of this slice.
- Per-leg provenance is persisted, not inferred.
web_message_statscarriesmode_id/provider/modelbut no Profile or Entry identity, and reverse-inferring the Entry frommode_idis exactly the trap Document Mode Editor already names (two Profiles may point at the same mode). Each hybrid stats row (stage='hybrid-beat'/'hybrid-prose') gains the winning entry id — nullable, no FK, may dangle — mirroring theweb_conversations.model_profile_entry_idconvention.
- One Profile owns the pair. Packages bind multiple ordered Profiles, and the existing
resolver is one flat query across all bindings (
Flavor's
target_stageis hardcoded toclassic_primary. Per Document Mode Editor §Flavor validity and ownership, V1 Flavor runtime is deliberately Web + Classic only — Direct/Discord/Hybrid assemble the Base unchanged and report the Flavor layer unsupported ("Style & rules are available in Classic chats"). Extendingtarget_stagetobeat_direction/proseis what lets a Flavor apply in a hybrid turn.
They're one committed feature rather than two coincidental fixes because they end in the same place: a Model Profile that fully describes how a creator's work runs in a hybrid conversation — which models take the Beat and Prose legs, and which style overlays apply to which stage.
Dependency ordering — the two pieces are not symmetric
- Piece 1 (role-tagged Beat/Prose resolution) has no dependency on Flavor at all. It's a Model Profile / hybrid-pipeline change on its own and can be picked up tomorrow, independently of Prompt Presets and of the Document Mode Editor work. This independence is the main reason this spec exists as its own document.
- Piece 2 (
target_stageextension) needs Flavor to exist first — it extends a column Flavor owns, and Flavor is unbuilt (specced in Document Mode Editor). It also drags three riders with it, all anchored in Prompt Presets because they live on the sharedsub_promptssubstrate:- the Flavor content-moderation gap — Model Profile publish checks sweep only
name/description(32_run_content_checks.sql:607-613), so Flavor prompt text would ship with no moderation coverage path at all unless the check sweep learns to join through Flavor's linking mechanism (see Prompt Presets §Creator-authored (Flavor)); - reusing the shared "pick a saved prompt" picker from Prompt Presets slice 1 for Flavor's import-as-private-clone flow;
- Flavor's first Context Budget line item — Flavor content is injected into the chat request, so it belongs in Context Budget the way Custom Instructions does, and currently has no budget hook (display-only, per the decided Context Budget scope in Prompt Presets).
- the Flavor content-moderation gap — Model Profile publish checks sweep only
What already exists (verified against code, not assumed)
model_profile_entries.role— shipped end to end: schema, repository, API, Workbench UI. Consumed by the hybrid runtime since 2026-08-04 (As built).- The hybrid pipeline itself — running. Each leg's concrete model still comes from the flat
HybridPipelineLlm.*settings; what a role-tagged entry now supplies is the leg's Mode. - Flavor — specced, not built (Document Mode Editor is "implementation-ready, no code yet"). Everything Flavor-dependent here inherits that status.
- Model Profile publish-check coverage —
name/descriptiononly; no join through any prompt content.
Relationship to sibling specs
| Doc | Relationship |
|---|---|
| Prompt Presets | The implementation this scope is committed to. Owns the shared sub_prompts substrate, the picker, and the Flavor moderation-gap analysis. |
| Document Mode Editor | Owns Flavor's design — validity rules, ownership, target_stage, import-as-clone. Piece 2 extends what it defines. |
| Hybrid Pipeline | Owns the runtime the role-tagged entries must feed. Its Model routing as-built note is the origin of piece 1. Its § Package start makes piece 1's role entries reader-visible: whether a package carries beat/prose entries becomes the readiness signal in the package start modal — copy only, never a gate, because a leg with no match degrades to the settings-bound seed mode. |
Suggested slicing (leans, not committed)
- Role-tagged entry consumption — ✅ SHIPPED 2026-08-04 (As built). Per the contract above — each hybrid leg's concrete model (settings/preset-side) is matched against the effective Profile's same-role entries; a match supplies that leg's Mode + param overrides, no match keeps the settings-bound seed-mode behavior. Includes the per-leg execution-plan freeze. Ship with at least one real paired Profile ("Authentic over Comfort") to prove it.
target_stageextension (after Flavor ships): extend pastclassic_primarytobeat_direction/prose, plus the three riders above (moderation-coverage join, picker reuse, Context Budget line).
Open questions
Where per-role concrete model selection lives: the flat
HybridPipelineLlm.*settings only, or a per-role preset picker (an accessible concrete preset per leg)? The contract works with either; the picker is the durable end-state, the settings are what exists. (The old "which model does a role-less Profile fall back to" question dissolved under the corrected contract — Profiles never supply models at all, so no match simply means today's behavior.)Do an entry's param overrides (temperature / max_tokens / …) apply to the matched leg verbatim, or filtered per role (a Beat director and a Prose writer plausibly want different override policies)?
Does a Flavor targeting
beat_directionneed different validation thanclassic_primary(beat-direction prompts are structured instructions, not prose style)? Slice-2 design.The pair rule is settled (2026-08-06): a matched
beat+prosepair within one Profile. Decided on the reader-facing side — see Hybrid Pipeline § Readiness is a matched pair — and it governs both sides, so an "any role entry" reading is out here too.This makes the Workbench pair-nudge worth building rather than a nicety. Under the old any-entry reading a half-pair still counted for something. Under the pair rule a Profile with a Beat entry and no Prose is completely inert on the reader's side: no readiness copy, no Hybrid preselect on a package that binds it, and the runtime silently falls that leg back to the seed mode. The nudge ("this Profile has a Beat entry but no Prose entry — the Prose leg will use the platform default") is the only surface that would ever tell the creator their half-pair does nothing. Still open is whether it ships with piece 2 and where it renders, not what rule it applies.
Open follow-ups (knowledge review, 2026-09-29)
- The Classic Primary resolver ignores built-in models; the Hybrid legs don't.
fn_resolve_package_effective_modereads the reader's model only from a preset the reader owns (lp.user_id = p_user_id,database/v1/functions/47_package_functions.sql:357-360) and returns nothing when noLlm.PresetIdis set (:353-355). So a reader on a platform built-in, or on no preset at all (the admin default built-in), never gets Model Profile resolution — not even a*Entry — and the package runs on its own or the character's Mode. The display twin infn_get_conversation_model_profiles(:1171-1176) has the same predicate. The Hybrid legs match the flattenedHybridPipelineLlm.*/Llm.*model (built-ins included), so the two pipelines disagree about the same reader. Fix shape: admit platform built-ins with the one predicateLlmPresetRepository.PlatformBuiltinPredicatespells (user_id 0 on the platform rail) in both functions, and re-resolve on a built-in's model change. Needs a decision first: whether "no preset" means the admin default built-in (what the enricher runs) or "no usable model" (Document Mode Editor §Effective package variant resolution, step 0) — the two specs read differently.- A reader whose chat preset is a platform built-in gets the same Primary-Entry resolution
(including
*) as one on a preset of their own.
- A reader whose chat preset is a platform built-in gets the same Primary-Entry resolution
(including
As built — piece 1
Shipped 2026-08-04. The consumption contract above was implemented as written; this section records only what the code adds to it and where it diverged.
Where it lives
| Concern | Code |
|---|---|
| Pair-owner walk + per-role tiered match | database/v1/functions/47d_hybrid_role_mode_functions.sql — fn_resolve_hybrid_role_modes, fn_match_model_profile_role_entry |
| Per-turn resolution + freeze | HybridLegPlanner.ResolveRoleModesAsync, run once by HybridContextBuildingStage (the hybrid_context stage, Order 100, before compute allocation) → IPipelineContext.HybridLegPlan + .HybridRoleModes (Core/Services/Hybrid/HybridLegPlan.cs, HybridRoleModeResolution.cs) |
| Per-leg mode precedence | HybridLegPlanner.ResolveLegModeAsync — entry → settings binding → constants |
| Repository seam | IModelProfileRepository.ResolveHybridRoleModesAsync behind IHybridRoleModeSource |
| Provenance | web_message_stats.model_profile_entry_id (27_tables_message_stats.sql), threaded via WebMessageStatsStage |
| Seeded pair | database/v1/92_seed_hybrid_model_profile.sql — "Authentic over Comfort" |
Divergences from the spec text (deliberate, each with its reason)
- Param overrides are NOT applied. The contract paragraph above says a winning entry supplies
"Mode and param overrides"; piece 1 supplies the Mode only. This was the brief's explicit
call, and it is load-bearing rather than a shortcut:
fn_resolve_hybrid_role_modesdoes not even return the parameter columns, so no caller can start applying them by accident. The entry keeps holding them as recommendations for a future opt-in surface. - The plan-freeze does NOT ride the Document Mode Editor's execution-plan machinery. The spec's
§1 pointed at that plan-freeze as the model; the brief scoped it out, and the implementation freezes
a single small record on the pipeline context instead — the same carrier
BeatTelemetryalready uses. What is frozen is narrower than the spec's tuple:(profile, per-leg entry, per-leg mode), not(… preset/provider/model, effective params), because the model side never moved off the settings path and params are not applied. - The beat leg is matched against the beat call's whole fallback chain, not
HybridPipelineLlm.Modelalone.BeatLlmService.TryResolveModel(the resolver the beat call itself uses:HybridPipelineLlm.Model → Llm.Modelsince 2026-11-22, Relay eod-421; before that the helper stagesTrackerEvalLlm.Model → JournalEvalLlm.Model → SummarizationLlm.Modelcame between) is shared with the matcher. Reading the first key alone would match against a blank while a fallback supplied the model that actually ran. Same move on the prose side viaProseSettingsOverride.ResolveProseModel(ProseModel → Llm.Model). - A winning entry whose Mode can't serve degrades to the settings-bound Mode, not to the constants. The spec only says an unmatched leg keeps today's behavior. A matched entry pointing at an unusable Mode (zero declared sections) is a third case; dropping only what the entry added stays closer to the creator's intent than falling to a compile-time prompt.
- Pair ownership requires a role-tagged entry with a LIVE Mode. A Profile whose only role-tagged entries point at soft-deleted Modes cannot serve either leg, so letting it own the pair would starve both legs and shadow a later Profile that could serve them.
is_defaultonpackage_model_profilesis not consulted — ownership is pure binding order, matching what the classic resolver does.- Unplanned prerequisite: package-start could not be Hybrid.
fn_create_conversation_from_packagenever setpipeline_type, andConversationsEndpointsdocumented "Package-start stays Classic" — so no conversation could be both package-bound and Hybrid, and this feature (which resolves through the package) was unreachable.p_pipeline_typewas added to the function and the endpoint now honoursIsHybridon the package path. UI reachability (added 2026-08-05, dev decision): the chat gear menu's "New conversation" re-pick is now package-aware — on a package conversation it creates a new package conversation honoring the pipeline pick, making package+Hybrid reachable without insider knowledge. The package-page start still shows no picker (always Classic), deferred to the persona-templates new-chat redesign as before.
Open questions this settles
- "Where per-role concrete model selection lives" — unchanged by piece 1: the flat
HybridPipelineLlm.*settings (withPresetId/ProsePresetIdflattening into them). Entries cannot supply models, so the per-role preset picker remains the durable end-state, untouched here. - "Do an entry's param overrides apply verbatim or filtered per role" — neither, yet. Piece 1 applies none of them; the question stays open for whoever wires recommendations to a UI.
Acceptance Criteria — piece 1 (role-tagged entry consumption)
Scoped to piece 1 only. Piece 2 (target_stage) waits on Flavor existing and has no criteria here.
The feature is not done until every box below is verified ✅ against the running product.
User use cases — satisfiable + accessible (verify by driving the UI, not the code):
- As a creator, I can pair a Beat Mode and a Prose Mode inside one Model Profile by adding a role-tagged Entry for each — reachable from the Workbench Model Profile entries panel (role selector) without insider knowledge.
- As a creator, I can bind that Profile to my Package — reachable from the Package editor's model profile picker.
- As a reader, starting a Hybrid conversation from that Package runs the Beat leg on the Profile's Beat Mode and the Prose leg on its Prose Mode, with no extra configuration step.
Behavior:
- On a hybrid turn whose conversation is bound to a package, the Beat leg's Mode comes from the
pair-owner Profile's matching
role = 1entry, and the Prose leg's Mode from its matchingrole = 2entry. - Both legs resolve from one pair-owner Profile — the first package-bound Profile in binding order carrying any role-tagged entry. Never one leg from Profile A and the other from Profile B.
- Per-leg matching is by
model_identifieragainst that leg's concrete model taken from the settings side — beat:HybridPipelineLlm.Model(with the beat call's own fallback to the chat model); prose:HybridPipelineLlm.ProseModelfalling back to the conversation's chat model. - Match tiers are exact → substring (longer identifier first) → literal
*, tie-broken by identifier length then entry order — the same shape asfn_resolve_package_effective_mode. - Resolution happens once per accepted turn, carried on the pipeline context; nothing re-reads the Profile mid-turn, so an entry edited between the beat call and the prose call cannot split a turn across two configurations.
- Each hybrid
web_message_statsrow records the winning entry id for its own leg (stage = 'hybrid-beat'→ the Beat entry,stage = 'hybrid-prose'→ the Prose entry). - A seeded system Profile "Authentic over Comfort" exists pairing the two seeded system Modes
(Beat Director as
role = 1, Visceral Prose asrole = 2), so the feature is provable with real data on a fresh migration.
Invariants that must stay true (carve-outs):
- An Entry never supplies a model. No provider, endpoint, API key, or model identifier is ever read out of an entry to execute a leg — the entry only supplies a Mode. Verified by the beat and prose calls still running on the settings-side provider/model after a match.
- Entry parameters do NOT auto-apply.
temperature/max_tokens/top_p/frequency_penalty/presence_penaltyon a winning entry change nothing about the leg's call. They stay opt-in recommendations. - A leg with no same-role match keeps today's behavior exactly: the settings-bound seed Mode
(
HybridPipelineLlm.BeatModeId/.ProseModeId), with the hardcodedHybridPipelinePromptsconstants as the last-resort fallback. Entry consumption replaces the settings bridge, not the constants. - A Profile with no role-tagged entries changes nothing — byte-identical prompts and identical stats rows to the pre-change build (a Profile that predates roles is inert here).
- Classic turns are completely unaffected — no new query runs, no prompt changes, and
fn_resolve_package_effective_mode'srole = 0filter still governs classic mode resolution. - A mode-config problem never fails a turn. Every resolution failure (missing profile, dangling mode, zero-section mode, query error) logs and falls back; the turn still produces a message.
Edges:
- Non-package conversation → no pair-owner, both legs fall back, no error surfaced.
- Package bound to Profiles where the first in binding order has only
role = 0entries → the pair-owner is the first Profile that does carry a role-tagged entry; a Profile with none is skipped for ownership. - Pair-owner found but only one role matches → the matched leg uses its entry, the other leg falls back independently; no fall-through to a later Profile for the unmatched leg.
- Winning entry points at a soft-deleted Mode → that entry cannot win; the leg falls back.
- Beat or prose model unresolvable/blank → the wildcard tier does not fire for that leg (same rule as the classic resolver) and the leg falls back.
- Winning-entry id later deleted →
web_message_stats.model_profile_entry_idmay dangle (no FK, by design, mirroringweb_conversations.model_profile_entry_id); readers LEFT JOIN.