feat(proactive): memory-driven v3#8
Merged
Conversation
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).
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PART Fannotation on eachConceptNode).concept_nodescarriesfollow_up_at+follow_up_hint+advance_pre/post_hoursinstead of a parallelfollow_up_threadstable.FollowUpSchedulerschedules asyncio timers in response to memory'son_event_createdhook. No polling.superseded_by_idchain — no separate close-detection LLM call.SESSION_IDLE_MINUTES30 → 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)+ '' +FollowUpThread+ '' +/+ '' +extract_threads+ '' +/+ '' +close_detection+ '' +/+ '' +HighImpactProactiveObserver+ '' +/+ '' +HIGH_EMOTIONAL_EVENT+ '' +/+ '' +thread_scanner+ '' +all 0 hits in src/+tests/+ '' +tests/proactive/test_round_v3_e2e.py+ '' +· supersede stops post phase across pre/on/postArchitecture changes
+ '' +proactive/execution/follow_up_scheduler.py+ '' +(event-driven asyncio timer per event with smart cooldown per gate)+ '' +proactive/execution/observer.py+ '' +(+ '' +MemoryFollowUpObserver+ '' +bridges memory+ '' +on_event_created+ '' +)+ '' +runtime/wiring/follow_up.py+ '' +(registration + lifecycle wiring)+ '' +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+ '' +)+ '' +quiet_hours+ '' +/+ '' +forbidden_topics+ '' +/+ '' +in_flight_turn+ '' +/+ '' +rate_limit+ '' +/+ '' +engagement_score+ '' +(with high-confidence bypass via+ '' +relational_tags+ '' +∋+ '' +commitment+ '' +/+ '' +vulnerability+ '' +or+ '' +|emotional_impact| >= 7+ '' +)+ '' +/api/admin/proactive/threads+ '' +→+ '' +/api/admin/proactive/events+ '' +· DELETE replaced by+ '' +DELETE /api/admin/memory/events/{id}/proactive-follow-up+ '' ++ '' +screens/Admin/proactive/ProactiveTab.tsx+ '' +reads events+ '' +docs/{en,zh}/proactive.md+ '' +++ '' +docs/{en,zh}/memory.md+ '' +v0.7 columns section+ '' +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
+ '' +set_reminder+ '' +) deferred to v4Detail in
+ '' +docs/{en,zh}/proactive.md+ '' +"Known limitations" ++ '' +CHANGELOG.md+ '' ++ '' +[Unreleased]+ '' +section.