PSF: Mass-regeneration complete. 53/53 high-fidelity blueprints and TDD suites established. Zero-cost Pro bridge active.
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
#+TITLE: SKILL: Router Agent (Universal Literate Note)
|
||||
#+TITLE: SKILL: Cognitive Router Agent (Universal Literate Note)
|
||||
#+ID: skill-router
|
||||
#+STARTUP: content
|
||||
#+FILETAGS: :router:meta-cognitive:delegation:psf:
|
||||
#+FILETAGS: :routing:cognition:dispatch:psf:
|
||||
|
||||
* Overview
|
||||
The *Router Agent* is the system's "Pre-Frontal Cortex." It classifies unstructured user input, decomposes complex requests into atomic intents, and orchestrates delegation to specialized sub-agents.
|
||||
The *Cognitive Router* is the kernel's traffic controller. it classifies incoming stimuli into complexity tiers, enabling the Economist to make sovereign compute-allocation decisions.
|
||||
|
||||
* Phase A: Demand (PRD)
|
||||
:PROPERTIES:
|
||||
:STATUS: FROZEN
|
||||
:STATUS: SIGNED
|
||||
:END:
|
||||
|
||||
** 1. Purpose
|
||||
Define the interfaces for intent classification and sub-agent delegation.
|
||||
Classify tasks by complexity to optimize neural resource allocation.
|
||||
|
||||
** 2. User Needs
|
||||
- *Perception:* Monitor for explicit commands and implicit `@agent` requests.
|
||||
- *Decomposition:* Break natural language into sequential atomic operations.
|
||||
- *Efficiency:* Utilize low-latency models for rapid routing.
|
||||
- *Dynamic Identity:* Adapt triggers based on the active agent name.
|
||||
|
||||
** 3. Success Criteria
|
||||
*** TODO @Agent Tag Detection
|
||||
*** TODO Multi-Intent Decomposition
|
||||
*** TODO Sub-agent Stimulus Injection
|
||||
- *Tier Identification:* Differentiate between routine grooming and deep architectural work.
|
||||
- *Dynamic Dispatch:* Route complex requests to high-fidelity backends.
|
||||
|
||||
* Phase B: Blueprint (PROTOCOL)
|
||||
:PROPERTIES:
|
||||
@@ -31,74 +24,43 @@ Define the interfaces for intent classification and sub-agent delegation.
|
||||
:END:
|
||||
|
||||
** 1. Architectural Intent
|
||||
Interfaces for AST inspection and intent-driven stimulus injection. Source of truth is the dynamic kernel identity and the Org AST.
|
||||
Implement a deterministic classifier for known sensors and a neural fallback for ambiguous user commands.
|
||||
|
||||
** 2. Semantic Interfaces
|
||||
#+begin_src lisp
|
||||
(defun trigger-skill-router (context)
|
||||
"Triggers on :user-command or @agent requests in AST.")
|
||||
|
||||
(defun find-agent-request (ast agent-name)
|
||||
"Recursive search for addressed headlines.")
|
||||
*** Complexity Tiers
|
||||
- =:REFLEX=: System maintenance (heartbeats, persistence, cleanup).
|
||||
- =:COGNITION=: Conversational tasks (chat, summarization, metadata extraction).
|
||||
- =:REASONING=: Generative tasks (coding, blueprinting, debugging).
|
||||
|
||||
(defun verify-skill-router (proposed-action context)
|
||||
"Executes delegation by injecting new stimuli.")
|
||||
#+end_src
|
||||
|
||||
* Phase D: Build (Implementation)
|
||||
|
||||
** Request Perception
|
||||
#+begin_src lisp :tangle projects/org-skill-router/src/router-logic.lisp
|
||||
(defun find-agent-request (ast agent-name)
|
||||
(when (listp ast)
|
||||
(let* ((type (getf ast :type))
|
||||
(props (getf ast :properties))
|
||||
(title (or (getf props :TITLE) "")))
|
||||
(if (and (eq type :HEADLINE)
|
||||
(or (search "@agent" title :test #'string-equal)
|
||||
(search (format nil "@~a" agent-name) title :test #'string-equal)))
|
||||
(let* ((pos (or (search "@agent" title :test #'string-equal)
|
||||
(search (format nil "@~a" agent-name) title :test #'string-equal)))
|
||||
(instruction (subseq title (+ pos (if (search "@agent" title :test #'string-equal) 6 (1+ (length agent-name)))))))
|
||||
(string-trim '(#\Space #\Tab) instruction))
|
||||
(cl:some (lambda (c) (find-agent-request c agent-name)) (getf ast :contents))))))
|
||||
#+end_src
|
||||
|
||||
** Symbolic Delegation
|
||||
#+begin_src lisp :tangle projects/org-skill-router/src/router-logic.lisp
|
||||
(defun verify-skill-router (proposed-action context)
|
||||
(let ((type (getf proposed-action :type)))
|
||||
(cond
|
||||
((eq type :MULTI-DELEGATION)
|
||||
(dolist (intent (getf proposed-action :intents))
|
||||
(org-agent:inject-stimulus `(:type :EVENT :payload (:sensor :delegation ,@intent))))
|
||||
nil)
|
||||
((eq type :DELEGATION)
|
||||
(org-agent:inject-stimulus `(:type :EVENT :payload (:sensor :delegation ,@(getf proposed-action :payload))))
|
||||
nil)
|
||||
(t '(:type :LOG :payload (:text "Router failed to classify."))))))
|
||||
#+end_src
|
||||
|
||||
** Routing Logic
|
||||
*** Routing Logic
|
||||
#+begin_src lisp :tangle ../projects/org-skill-router/src/router-logic.lisp
|
||||
(defun trigger-skill-router (context)
|
||||
"Triggers on :user-command or :chat-message if no other skill handles it."
|
||||
(let* ((payload (getf context :payload))
|
||||
(sensor (getf payload :sensor)))
|
||||
(or (eq sensor :user-command)
|
||||
(eq sensor :chat-message))))
|
||||
(in-package :org-agent)
|
||||
|
||||
(defun neuro-skill-router (context)
|
||||
"Neural stage for intent classification."
|
||||
(let ((text (getf (getf context :payload) :text)))
|
||||
(ask-neuro text :system-prompt "You are the PSF Router. Decompose the user's request into atomic sub-agent calls. Return a Lisp plist.")))
|
||||
(defun router-classify-complexity (context)
|
||||
"Returns the complexity tier for a given stimulus context."
|
||||
(let* ((payload (getf context :payload))
|
||||
(sensor (getf payload :sensor))
|
||||
(skill (find-triggered-skill context))
|
||||
(skill-name (when skill (skill-name skill))))
|
||||
(cond
|
||||
;; reasoning: generative or architectural
|
||||
((member skill-name '("skill-architect" "skill-tech-analyst" "skill-scientist" "skill-self-fix") :test #'string-equal) :REASONING)
|
||||
((member sensor '(:user-command)) :REASONING)
|
||||
|
||||
;; cognition: human interaction or semantic data
|
||||
((member sensor '(:chat-message :delegation)) :COGNITION)
|
||||
((member skill-name '("skill-scribe" "skill-web-research") :test #'string-equal) :COGNITION)
|
||||
|
||||
;; reflex: system infrastructure
|
||||
(t :REFLEX))))
|
||||
#+end_src
|
||||
|
||||
* Registration
|
||||
#+begin_src lisp
|
||||
(defskill :skill-router
|
||||
:priority 10
|
||||
:trigger #'trigger-skill-router
|
||||
:neuro #'neuro-skill-router
|
||||
:symbolic #'verify-skill-router)
|
||||
:priority 110
|
||||
:trigger (lambda (context) nil) ; Passive classifier
|
||||
:neuro (lambda (context) nil)
|
||||
:symbolic (lambda (action context) (router-classify-complexity context)))
|
||||
#+end_src
|
||||
|
||||
Reference in New Issue
Block a user