Repository navigation
feat(j5): people can switch a persona worker's model - #934
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
This review includes 28 billable files and costs up to $7.00. Or wait 49 seconds for your next included review. View limit details
|
tyler-barton-horizon
left a comment
There was a problem hiding this comment.
Automated review of this layer of stack pingdotgg#933 (diff against its base branch). Findings were not individually verified against the source, so please treat them as likely issues and push back on any that are wrong.
apps/server/src/j5/a2a/DeliveryTransport.ts:752 (not in this diff): A2A steer/restart deliveries pin modelSelection to the active run's selection. After a person switches the model mid-run, that no longer equals the assignment, so checkSwitch treats the peer's steer as an agent model change and refuses it. The error is caught and logged, the message falls back to queueing, and steering silently stops working on switched persona threads.
🤖 Generated with Claude Code
| export const personaRouteToFollow = ( | ||
| assignment: OrchestrationV2AgentPersonaAssignment | undefined, | ||
| draft: { readonly modelSelectionExplicit?: boolean } | null, | ||
| ) => (draft?.modelSelectionExplicit === true ? undefined : assignment); |
There was a problem hiding this comment.
After the server refuses a switch, the composer keeps the explicit pick, so it keeps sending the refused model and every later message fails.
A person picks Claude on a Builder (workspace-write) thread and sends. The server refuses because Claude can't enforce workspace-write and says the worker stays on its model. But modelSelectionExplicit stays true and the draft-clearing subscription only clears picks that match thread.modelSelection, so selectedModelSelection stays on Claude and each follow-up is refused until the person re-picks the original model.
There was a problem hiding this comment.
True, and I left it on purpose. It's what upstream does on any thread when a picked model's send fails: the picker keeps your pick and every send tells you why. Resetting it automatically would mean clearing the pick in upstream's send path on any failure, network blips included. The refusal text says the worker stays on its model, so you pick again.
| const person = reachPersonId(reach); | ||
| // Only a person may switch a persona worker's model; the orchestrator checks the switch. | ||
| const asPerson = <A, E, R>(effect: Effect.Effect<A, E, R>) => | ||
| person === null |
There was a problem hiding this comment.
A person's right to switch rides on an ambient Context.Reference, which is lost when the dispatch runs on another fiber.
During startup, ws.ts routes dispatches through startup.enqueueCommand into a queue drained by a forked commandWorker whose context lacks AgentPersonaModelSwitch. A person's thread.model-selection.set is then refused with "Agents can't change a persona worker's model". Carrying provenance on the command would be sturdier than fiber-local state.
There was a problem hiding this comment.
Right, that's the startup window. A switch sent before commands are ready gets refused as an agent's, and resending works once the server's up. It's in Not verified. Putting provenance on the command would mean adding an actor field to upstream's command, and I'd rather not. Since the gap fails closed, I'm keeping the mark where DispatchModeLimit already lives.
| // Only a person may switch a persona worker's model; the orchestrator checks the switch. | ||
| const asPerson = <A, E, R>(effect: Effect.Effect<A, E, R>) => | ||
| person === null | ||
| ? effect |
There was a problem hiding this comment.
Sessions with reach: 'unknown' get no person marker, so their switches are refused with a message that calls them an agent.
A paired client whose session has no j5_a2a_person_session row resolves to { kind: 'unknown' }, reachPersonId returns null, and every model switch fails with AGENT_MODEL_SWITCH_REFUSAL, which is misleading for a human client.
There was a problem hiding this comment.
I don't think this one can happen. An unknown session isn't wide, so admission's requireLevel refuses it before upstream sees the command (CommandAdmission.ts:221: 'This is not shared with you on this server.'). It never gets as far as the model check.
| return event; | ||
| const driver = yield* deps.getDriver(thread.modelSelection.instanceId); | ||
| const definition = yield* library | ||
| .readSnapshot(assignment) |
There was a problem hiding this comment.
followModelSelection reads and hashes the persona snapshot from disk inside every selection event, only to compute the optional resolvedEntryIndex, and a read failure aborts the event.
If the snapshot file is missing or the legacy built-in version is gone, a switch that already passed checkSwitch fails when the event is written. A queued switch fails in makeSystemEvent (Orchestrator.ts:1213) and leaves the queued run unstarted. Every switch also pays a file read plus a sha256 while holding the thread lock.
There was a problem hiding this comment.
That's intended. A thread whose snapshot is missing can't run a turn anyway, since the runtime reads the same snapshot every turn and fails, so failing the switch event says it sooner. It's one read per switch, not per event. The read is there for resolvedEntryIndex, so the assignment records when you switched onto one of the persona's own entries.
| const assignment = thread.agentPersonaAssignment; | ||
| const selection = command.modelSelection; | ||
| if ( | ||
| assignment === undefined || |
There was a problem hiding this comment.
switchedAgentPersonaAssignment keeps reviewIndependence unchanged, but the reviewer note is built from the switched model, so the stored outcome can contradict the model the reviewer actually runs on.
A reviewer created with outcome different-model and authors [claude-opus-5] is switched onto claude-opus-5 before its first turn. The note reads 'you run on claude-opus-5; the authors ran on claude-opus-5' with no same-model warning, and the record still claims a different-model review.
There was a problem hiding this comment.
The note's only built once, when the brief's composed at creation (spawn, crew launch, delegation), so it always matches the stored outcome. reviewIndependence records what was decided at creation, and that's deliberate. A person moving a reviewer onto the author's model is their call (#782/#783), and modelSwitchedBy on the same assignment shows it happened.
|
Re the review note on |
df699a0 to
2c968db
Compare
2c968db to
4fd8a2a
Compare
A persona worker was locked to its launch model: the server refused any model or provider change, and the web composer hid the picker. A worker stuck on a provider at its usage limit had to be started over. A person can now switch it from the composer on web, desktop and mobile. The server checks the switch again: a signed-in provider must offer the model and its options, and that provider must enforce the persona's access. A refusal names why, and the worker stays put. Only a person's client command counts (CommandAdmission marks it); agents, MCP tools and service sessions are refused and told to replace the worker. The assignment's model fields follow the thread's selection in the same event, at upstream's two event constructors, so the chip, the composer and the per-turn runtime check all read the model the thread runs on, however upstream applied it (selection command, a message's model on steer, restart or a new run, or a queued run starting). Done with Claude Opus 5.5 in Claude Code (J5 Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A queued message carrying a new model applies it later, in the system write that starts the queued run. Nothing drove that path, so the hook that keeps the assignment on the thread's model there was untested. Stop and resume start the queued run without a provider; the test fails without the makeSystemEvent hook. Done with Claude Opus 5.5 in Claude Code (J5 Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A new-task draft carries the person's sticky model, and launching it as a persona never cleared that pick. On the started thread the picker could show the sticky model while sending the worker's, and an effort change made it an explicit pick, switching the worker onto a model nobody chose. The draft's model picks are now dropped once the persona launches, and choosing a persona no longer resets the draft, so clearing it keeps the person's pick. Done with Claude Opus 5.5 in Claude Code (J5 Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A change to effort alone counts as a person's switch, since reasoning is part of the model selection and takes the same checks, but the note only said the model changed. It now reads "A person changed its model or reasoning since launch." Done with Claude Opus 5.5 in Claude Code (J5 Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lable The model-only composer row was skipped when the provider was unavailable, so upstream's "Open provider settings" button rendered alone and the persona and handoff chips disappeared. They now stay beside it. Done with Claude Opus 5.5 in Claude Code (J5 Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4fd8a2a to
67d58e8
Compare
Summary
Once a persona worker started on a model, I couldn't change it. The server refused any model or provider change on a persona thread, and the web composer hid the picker. So a worker stuck on a provider that hit its usage limit had to be started over. Now a person can switch it from the composer, and the server runs the launch checks again on each switch. Closes #783.
CommandAdmissionmarks a dispatch from a session that names a person with a J5Context.Reference(AgentPersonaModelSwitch), the same wayDispatchModeLimitreaches the orchestrator. Anyone admission already lets send a model change on that thread can switch. Everything without the mark is refused with "Agents can't change a persona worker's model. Replace the worker instead…". That coverst3_thread_configure, an agent's message carrying a model, MCP and scheduled paths, and service sessions with no person.thread.model-selection.set, because the composers don't send that. They send the model onmessage.dispatch, and upstream applies a message's model in four places: steer, restart, a new run, and later in a separate write when a queued run starts. Sendingmodel-selection.setfirst would release the live session and kill a running turn. Instead, upstream's two event constructors pass each event throughpersonaGuards.followModelSelection. Anythread.model-selection-updatedorthread.provider-switchedevent on a persona thread then carries the switched assignment. That meansresolvedModelSelection,resolvedDriver,resolvedRoute: "override",resolvedEntryIndexwhen the model matches a list entry, and the newmodelSwitchedBy: "person". The snapshot, digest, instructions,pickSourceandreviewIndependencedon't change. The per-turn runtime check reads the switched driver, so a later turn on a provider that can't enforce the access is still refused.modelSelectionExplicit). A persona launch also drops the draft's model picks. Without those two rules, a draft's sticky model would show in the picker and could quietly switch a brand-new worker. The chip's tooltip names the current model and says when a person changed its model or reasoning. If the provider is unavailable, the persona and handoff chips stay next to "Open provider settings".No model-facing text changed, so no evals ran.
UI changes
The composer controls row on a persona thread, cropped from 1280x800. Base is
feat/persona-reviewer-independence(6890d43) and head is a85bc9f, on the same test home after one "Say hi in your thread" turn as the Haiku helper persona:Live testing
Partial, at a85bc9f, using
setup-agent-live-test.ts --base origin/feat/persona-reviewer-independence. I ran one real Haiku turn on each server, just to get a persona thread for the captures above.Evidence
agentPersonaLaunch.integration.test.ts, against the real orchestrator:overrideroute with no entry index;modelSwitchedBy: "person", the run carries the new model, and the runtime keeps the launch snapshot's instructions;model-selection.setand anmcpmessage carrying a model are refused with the replace-the-worker text, and the assignment stays put.reviewIndependencestays as recorded.makeSystemEventhook.CommandAdmission.test.ts, "marks only a person's commands as theirs": an owner's command carries the mark and anmcp-clientservice session's doesn't.personaComposerSelection.test.ts, against the real draft store:agentPersonas.test.ts: the chip presents the current model and the switch note.vp test run src/j5/agents/agentPersonaLaunch.integration.test.ts src/j5/agents/agentPersonaRuntimePolicy.test.ts src/j5/agents/agentSubagent.integration.test.ts(fromapps/server)vp test run src/orchestration-v2/{OpenCode2OrchestratorV2.integration,Orchestrator.control-reads,ProjectionStore,ProviderRuntimeRecoveryService,RestartBackgroundNote,SteeringCompletion.integration,SelectionRestart.integration,ThreadLaunchService,runtimeLayer}.test.ts src/j5/sharing/(fromapps/server)vp run check:changed: format, lint, knip, typecheck (32 packages) and tests (25 files, 435 tests) all pass.Not verified:
Merge Danger
Door: two-way.
modelSwitchedByis optional, so a revert still decodes switched assignments. Threads switched before a revert keep their new model, and the old lock applies from then on.Blast Radius: model changes on persona threads, plus the persona composer row on web and mobile. If the checks are wrong, a worker could land on a provider that can't enforce its access. The per-turn runtime check still refuses that turn. Ordinary threads go through the same hook, but only selection events on a thread with an assignment are touched.
After merge: #784 (agents replace a worker to change its model) builds on the agent refusal.
Upstream impact
apps/server/src/orchestration-v2/Orchestrator.ts:routeLockedbecomesmodelChange, andmakeEventandmakeSystemEventeach pass the event throughfollowModelSelection(3 changed lines). This is the "Role library" row in FORK.md.apps/web/src/components/chat/ChatComposer.tsx,ChatView.tsx: the follow-the-route hook, the persona control in the controls bar, andmodelOnly. FORK.md has the persona composer row and its provider-candidate note.apps/web/src/components/chat/ComposerControlsBar.tsx: onemodelOnlyprop with one early return. Covered in the same FORK.md row.apps/web/src/components/chat/useComposerSend.ts: a J5 comment only.apps/mobile/src/features/threads/ThreadComposer.tsx:onPressModel={openSettings}. Covered in the persona composer row.docs/j5/product/upstream.md) is rewritten: persona threads now keep the model and reasoning pickers and hide only access and plan mode. Bryant approved switching in Personas: people can switch a persona worker's model #783's plan.Checklist
FORK.md(case text and file-table row) in this PRdocs/j5/product/upstream.mdAGENTS.md)docs/j5/product/and user docs rewritten where this changes themSurfaces walked:
t3_thread_configure, message selections, MCP) are refused.Made with Claude Opus 5.5 in Claude Code (J5 Code).
🤖 Generated with Claude Code