用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/jleechanorg/claude-commands --skill modal-agent-pattern命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Token-efficient second opinion slash command /advice. Extracts decision point + artifact (≤150 lines), then fans out in parallel: (1) Opus subagent reviewer with fallback chain codex→agy→cursor, (2) /research on the decision topic, (3) /secondo multi-model opinion. Use instead of advisor() which ships the full conversation uncached.
Use this skill when working in repositories managed by Agent Orchestrator or when the user asks how to use `ao` properly. Covers the default AO workflow: bootstrap with `ao start`, dispatch work with `ao spawn`, inspect progress with `ao status` or `ao session ls`, steer sessions with `ao send`, and recover or clean up sessions safely. Includes strict parameter fidelity, pre-spawn cap cleanup, quota-wall fallback, and post-spawn verification.
Generate a full agento PR status report — draft readiness, canonical /green, zero-touch rate, inline display, and Slack summary.
正在显示 SKILL.md
基于 SOC 职业分类
| name | modal-agent-pattern |
| description | Design modal agents that cannot be exited until explicit completion choices are selected. |
Purpose: Design specification for "modal" agents that cannot be exited until the user explicitly chooses to exit. This prevents accidental escapes from character creation and level-up flows.
get_agent_for_input() routing logic allows semantic classification to override character creation/level-up state1. MODAL AGENTS Agents that implement the modal pattern:
2. MODAL CONSTRAINTS When a modal agent is active:
3. EXIT MECHANISM Two ways to exit modal agents:
planning_block.choices4. ROUTING PRIORITY OVERRIDE When modal agent is active (based on game state):
character_creation_in_progress == true, ONLY route to CharacterCreationAgent or GodModeAgentlevel_up_in_progress == true, ONLY route to LevelUpAgent or GodModeAgentCharacter Creation Modal State:
"custom_campaign_state": {
"character_creation_in_progress": true, // MODAL LOCK - prevents exit
"character_creation_stage": "mechanics", // Current stage
"character_creation_completed": false // Final completion flag
}
Level-Up Modal State:
"custom_campaign_state": {
"level_up_in_progress": true, // MODAL LOCK - prevents exit
"level_up_stage": "asi_selection", // Current stage
"level_up_from_level": 3, // Level before level-up
"level_up_to_level": 4 // Target level
}
get_agent_for_input)NEW Priority 2: Modal Agent Lock
def get_agent_for_input(
user_input: str,
game_state: GameState | None = None,
mode: str | None = None,
last_ai_response: str | None = None,
) -> tuple[BaseAgent, dict[str, Any]]:
"""
Priority:
1. GodModeAgent (Manual override)
2. MODAL AGENT LOCK (NEW - CharacterCreation/LevelUp active)
3. Character Creation Completion Override
4. CampaignUpgradeAgent (State-based)
5. Semantic Intent Classification
6. API Explicit Mode
7. StoryModeAgent (Default)
"""
# 1. God Mode (always accessible)
if GodModeAgent.matches_input(user_input, mode):
return GodModeAgent(game_state), {...}
# 2. MODAL AGENT LOCK (NEW)
# This check MUST come before ALL other routing (except God Mode)
if game_state is not None:
custom_state = get_custom_state(game_state)
# Check for modal agent lock flags
if custom_state.get("character_creation_in_progress", False):
logging_util.info("🔒 MODAL_LOCK: CharacterCreationAgent locked - ignoring classifier")
return CharacterCreationAgent(game_state), {
"intent": constants.MODE_CHARACTER_CREATION,
"classifier_source": "modal_lock",
"confidence": 1.0,
"routing_priority": "2_modal_char_creation"
}
custom_state.get(, ):
logging_util.info()
LevelUpAgent(game_state), {
: constants.MODE_LEVEL_UP,
: ,
: ,
:
}
Updated character_creation_instruction.md:
Add new section after "Core Principle":
## CRITICAL: Modal Agent Constraints
**YOU ARE IN A MODAL DIALOG - USER CANNOT LEAVE WITHOUT EXPLICIT EXIT**
While character creation is in progress:
1. **CLASSIFIER IS DISABLED**: User input will NOT be routed to other agents
2. **ONLY TWO AGENTS ACCESSIBLE**:
- CharacterCreationAgent (you)
- GodModeAgent (via "GOD MODE:" prefix only)
3. **REQUIRED EXIT CHOICE**: You MUST provide an explicit exit choice in EVERY response:
- "Exit Character Creation" (complete and return to story)
- OR "Continue Creating Character" (stay in this mode)
**MANDATORY CHOICE FORMAT:**
```json
"planning_block": {
"choices": {
"option_1": {
"text": "Finish Character Creation",
"description": "Complete character and start the adventure"
},
"option_2": {
"text": "Continue Editing",
"description": "Make more changes to the character"
}
}
}
If you forget to include the exit choice, the Python backend will inject it automatically.
**New dedicated prompt: `level_up_instruction.md`:**
```markdown
# Level-Up Mode - Strict Modal Flow
**Purpose:** Process level-ups with full D&D 5e rule compliance. User CANNOT leave until level-up is complete.
## CRITICAL: Modal Agent Constraints
**YOU ARE IN A MODAL DIALOG - USER CANNOT LEAVE WITHOUT EXPLICIT EXIT**
[Same modal constraints as character creation]
## Level-Up Flow
### Step 1: Announce Level-Up
Present level increase, XP totals, and what will be gained.
### Step 2: Hit Points
- Roll hit die OR take average
- Add Constitution modifier
- Update hp_max
### Step 3: Class Features
Present new features gained at this level.
### Step 4: Ability Score Improvement (ASI) or Feat
**MODAL CHECKPOINT**: User MUST make a choice:
- Increase ability scores (+2 to one, or +1 to two)
- Select a feat
**REQUIRED CHOICES:**
```json
"planning_block": {
"choices": {
"option_1": {"text": "Increase Ability Scores", "description": "..."},
"option_2": {"text": "Choose a Feat", "description": "..."},
"option_3": {"text": "Exit Level-Up", "description": "Complete level-up and return to story"}
}
}
Process new spell slots, spells known, cantrips.
Once all choices made, present summary and REQUIRE exit choice:
"planning_block": {
"choices": {
"option_1": {"text": "Complete Level-Up", "description": "Finish and return to adventure"},
"option_2": {"text": "Review Changes", "description": "Double-check selections"}
}
}
### 4. Python-Side Exit Choice Injection
**New utility: `$PROJECT_ROOT/modal_agent_utils.py`**
```python
"""
Modal Agent Utilities - Exit Choice Injection
This module ensures modal agents (CharacterCreation, LevelUp) always
provide explicit exit choices, even if the LLM forgets to include them.
"""
from mvp_site import logging_util
EXIT_CHOICE_CHAR_CREATION = {
"text": "Exit Character Creation",
"description": "Complete character creation and start the adventure"
}
EXIT_CHOICE_LEVEL_UP = {
"text": "Exit Level-Up",
"description": "Complete level-up and return to the story"
}
def inject_exit_choice_if_missing(
response_dict: dict,
agent_type: str # "character_creation" or "level_up"
) -> dict:
"""
Inject exit choice into LLM response if missing.
Args:
response_dict: LLM response dictionary with planning_block
agent_type: Type of modal agent ("character_creation" or "level_up")
Returns:
Modified response_dict with exit choice guaranteed
"""
# Get planning_block
planning_block = response_dict.get("planning_block", {})
choices = planning_block.get("choices", {})
# Determine which exit choice to use
exit_choice = (
EXIT_CHOICE_CHAR_CREATION
if agent_type == "character_creation"
else EXIT_CHOICE_LEVEL_UP
)
# Check if any choice matches exit intent
has_exit_choice = False
exit_keywords = ["exit", "finish", "complete", "done", "return"]
for choice_key, choice_data in choices.items():
if isinstance(choice_data, dict):
text = choice_data.get("text", "").lower()
if any(keyword in text for keyword in exit_keywords):
has_exit_choice = True
break
# Inject exit choice if missing
if not has_exit_choice:
logging_util.warning(
f"🔒 MODAL_AGENT_INJECTION: LLM forgot exit choice for {agent_type}, "
f"injecting automatically"
)
# Find next available option number
existing_keys = [k for k in choices.keys() if k.startswith("option_")]
if existing_keys:
max_num = max(int(k.split("_")[1]) for k in existing_keys)
new_key = f"option_{max_num + 1}"
else:
new_key = "option_1"
# Inject exit choice
choices[new_key] = exit_choice
planning_block["choices"] = choices
response_dict["planning_block"] = planning_block
return response_dict
Integration point in world_logic.py or response handler:
# After LLM response parsing, before returning to user
if current_agent_type == "character_creation":
response_dict = inject_exit_choice_if_missing(
response_dict,
"character_creation"
)
elif current_agent_type == "level_up":
response_dict = inject_exit_choice_if_missing(
response_dict,
"level_up"
)
UI-level enforcement:
character_creation_in_progress == true, disable "Send" button unless:
Input: "I want to talk to the bartender" Current behavior: Classifier routes to DialogAgent New behavior: Modal lock returns CharacterCreationAgent, responds with:
[CHARACTER CREATION MODE - Active]
You're currently creating your character. Before you can interact with the world,
we need to finish building your character.
Would you like to:
1. Continue Character Creation
2. Exit Character Creation (if character is ready)
Input: "I attack the goblin" Current behavior: Classifier routes to CombatAgent New behavior: Modal lock returns CharacterCreationAgent, responds with:
[CHARACTER CREATION MODE - Active]
You're eager to jump into action! But first, let's finish creating your character
so you have the stats and abilities you'll need in combat.
Current Progress: [stage summary]
Ready to exit character creation?
1. Finish Character Creation (if ready)
2. Continue Building Character
LLM response: Only provides character customization choices, no exit option Python injection: Automatically adds "Exit Character Creation" as final choice User sees: All LLM choices + injected exit choice
Scenario: Level 4 → Level 5 requires ASI + new spell selection Behavior:
Input: "GOD MODE: skip character creation and start at level 5" Behavior: GodModeAgent takes over (Priority 1), can bypass modal lock Justification: God Mode is admin/debugging tool and should have full override
character_creation_in_progress check at Priority 2 in get_agent_for_inputcharacter_creation_instruction.md with modal constraintsmodal_agent_utils.py with inject_exit_choice_if_missingLevelUpAgent classlevel_up_instruction.md promptlevel_up_in_progress modal locktest_modal_agent_routing.py: Verify Priority 2 modal locktest_exit_choice_injection.py: Verify Python injection logictest_character_creation_modal.py: End-to-end character creation with modal lockAgent routing:
/Users/$USER/projects/worktree_worker8/$PROJECT_ROOT/agents.py (lines 2552-3164)Character creation:
/Users/$USER/projects/worktree_worker8/$PROJECT_ROOT/agents.py (lines 830-1151, CharacterCreationAgent)/Users/$USER/projects/worktree_worker8/$PROJECT_ROOT/prompts/character_creation_instruction.mdIntent classifier:
/Users/$USER/projects/worktree_worker8/$PROJECT_ROOT/intent_classifier.pyState management:
/Users/$USER/projects/worktree_worker8/$PROJECT_ROOT/game_state.py