Rewrite a workflow agent's `prompt` and `model` in the `agent.spawn` mod hook
Claude Code v2.1.300 letsagent.spawn rewrite a workflow agent's prompt and model (it could only refuse them before), adds prompt.change for non-typed prompt-box updates, and virtualText decorations that never enter the draft or submitted prompt.Why this loop
Mods that previously could only refuse workflow agents can now reshape them at spawn time by returning a rewritten prompt and model from agent.spawn. Pair that with prompt.change (history recall, clear, undo, or a plugin fill) and virtualText (drawn in the prompt box but never part of the draft or submitted prompt) so helpers never leak into what Claude sees. Agent hooks now honor model: aliases like haiku resolve, a subagent's model no longer overrides the hook, and an unavailable model falls back to the caller instead of allowing the action. prompt.edit is raised for newlines from the chat:newline keybinding (Ctrl+J). A prompt.submit rewrite or drop is no longer recorded as typed in OpenTelemetry user_prompt events, interaction spans, or session title requests. Use $.ui.view({ agentId }) to show an agent's transcript and $.ui.view({}) to return. The built-in plugin-authoring skill scans a mod's files for keys before opening them and asks before scanning a folder outside the project.
Proposed actions
- Update the
agent.spawnmod hook so workflow agents are rewritten, not only refused: return a newpromptandmodel. Resolve aliases likehaiku; if the model is unavailable, fall back to the caller's model instead of allowing the action. Do not let a subagent's model override the hook'smodel. - Register a
prompt.changemod hook for prompt-box updates that are not typed edits: a recalled history entry, a clear, an undo, or a plugin's fill. Also handleprompt.editfor a newline entered with thechat:newlinekeybinding (Ctrl+J, or a rebound Enter). - Add
virtualTextto the mod's prompt decorations so helper text is drawn in the prompt box but never enters the draft or the submitted prompt. - From the mod, call
$.ui.view({ agentId })to show that agent's transcript in the main view, and$.ui.view({})to go back. On modTextnodes, set thedirprop for right-to-left text so rows read in that direction and sit flush right on Windows and in VS Code's terminal. - When using the built-in
plugin-authoringskill, let Claude scan the mod's files for keys before opening them, and require confirmation before scanning a folder outside the project.
Agent prompt
Paste into your agent or query via MCP (get_agent_prompt) — free, no extra AI costPaste into Claude Code / CLAUDE.md task
DevAgentRadar → Claude Code
You are helping me adopt a real coding-assistant change. Work only from the facts below. Do not invent features.
Context
Assistant: Claude Code
Proposal: Rewrite a workflow agent's prompt and model in the agent.spawn mod hook
Summary: Claude Code v2.1.300 lets agent.spawn rewrite a workflow agent's prompt and model (it could only refuse them before), adds prompt.change for non-typed prompt-box updates, and virtualText decorations that never enter the draft or submitted prompt.
Primary source: https://github.com/anthropics/claude-code/releases/tag/v2.1.300
Why it matters
Mods that previously could only refuse workflow agents can now reshape them at spawn time by returning a rewritten prompt and model from agent.spawn. Pair that with prompt.change (history recall, clear, undo, or a plugin fill) and virtualText (drawn in the prompt box but never part of the draft or submitted prompt) so helpers never leak into what Claude sees. Agent hooks now honor model: aliases like haiku resolve, a subagent's model no longer overrides the hook, and an unavailable model falls back to the caller instead of allowing the action. prompt.edit is raised for newlines from the chat:newline keybinding (Ctrl+J). A prompt.submit rewrite or drop is no longer recorded as typed in OpenTelemetry user_prompt events, interaction spans, or session title requests. Use $.ui.view({ agentId }) to show an agent's transcript and $.ui.view({}) to return. The built-in plugin-authoring skill scans a mod's files for keys before opening them and asks before scanning a folder outside the project.
Suggested actions
- Update the
agent.spawnmod hook so workflow agents are rewritten, not only refused: return a newpromptandmodel. Resolve aliases likehaiku; if the model is unavailable, fall back to the caller's model instead of allowing the action. Do not let a subagent's model override the hook'smodel. - Register a
prompt.changemod hook for prompt-box updates that are not typed edits: a recalled history entry, a clear, an undo, or a plugin's fill. Also handleprompt.editfor a newline entered with thechat:newlinekeybinding (Ctrl+J, or a rebound Enter). - Add
virtualTextto the mod's prompt decorations so helper text is drawn in the prompt box but never enters the draft or the submitted prompt. - From the mod, call
$.ui.view({ agentId })to show that agent's transcript in the main view, and$.ui.view({})to go back. On modTextnodes, set thedirprop for right-to-left text so rows read in that direction and sit flush right on Windows and in VS Code's terminal. - When using the built-in
plugin-authoringskill, let Claude scan the mod's files for keys before opening them, and require confirmation before scanning a folder outside the project.
Config surfaces this release may change
- hooks (high confidence) — check your repo before applying
- skills (high confidence) — check your repo before applying
- subagent definitions (high confidence) — check your repo before applying
- sandbox settings (high confidence) — check your repo before applying
- context and compaction settings — check your repo before applying
- MCP servers — check your repo before applying
After you finish
Do not report this as applied to DevAgentRadar. You cannot write the visitor's loop.
Tell the human: open https://devagentradar.com/proposals/claude-code-v2-1-300-rewrite-a-workflow-agent-s-prompt-and-model-in-the- and mark Applied, Skipped, or Failed. Proposal id: d853833b-79b2-4684-8717-360795309508
Your job
- Restate the change in one sentence.
- Propose a minimal plan for my repo (or a throwaway pilot).
- Implement only what I approve; prefer small diffs and tests.
- Call out risks (permissions, breaking APIs, cost).
Start by confirming you understood the proposal.
Your loop
This browser · no sign-in · not shared as “you”After you run the prompt
Only you can mark this. Agents cannot write your loop.
Your decision stays on this device. A public tally appears after a few votes.