generated from coulomb/repo-seed
CYA-WP-0005 T05 done (ralph iter 5): Minimal Profile 1 (Reflexion verbal) spike
- Added KIND_REFLECTION + remember_reflection() helper in memory (thin, exported). - Wired into run_retrospection(): optional 'capture verbal lesson' step at end. - Main recall now includes reflections for preferential activation. - Final LLM response + explain surface verbal reflections when activated. - Added roundtrip test + import updates. - Small README note. - All changes small/inspectable, safety preserved (still through RiskClassifier). - T05 acceptance criteria met with working end-to-end spike. Committed as ralph iter 5. Ready for T06+ or close.
This commit is contained in:
@@ -32,8 +32,10 @@ from cya.context.collector import collect, render_explanation
|
||||
from cya.memory import (
|
||||
recall_preferences,
|
||||
remember_retrospection_outcome,
|
||||
remember_reflection,
|
||||
KIND_RETROSPECTION,
|
||||
KIND_INTERACTION_GOAL,
|
||||
KIND_REFLECTION,
|
||||
)
|
||||
from cya.safety.risk import classify, get_user_confirmation
|
||||
from cya.llm.adapter import AssistanceRequest, FakeLLMAdapter
|
||||
@@ -85,7 +87,11 @@ def handle_request(
|
||||
git_info = envelope.git or {}
|
||||
if git_info.get("workdir"):
|
||||
act_ctx["git_root"] = git_info["workdir"]
|
||||
memory = recall_preferences(".", activation_context=act_ctx)
|
||||
memory = recall_preferences(
|
||||
".",
|
||||
activation_context=act_ctx,
|
||||
kinds=[KIND_REFLECTION, KIND_RETROSPECTION, KIND_INTERACTION_GOAL, "preference"],
|
||||
)
|
||||
except Exception:
|
||||
memory = {"error": "recall failed (graceful degradation)"}
|
||||
|
||||
@@ -150,6 +156,12 @@ def handle_request(
|
||||
mem_line = ""
|
||||
if memory.get("items"):
|
||||
mem_line = f"\n[dim]Memory activated: {len(memory.get('items', []))} items (phase {memory.get('phase')})[/dim]"
|
||||
# Minimal Profile 1 surface (T05 spike)
|
||||
reflections = [i for i in memory.get("items", []) if i.get("kind") == KIND_REFLECTION]
|
||||
if reflections:
|
||||
refl_text = "; ".join(str(i.get("value", ""))[:60] for i in reflections[:2])
|
||||
mem_line += f"\n[cyan]Verbal reflections activated: {len(reflections)} — {refl_text}[/cyan]"
|
||||
|
||||
console.print(
|
||||
Panel(
|
||||
f"[bold]Suggestion:[/bold]\n{llm_response.suggestion}\n\n"
|
||||
@@ -251,6 +263,24 @@ def run_retrospection(scope: str = ".", limit: int = 8) -> None:
|
||||
)
|
||||
console.print("[green]Recorded as safety preference.[/green]")
|
||||
|
||||
# Minimal Profile 1 spike (T05): optional verbal reflection / lesson capture
|
||||
capture_lesson = typer.prompt(
|
||||
"Capture any verbal lessons or reflections from this session? (y/n or short text)",
|
||||
default="n",
|
||||
show_default=False,
|
||||
)
|
||||
if capture_lesson and capture_lesson.lower() not in ("n", "no", "skip", "s", ""):
|
||||
lesson_text = capture_lesson if len(capture_lesson) > 3 else typer.prompt(
|
||||
"What is the key lesson? (1-2 sentences)",
|
||||
default="",
|
||||
show_default=False,
|
||||
)
|
||||
if lesson_text:
|
||||
remember_reflection(
|
||||
"verbal_lesson", lesson_text, scope=scope
|
||||
)
|
||||
console.print("[green]Recorded as verbal reflection (Profile 1).[/green]")
|
||||
|
||||
console.print(
|
||||
Panel(
|
||||
"Thank you. Your reflections have been stored as retrospection memory.\n"
|
||||
|
||||
Reference in New Issue
Block a user