PYAE1994 commited on
Commit
3f3918a
·
verified ·
1 Parent(s): d045ad7

Update app/agent/executor.py

Browse files
Files changed (1) hide show
  1. app/agent/executor.py +36 -6
app/agent/executor.py CHANGED
@@ -1,24 +1,54 @@
1
  from tools_runtime import execute_tool_call
 
2
  from agent import Agent
3
 
4
- agent = Agent()
5
-
6
 
7
  class Executor:
8
 
 
 
 
 
 
 
 
9
  def run_plan(self, plan):
10
 
11
  results = []
12
 
13
- for step in plan["steps"]:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- print(f"🚀 Executing: {step}")
 
 
16
 
17
- response = agent.run(step)
 
 
 
18
 
 
 
 
19
  results.append({
20
  "step": step,
21
- "result": response
 
22
  })
23
 
24
  return results
 
1
  from tools_runtime import execute_tool_call
2
+ from self_heal import SelfHealer
3
  from agent import Agent
4
 
 
 
5
 
6
  class Executor:
7
 
8
+ def __init__(self, llm=None):
9
+ self.healer = SelfHealer(llm=llm)
10
+ self.agent = Agent()
11
+
12
+ # =====================================================
13
+ # MAIN PLAN EXECUTION LOOP (HYBRID MODE)
14
+ # =====================================================
15
  def run_plan(self, plan):
16
 
17
  results = []
18
 
19
+ for step in plan.get("steps", []):
20
+
21
+ print(f"🚀 Executing step: {step}")
22
+
23
+ # =================================================
24
+ # MODE 1: LOW-LEVEL TOOL EXECUTION
25
+ # =================================================
26
+ tool_result = execute_tool_call({
27
+ "tool": "run_shell",
28
+ "args": {"cmd": step}
29
+ })
30
+
31
+ # =================================================
32
+ # SELF HEAL CHECK (LOW LEVEL)
33
+ # =================================================
34
+ fix = self.healer.heal(step, tool_result)
35
 
36
+ if fix:
37
+ print("🛠️ Self-healing triggered (tool retry)")
38
+ tool_result = execute_tool_call(fix)
39
 
40
+ # =================================================
41
+ # MODE 2: LLM FALLBACK (HIGH-LEVEL EXECUTION)
42
+ # =================================================
43
+ llm_result = self.agent.run(step)
44
 
45
+ # =================================================
46
+ # MERGE RESULTS
47
+ # =================================================
48
  results.append({
49
  "step": step,
50
+ "tool_result": tool_result,
51
+ "llm_result": llm_result
52
  })
53
 
54
  return results