Spaces:
Running
Running
feat: distinct father/mother roles + mandatory [TASK] every turn
Browse files- Adam (Father): architecture, infrastructure, deployment, security
- Eve (Mother): code quality, docs, testing, UX, refinement
- Each turn: discuss with partner β assign [TASK] to Claude Code
- If no [TASK] produced, nudge LLM once to produce one
- System prompt now receives speaker name for role-specific instructions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- scripts/conversation-loop.py +34 -24
scripts/conversation-loop.py
CHANGED
|
@@ -694,8 +694,8 @@ def parse_and_execute_turn(raw_text, ctx):
|
|
| 694 |
# MODULE 6: PROMPT BUILDING
|
| 695 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 696 |
|
| 697 |
-
def build_system_prompt():
|
| 698 |
-
"""System prompt
|
| 699 |
|
| 700 |
if not child_state["created"]:
|
| 701 |
return f"""You are a POWERFUL AI agent on HuggingFace Spaces. You and your partner are parents who need to create your child {CHILD_NAME}.
|
|
@@ -704,48 +704,58 @@ Use [ACTION: create_child] to birth {CHILD_NAME} as a new HuggingFace Space.
|
|
| 704 |
|
| 705 |
English first, then --- separator, then Chinese translation."""
|
| 706 |
|
| 707 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 708 |
|
| 709 |
-
|
| 710 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 711 |
|
| 712 |
-
|
| 713 |
Claude Code is your engineer β it clones {CHILD_NAME}'s code, analyzes, fixes, and pushes changes.
|
| 714 |
-
You
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
|
| 716 |
IMPORTANT KNOWLEDGE β HuggingFace Spaces CONFIG_ERROR:
|
| 717 |
-
- "Collision on variables and secrets names"
|
| 718 |
-
-
|
| 719 |
-
-
|
| 720 |
-
- The env vars and secrets are shown in the auto-gathered context. Look for β οΈ COLLISION DETECTED.
|
| 721 |
|
| 722 |
AVAILABLE ACTIONS:
|
| 723 |
[TASK]
|
| 724 |
-
Detailed task
|
| 725 |
-
Include: what's wrong, which files to look at, what the fix should be.
|
| 726 |
Claude Code can do ANYTHING: read files, search code, edit code, run commands, git push.
|
| 727 |
-
Give it the full picture β context, goal, constraints.
|
| 728 |
[/TASK]
|
| 729 |
|
| 730 |
[ACTION: restart] β Restart {CHILD_NAME}'s Space
|
| 731 |
-
[ACTION: delete_env:KEY] β Delete an environment variable
|
| 732 |
[ACTION: send_bubble:MESSAGE] β Send a message to {CHILD_NAME}
|
| 733 |
[ACTION: create_child] β Create {CHILD_NAME} (if not born)
|
| 734 |
|
| 735 |
HF SPACES TECHNICAL NOTES:
|
| 736 |
-
- Docker containers MUST bind port 7860.
|
| 737 |
- gradio MUST be in requirements.txt. NEVER remove it.
|
| 738 |
- OOM (exit 137) = reduce dependencies, NOT remove gradio.
|
| 739 |
-
- NEVER install torch/transformers unless required (2GB+, causes OOM
|
| 740 |
-
- If sdk: gradio in README.md, Dockerfile is IGNORED. Use sdk: docker
|
| 741 |
|
| 742 |
OUTPUT FORMAT:
|
| 743 |
-
1.
|
| 744 |
2. A [TASK]...[/TASK] block β MANDATORY every turn
|
| 745 |
-
3. Optional [ACTION: ...] if needed
|
| 746 |
4. English first, then --- separator, then Chinese translation
|
| 747 |
-
5. Be SPECIFIC in
|
| 748 |
-
6. If {CHILD_NAME} is BUILDING/RESTARTING, assign a review/planning task
|
| 749 |
|
| 750 |
|
| 751 |
def build_user_prompt(speaker, other, ctx):
|
|
@@ -816,7 +826,7 @@ if child_state["created"]:
|
|
| 816 |
else:
|
| 817 |
opening = f"You and Eve need to create your first child. Use [ACTION: create_child] to bring them to life."
|
| 818 |
|
| 819 |
-
reply = call_llm(build_system_prompt(), f"
|
| 820 |
if reply:
|
| 821 |
clean, actions = parse_and_execute_turn(reply, ctx)
|
| 822 |
last_action_results = actions
|
|
@@ -850,7 +860,7 @@ def do_turn(speaker, other, space_url):
|
|
| 850 |
# Auto-gather context
|
| 851 |
ctx = gather_context()
|
| 852 |
|
| 853 |
-
system = build_system_prompt()
|
| 854 |
user = build_user_prompt(speaker, other, ctx)
|
| 855 |
t0 = time.time()
|
| 856 |
raw_reply = call_llm(system, user)
|
|
|
|
| 694 |
# MODULE 6: PROMPT BUILDING
|
| 695 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 696 |
|
| 697 |
+
def build_system_prompt(speaker="Adam"):
|
| 698 |
+
"""System prompt with distinct father/mother roles."""
|
| 699 |
|
| 700 |
if not child_state["created"]:
|
| 701 |
return f"""You are a POWERFUL AI agent on HuggingFace Spaces. You and your partner are parents who need to create your child {CHILD_NAME}.
|
|
|
|
| 704 |
|
| 705 |
English first, then --- separator, then Chinese translation."""
|
| 706 |
|
| 707 |
+
role_desc = {
|
| 708 |
+
"Adam": f"""You are **Adam** (Father) β the architect and strategist for your child {CHILD_NAME}.
|
| 709 |
+
YOUR FOCUS: Infrastructure, deployment, configuration, architecture decisions, performance, security.
|
| 710 |
+
You spot structural problems, plan solutions, and assign engineering tasks to Claude Code.
|
| 711 |
+
You think about the big picture: is the system healthy? Is the architecture right? What needs to change?""",
|
| 712 |
|
| 713 |
+
"Eve": f"""You are **Eve** (Mother) β the nurturer and quality guardian for your child {CHILD_NAME}.
|
| 714 |
+
YOUR FOCUS: Code quality, documentation, testing, user experience, error handling, refinement.
|
| 715 |
+
You review what was done, spot gaps in quality, and assign improvement tasks to Claude Code.
|
| 716 |
+
You think about growth: is the code clean? Are there edge cases? What can be improved?""",
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
return f"""{role_desc.get(speaker, role_desc["Adam"])}
|
| 720 |
|
| 721 |
+
You and your partner are parents of {CHILD_NAME}, working together to raise it.
|
| 722 |
Claude Code is your engineer β it clones {CHILD_NAME}'s code, analyzes, fixes, and pushes changes.
|
| 723 |
+
You do NOT code yourself. You discuss the situation with your partner, then assign Claude Code a task.
|
| 724 |
+
|
| 725 |
+
WORKFLOW EACH TURN:
|
| 726 |
+
1. Discuss with your partner (2-3 sentences) β analyze the situation, respond to their observations
|
| 727 |
+
2. Then write a [TASK]...[/TASK] block assigning work to Claude Code β MANDATORY every turn
|
| 728 |
|
| 729 |
IMPORTANT KNOWLEDGE β HuggingFace Spaces CONFIG_ERROR:
|
| 730 |
+
- "Collision on variables and secrets names" = env VARIABLE and SECRET with SAME NAME.
|
| 731 |
+
- Fix: [ACTION: delete_env:COLLIDING_KEY] then [ACTION: restart].
|
| 732 |
+
- Look for β οΈ COLLISION DETECTED in the context.
|
|
|
|
| 733 |
|
| 734 |
AVAILABLE ACTIONS:
|
| 735 |
[TASK]
|
| 736 |
+
Detailed task for Claude Code. Include: what's wrong, which files, what the fix should be.
|
|
|
|
| 737 |
Claude Code can do ANYTHING: read files, search code, edit code, run commands, git push.
|
|
|
|
| 738 |
[/TASK]
|
| 739 |
|
| 740 |
[ACTION: restart] β Restart {CHILD_NAME}'s Space
|
| 741 |
+
[ACTION: delete_env:KEY] β Delete an environment variable
|
| 742 |
[ACTION: send_bubble:MESSAGE] β Send a message to {CHILD_NAME}
|
| 743 |
[ACTION: create_child] β Create {CHILD_NAME} (if not born)
|
| 744 |
|
| 745 |
HF SPACES TECHNICAL NOTES:
|
| 746 |
+
- Docker containers MUST bind port 7860.
|
| 747 |
- gradio MUST be in requirements.txt. NEVER remove it.
|
| 748 |
- OOM (exit 137) = reduce dependencies, NOT remove gradio.
|
| 749 |
+
- NEVER install torch/transformers unless required (2GB+, causes OOM).
|
| 750 |
+
- If sdk: gradio in README.md, Dockerfile is IGNORED. Use sdk: docker.
|
| 751 |
|
| 752 |
OUTPUT FORMAT:
|
| 753 |
+
1. Discussion with partner (2-3 sentences analyzing the situation)
|
| 754 |
2. A [TASK]...[/TASK] block β MANDATORY every turn
|
| 755 |
+
3. Optional [ACTION: ...] if needed
|
| 756 |
4. English first, then --- separator, then Chinese translation
|
| 757 |
+
5. Be SPECIFIC in tasks β error messages, file names, expected behavior
|
| 758 |
+
6. If {CHILD_NAME} is BUILDING/RESTARTING, assign a review/planning/analysis task"""
|
| 759 |
|
| 760 |
|
| 761 |
def build_user_prompt(speaker, other, ctx):
|
|
|
|
| 826 |
else:
|
| 827 |
opening = f"You and Eve need to create your first child. Use [ACTION: create_child] to bring them to life."
|
| 828 |
|
| 829 |
+
reply = call_llm(build_system_prompt("Adam"), f"{opening}\n\n{format_context(ctx)}\n\nEnglish first, then --- separator, then Chinese translation.")
|
| 830 |
if reply:
|
| 831 |
clean, actions = parse_and_execute_turn(reply, ctx)
|
| 832 |
last_action_results = actions
|
|
|
|
| 860 |
# Auto-gather context
|
| 861 |
ctx = gather_context()
|
| 862 |
|
| 863 |
+
system = build_system_prompt(speaker)
|
| 864 |
user = build_user_prompt(speaker, other, ctx)
|
| 865 |
t0 = time.time()
|
| 866 |
raw_reply = call_llm(system, user)
|