autonomy build, phase 1

This commit is contained in:
serversdwn
2025-12-14 01:44:05 -05:00
parent fa4dd46cfc
commit 49f792f20c
10 changed files with 735 additions and 14 deletions

View File

@@ -99,6 +99,7 @@ async def run_reason(req: ReasonRequest):
if VERBOSE_DEBUG:
logger.debug("[STAGE 0.6] Running inner monologue...")
inner_result = None
try:
self_state = load_self_state()
@@ -112,9 +113,33 @@ async def run_reason(req: ReasonRequest):
inner_result = await inner_monologue.process(mono_context)
logger.info(f"[INNER_MONOLOGUE] {inner_result}")
# Store in context for downstream use
context_state["monologue"] = inner_result
except Exception as e:
logger.warning(f"[INNER_MONOLOGUE] failed: {e}")
# ----------------------------------------------------------------
# STAGE 0.7 — Executive Planning (conditional)
# ----------------------------------------------------------------
executive_plan = None
if inner_result and inner_result.get("consult_executive"):
if VERBOSE_DEBUG:
logger.debug("[STAGE 0.7] Executive consultation requested...")
try:
from autonomy.executive.planner import plan_execution
executive_plan = await plan_execution(
user_prompt=req.user_prompt,
intent=inner_result.get("intent", "unknown"),
context_state=context_state,
identity_block=identity_block
)
logger.info(f"[EXECUTIVE] Generated plan: {executive_plan.get('summary', 'N/A')}")
except Exception as e:
logger.warning(f"[EXECUTIVE] Planning failed: {e}")
executive_plan = None
# ----------------------------------------------------------------
# STAGE 1 — Intake summary
# ----------------------------------------------------------------
@@ -154,7 +179,9 @@ async def run_reason(req: ReasonRequest):
identity_block=identity_block,
rag_block=context_state.get("rag", []),
reflection_notes=reflection_notes,
context=context_state
context=context_state,
monologue=inner_result, # NEW: Pass monologue guidance
executive_plan=executive_plan # NEW: Pass executive plan
)
# ----------------------------------------------------------------
@@ -178,13 +205,31 @@ async def run_reason(req: ReasonRequest):
if VERBOSE_DEBUG:
logger.debug("[STAGE 5] Applying persona layer...")
persona_answer = await speak(final_neutral)
# Extract tone and depth from monologue for persona guidance
tone = inner_result.get("tone", "neutral") if inner_result else "neutral"
depth = inner_result.get("depth", "medium") if inner_result else "medium"
persona_answer = await speak(final_neutral, tone=tone, depth=depth)
# ----------------------------------------------------------------
# STAGE 6 — Session update
# ----------------------------------------------------------------
update_last_assistant_message(req.session_id, persona_answer)
# ----------------------------------------------------------------
# STAGE 6.5 — Self-state update
# ----------------------------------------------------------------
try:
from autonomy.self.analyzer import analyze_and_update_state
await analyze_and_update_state(
monologue=inner_result or {},
user_prompt=req.user_prompt,
response=persona_answer,
context=context_state
)
except Exception as e:
logger.warning(f"[SELF_STATE] Update failed: {e}")
if VERBOSE_DEBUG:
logger.debug(f"\n{'='*80}")
logger.debug(f"[PIPELINE COMPLETE] Session: {req.session_id}")