Files
memex/notes/org-skill-long-horizon.org

90 lines
3.5 KiB
Org Mode

#+TITLE: SKILL: Long-Horizon Planning Agent (Universal Literate Note)
#+ID: skill-long-horizon
#+STARTUP: content
#+FILETAGS: :planning:meta-cognition:long-horizon:psf:
* Overview
The *Long-Horizon Planning Agent* manages complex, multi-step tasks that exceed the context window of standard LLMs. It uses an Org-mode *Dynamic Task Tree* to track progress, summarize completed sub-tasks, and prune irrelevant execution branches.
* Phase A: Demand (PRD)
:PROPERTIES:
:STATUS: DRAFT
:END:
** 1. Purpose
Enable the agent to maintain focus and coherence over tasks spanning 100+ steps (SWE-bench parity).
** 2. User Needs
- *Hierarchical Planning:* Break large goals into a nested tree of Org headlines.
- *Context Compression:* Automatically summarize the results of child sub-trees into their parent nodes.
- *Branch Pruning:* Meta-cognitive review to stop execution of failed or redundant paths.
- *Self-Correction:* Adjust the plan dynamically based on environmental feedback.
** 3. Success Criteria
*** TODO Dynamic Task Tree Generation
*** TODO Context Compression Verification
*** TODO Branch Pruning Logic Effectiveness
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
** 1. Architectural Intent
Interfaces for plan generation and recursive summarization. Source of truth is the current plan subtree in the Object Store.
** 2. Semantic Interfaces
#+begin_src lisp
(defun plan-compress-node (node-id)
"Neural summarization of a completed sub-task tree.")
(defun plan-review-branches (root-id)
"Meta-cognitive audit of the current plan to prune dead ends.")
#+end_src
* Phase D: Build (Implementation)
** Context Compression
#+begin_src lisp :tangle projects/org-skill-long-horizon/src/planning-logic.lisp
(defun plan-compress-node (node-id)
"Summarizes a completed task and its children into a single string to save context."
(let* ((obj (org-agent:lookup-object node-id))
(children (org-agent:org-object-children obj))
(content (org-agent:org-object-content obj))
(child-summaries (loop for cid in children
collect (org-agent:org-object-content (org-agent:lookup-object cid)))))
(org-agent:ask-neuro
(format nil "Summarize this completed sub-task and its outcomes: ~a~%Sub-tasks: ~{~a~%~}" content child-summaries)
:system-prompt "You are a Meta-Cognitive Pruning Engine. Summarize outcomes to preserve high-signal context.")))
#+end_src
** Neuro-Cognitive Audit
#+begin_src lisp :tangle projects/org-skill-long-horizon/src/planning-logic.lisp
(defun neuro-skill-long-horizon (context)
"Triggered when a major milestone is reached.
Performs a 'Review' of the entire plan tree."
(let* ((payload (getf context :payload))
(root-id (getf payload :plan-root-id))
(plan-tree (org-agent:lookup-object root-id)))
(format nil "
I am performing a Meta-Cognitive Audit of the current plan.
ROOT: ~a
STATUS: ~a
TASK:
1. Identify nodes that are 'BLOCKED' or 'FAILED'.
2. Decide if these branches should be RETRIED, PRUNED, or if the PLAN needs RESTRUCTURING.
3. Return a revised plan structure in Lisp format.
" (getf (org-agent:org-object-attributes plan-tree) :TITLE)
(getf (org-agent:org-object-attributes plan-tree) :TODO-STATE))))
#+end_src
* Registration
#+begin_src lisp
(defskill :skill-long-horizon
:priority 95
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :milestone))
:neuro #'neuro-skill-long-horizon
:symbolic (lambda (action context) action))
#+end_src