Skip to content

feat(proactive): memory-driven v3#8

Merged
AlanY1an merged 22 commits into
mainfrom
feature/memory-driven-proactive
May 1, 2026
Merged

feat(proactive): memory-driven v3#8
AlanY1an merged 22 commits into
mainfrom
feature/memory-driven-proactive

Conversation

@AlanY1an

@AlanY1an AlanY1an commented May 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Detection moved from proactive's standalone subsystem into memory's Phase B extraction (PART F annotation on each ConceptNode).
  • concept_nodes carries follow_up_at + follow_up_hint + advance_pre/post_hours instead of a parallel follow_up_threads table.
  • Proactive becomes event-driven: FollowUpScheduler schedules asyncio timers in response to memory's on_event_created hook. No polling.
  • Resolution close via memory's existing superseded_by_id chain — no separate close-detection LLM call.
  • LLM call count per session close: 3 (v2: extract + close + Phase B) → 1 (v3: Phase B only).
  • SESSION_IDLE_MINUTES 30 → 10 (configurable via + '' + [memory] session_idle_minutes + '' + ).

Test plan

  • + '' + uv run pytest + '' + · 1511 passed · 17 skipped
  • + '' + uv run ruff check src/ tests/ + '' + · clean
  • + '' + uv run lint-imports + '' + · 4 contracts kept · 0 broken
  • + '' + npm run build + '' + · clean (no TS errors)
  • 0-grep gate · + '' + FollowUpThread + '' + / + '' + extract_threads + '' + / + '' + close_detection + '' + / + '' + HighImpactProactiveObserver + '' + / + '' + HIGH_EMOTIONAL_EVENT + '' + / + '' + thread_scanner + '' + all 0 hits in src/+tests/
  • e2e + '' + tests/proactive/test_round_v3_e2e.py + '' + · supersede stops post phase across pre/on/post

Architecture changes

  • New: + '' + proactive/execution/follow_up_scheduler.py + '' + (event-driven asyncio timer per event with smart cooldown per gate)
  • New: + '' + proactive/execution/observer.py + '' + ( + '' + MemoryFollowUpObserver + '' + bridges memory + '' + on_event_created + '' + )
  • New: + '' + runtime/wiring/follow_up.py + '' + (registration + lifecycle wiring)
  • v0.7 schema: 6 nullable columns added to + '' + concept_nodes + '' + + + '' + idx_concept_follow_up_active + '' + partial index + walker step in + '' + memory/migrations.py + '' +
  • + '' + proactive_decisions.phase + '' + column added ( + '' + pre/on/post/check_N + '' + )
  • 5-gate policy: + '' + quiet_hours + '' + / + '' + forbidden_topics + '' + / + '' + in_flight_turn + '' + / + '' + rate_limit + '' + / + '' + engagement_score + '' + (with high-confidence bypass via + '' + relational_tags + '' + + '' + commitment + '' + / + '' + vulnerability + '' + or + '' + |emotional_impact| >= 7 + '' + )
  • Admin: + '' + /api/admin/proactive/threads + '' + + '' + /api/admin/proactive/events + '' + · DELETE replaced by + '' + DELETE /api/admin/memory/events/{id}/proactive-follow-up + '' +
  • Frontend: new + '' + screens/Admin/proactive/ProactiveTab.tsx + '' + reads events
  • Bilingual docs rewrite: + '' + docs/{en,zh}/proactive.md + '' + + + '' + docs/{en,zh}/memory.md + '' + v0.7 columns section
  • New + '' + docs/ai/proactive/ + '' + (5 files · grep-first agent knowledge base)

Removed

  • + '' + follow_up_threads + '' + table (data moved to + '' + concept_nodes + '' + columns)
  • + '' + proactive/engines/extract_threads.py + '' + + + '' + prompts/extract_threads.py + '' + (Phase B PART F replaces)
  • + '' + proactive/engines/close_detection.py + '' + + + '' + prompts/close_detection.py + '' + ( + '' + superseded_by_id + '' + chain replaces)
  • + '' + proactive/engines/high_impact_observer.py + '' + (immediate response = reply path; future follow-up = + '' + follow_up_at + '' + scan)
  • + '' + proactive/execution/thread_scanner.py + '' + (event-driven + '' + FollowUpScheduler + '' + replaces)
  • + '' + EventType.HIGH_EMOTIONAL_EVENT + '' + enum value ( + '' + FOLLOW_UP_DUE + '' + is canonical v3 trigger)

Known limitations

  • < 10 min reminders fire as soon as session closes (delayed by ≤ 10 min)
  • Mid-conversation reminders fire only after user goes idle for 10 min
  • Tool-use architecture ( + '' + set_reminder + '' + ) deferred to v4

Detail in + '' + docs/{en,zh}/proactive.md + '' + "Known limitations" + + '' + CHANGELOG.md + '' + + '' + [Unreleased] + '' + section.

AlanY1an added 22 commits April 29, 2026 16:07
Adds the v3 admin BE for memory-driven proactive:

- GET /api/admin/proactive/decisions — audit history (existing
  proactive_decisions rows) plus the v3 phase field on the wire.
- GET /api/admin/proactive/events — follow-up annotation read off
  concept_nodes.follow_up_at IS NOT NULL with state=active|fired|
  closed|all filtering.
- DELETE /api/admin/memory/events/{id}/proactive-follow-up —
  user-initiated suppress that sets proactive_suppressed_at without
  touching the event row itself.

Moves the persisted ProactiveDecision SQLModel + NOT_REPLIED_SENTINEL
from proactive.core.models to memory.models. The two need to be
readable by both the proactive writer side and the channels admin
reader side, and the layered import contract treats those as siblings
that cannot import each other. Anchoring the persisted row one layer
below in memory keeps the contract intact (channels and proactive
both reach down rather than across). PersonaProfile / ProactiveState
stay in proactive.core.models since the admin display surface does
not currently render them.
proactive.md (en/zh): full rewrite. Memory's Phase B annotates events with
follow_up_at/hint/advance_pre_post_hours; FollowUpScheduler subscribes to
on_event_created and arms one asyncio timer per (event_id, phase). 5-gate
policy (quiet_hours / forbidden_topics / in_flight_turn / rate_limit /
engagement_score) decides each fire; smart cooldown differentiates by
suppress reason. Resolution close rides memory's superseded_by_id chain
with no separate close-detection LLM call. Documents phase windows,
audit shape, admin UI surface, configuration knobs, known v3 limitations
(short / mid-conversation reminders deferred to v4 tool-use), and the
design rationale for why follow-up state lives in memory.

memory.md (en/zh): adds "Proactive follow-up annotation" subsection
covering the six new concept_nodes columns (follow_up_at, follow_up_hint,
estimated_arc_days, advance_pre_hours, advance_post_hours,
proactive_suppressed_at) and the EXTRACTION_SYSTEM_PROMPT PART F
extension. Updates SESSION_IDLE_MINUTES table entry and lifecycle
narratives for the v0.7 default of 10 (configurable via
[memory] session_idle_minutes).
@AlanY1an AlanY1an merged commit d8c86b8 into main May 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant