File size: 1,214 Bytes
1699390
b7869b7
1061f4a
b7869b7
1699390
 
b7869b7
1699390
 
 
 
 
 
 
 
 
 
b7869b7
 
1699390
 
b7869b7
 
1699390
1061f4a
1699390
 
6b59156
1699390
 
1061f4a
 
 
 
 
 
 
 
1699390
 
1061f4a
1699390
 
1061f4a
1699390
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from pygmyclaw import PygmyClaw


class AgentExecutor:
    _agent = None  # singleton

    def __init__(self):
        if AgentExecutor._agent is None:
            print("[EXECUTOR] Initializing PygmyClaw once...")
            AgentExecutor._agent = PygmyClaw()

    def run(self, prompt, agent_type):
        agent = AgentExecutor._agent

        system_prompt = self.get_system_prompt(agent_type)

        final_prompt = f"""
{system_prompt}

User Task:
{prompt}
"""

        print(f"[EXECUTOR] Running ({agent_type})")
        print(f"[DEBUG PROMPT]\n{final_prompt[:300]}")

        return agent.generate_with_ssd(final_prompt, max_tokens=512)

    def get_system_prompt(self, agent_type):
        if agent_type == "code":
            return """You are a coding agent.

STRICT RULES:
- Always return Python code inside ```python ``` blocks
- Do NOT return JSON tools
- Do NOT use "echo"
- Code must be directly executable
"""
        elif agent_type == "research":
            return "You are a research agent. Provide detailed factual answers."

        elif agent_type == "image":
            return "You are an image generation planner."

        else:
            return "You are a command execution agent."