feat: make AI brain the primary driver of all goal-oriented navigation

This commit is contained in:
2026-04-27 22:51:27 +02:00
parent 12937cb2c1
commit c93333928a

View File

@@ -101,7 +101,17 @@ class GoalPlanner:
if count >= 2: # MAX_RETRIES is 2 in goap
avoid_actions.add(act)
# ── 1. HD Map Routing (Primary Strategy) ──
# ── 1. Brain-Driven Decision Making (Primary Strategy) ──
# The user explicitly wants the AI to be the primary driver of goals.
from GramAddict.core.navigation.brain import ask_brain_for_action
brain_action = ask_brain_for_action(goal, screen_type.name, available, explored_nav_actions)
if brain_action:
logger.info(f"🧠 [Brain] Decided dynamically to execute: '{brain_action}'")
return brain_action
# ── 2. HD Map Routing (Fallback) ──
# If the Brain doesn't know what to do, try the deterministic topological map.
target_screen = ScreenTopology.goal_to_target_screen(goal)
if target_screen and target_screen != screen_type:
route = ScreenTopology.find_route(screen_type, target_screen, avoid_actions=avoid_actions)
@@ -116,21 +126,12 @@ class GoalPlanner:
)
return next_action
else:
logger.warning(f"🛡️ [HD Map] Route action '{next_action}' is trapped. Falling back to brain.")
logger.warning(f"🛡️ [HD Map] Route action '{next_action}' is trapped. Skipping HD Map.")
else:
logger.debug(
f"🛡️ [HD Map] Route action '{next_action}' already explored and failed. Falling back to brain."
f"🛡️ [HD Map] Route action '{next_action}' already explored and failed. Skipping HD Map."
)
# ── 1.5 Brain-Driven Decision Making (Preventing Trapped States) ──
# If HD Map didn't yield a valid action, or we're stuck, ask the AI brain.
from GramAddict.core.navigation.brain import ask_brain_for_action
brain_action = ask_brain_for_action(goal, screen_type.name, available, explored_nav_actions)
if brain_action:
logger.info(f"🧠 [Brain] Decided dynamically to execute: '{brain_action}'")
return brain_action
# ── 2. Learned Knowledge (Qdrant) ──
required_screens = self.knowledge.get_requirements(goal)