Repository navigation
Description
Item 3 of 11 in the Personas v2: simpler specialists milestone. It ships in one release with #777 and #779.
The problem
Today a persona gets exactly two routes: a primary and a fallback. That's either too rigid, when I want three or four acceptable models in order, or it forces a fallback I don't actually want. And when a persona can't launch, j5_list_personas gives the agent one formatted string, not a reason it can act on.
Where this sits
Decision 2 of the Personas v2 proposal. This story covers the list shape, how a model gets picked from it, the agent-facing listing, and the Agent Setup editor. The limits based on who picked the persona (#781) and the reviewer preference (#782) plug into the same selection step later.
What we already have
- Contract:
modelRoute: Schema.Tuple([AgentPersonaModelTarget, AgentPersonaModelTarget])appears inAgentPersonaEditInput,AgentPersonaDefinitionView, andAgentPersonaCreateInput.resolvedRouteon the assignment is"primary" | "fallback" | "override".AgentPersonaRouteAttemptandAgentPersonaRouteFailureCodealready describe why one route failed. All of these are inpackages/contracts/src/j5/agentPersona.ts. - Routing:
apps/server/src/j5/agents/agentPersonaRouting.tsresolves the route.agentPersonaLaunch.ts,agentPersonaSpawn.ts, andagentPersonaSubagent.tscall it. - Listing:
j5_list_personaslives inapps/server/src/j5/a2a/mcp/tools.ts:767. Its description says it returns "the provider, model, and reasoning this persona would run on right now, or null when blocked". - Editors: web uses
AgentDefinitionFields.tsx,AgentEditorDialog.tsx, andAgentCreateDialog.tsxinapps/web/src/j5/agents/, with Primary/Fallback model pickers. Mobile has its own Agent Setup screens underapps/mobile/src/j5/agents/. - Usage limits: we already know when a provider is at its usage limit, because deliveries wait on it.
Proposal
A persona has an ordered list of model-and-reasoning entries, as many as it wants. When a worker is created, selection takes the first entry that passes all of these:
- a signed-in provider offers it;
- the provider can enforce the persona's access (Personas: three access levels #779);
- whoever picked the persona allows it (Personas: agents pick personas, and who picked sets the limits #781);
- it isn't one of the author's models, for marked reviewers (Personas: reviewers prefer a different model from the author #782). That one is a preference: it reorders the list rather than ruling entries out.
A provider already known to be at its usage limit is skipped. If a worker hits a usage limit mid-run, today's behavior stays: deliveries wait, and the same worker picks back up after the reset.
When the list runs out, the launch fails with one structured reason per entry. It escalates to the Captain inside a Crew, and to the person otherwise. The escalation itself is #785.
Acceptance criteria
- The definition, create, and edit contracts carry an ordered list of entries. Each entry has a provider instance, a model, and model options.
- Selection picks the first entry that passes every check. Tests use a list of three or more entries where the first ones fail for different reasons.
- A provider that's known to be at its usage limit is skipped at selection.
- An exhausted list fails with one reason per entry. Reuse or extend
AgentPersonaRouteFailureCode, which covers not signed in, model not offered, and access not enforceable, and add usage limit. - The assignment records which entry was chosen (its index or its model) instead of
primary/fallback, and old assignments still decode. -
j5_list_personasreturns the ordered entries, each with its rejection reason if it has one, instead of one formatted route string. The tool description is updated to match. - Agent Setup on web, desktop, and mobile can add, remove, and reorder entries, and set each entry's reasoning.
- Persona availability badges ("Blocked") show the reason for each entry.
-
docs/j5/user/personas.mddescribes the ordered list instead of primary/fallback models. - Focused tests cover selection order, the usage-limit skip, an exhausted list with mixed reasons, and the listing shape.
Out of scope
- The "Allow approved fallback models" setting. It's designed but deferred, because no live persona can use it yet.
- Limits based on who picked the persona (Personas: agents pick personas, and who picked sets the limits #781), and the reviewer reordering (Personas: reviewers prefer a different model from the author #782).
- Switching a running worker's model (Personas: people can switch a persona worker's model #783).
Activity