81 lines
3.2 KiB
Org Mode
81 lines
3.2 KiB
Org Mode
#+TITLE: SKILL: The Economist Agent (Universal Literate Note)
|
|
#+ID: skill-economist
|
|
#+STARTUP: content
|
|
#+FILETAGS: :economics:optimization:budget:psf:
|
|
#+DEPENDS_ON: skill-router skill-performance-auditor
|
|
|
|
* Overview
|
|
The *Economist Agent* manages the PSF's compute resources. It predicts the "Cost of Thought" for a task and autonomously selects the most cost-effective LLM provider or local model based on complexity and remaining budget.
|
|
|
|
* Phase A: Demand (PRD)
|
|
:PROPERTIES:
|
|
:STATUS: SIGNED
|
|
:END:
|
|
|
|
** 1. Purpose
|
|
Optimize token usage and compute overhead without sacrificing architectural integrity.
|
|
|
|
** 2. User Needs
|
|
- *Predictive Budgeting:* Estimate token cost before triggering SOTA models.
|
|
- *Provider Switching:* Dynamically route tasks between local (Ollama) and cloud (Gemini) models.
|
|
- *Audit Reports:* Provide transparency on compute consumption.
|
|
|
|
* Phase B: Blueprint (PROTOCOL)
|
|
:PROPERTIES:
|
|
:STATUS: SIGNED
|
|
:END:
|
|
|
|
** 1. Architectural Intent
|
|
The *Economist Agent* provides cost-governance for the Neural Engine. It intercepts `think` requests and determines the optimal Model/Provider based on task complexity, priority, and current budget constraints.
|
|
|
|
** 2. Semantic Interfaces
|
|
|
|
*** Routing Logic (2026 Fleet)
|
|
#+begin_src lisp :tangle ../projects/org-skill-economist/src/economist-logic.lisp
|
|
(in-package :org-agent)
|
|
|
|
(defun economist-route-task (context)
|
|
"Analyzes the stimulus context and returns a prioritized list of providers.
|
|
High-priority or complex tasks (e.g., :architect) get powerful models.
|
|
Routine tasks (e.g., :heartbeat, :persistence) get cheap/flash models."
|
|
(let* ((payload (getf context :payload))
|
|
(sensor (getf payload :sensor))
|
|
(complexity (ignore-errors (uiop:symbol-call :org-agent.skills.org-skill-router :router-classify-complexity context))))
|
|
(cond
|
|
;; Explicit user interaction or Reasoning tasks
|
|
((or (member sensor '(:user-command)) (eq complexity :REASONING)) '(:openrouter))
|
|
|
|
;; Cognitive or Reflexive tasks
|
|
(t '(:openrouter))))) ; Route through OpenRouter to avoid direct Google 429s
|
|
|
|
(defun economist-get-model-for-provider (provider &optional context)
|
|
"Returns the specific model ID recommended for the given provider/complexity.
|
|
Updated for April 2026 SOTA. Prefers Gemini 3.0/2.5 Flash for reflexes."
|
|
(let ((complexity (ignore-errors (uiop:symbol-call :org-agent.skills.org-skill-router :router-classify-complexity context))))
|
|
(case provider
|
|
(:openrouter
|
|
(case complexity
|
|
(:REASONING "anthropic/claude-3.5-sonnet")
|
|
(:COGNITION "moonshotai/kimi-k2.5")
|
|
(t "google/gemini-3-flash-preview")))
|
|
(t nil))))
|
|
#+end_src
|
|
|
|
* Phase D: Build (Implementation)
|
|
|
|
** Integration with Kernel
|
|
#+begin_src lisp :tangle ../projects/org-skill-economist/src/economist-logic.lisp
|
|
(defun economist-patch-kernel ()
|
|
"Hot-patches the kernel's *provider-cascade* to use economist logic."
|
|
(setf org-agent:*provider-cascade* #'economist-route-task))
|
|
#+end_src
|
|
|
|
* Registration
|
|
#+begin_src lisp
|
|
(defskill :skill-economist
|
|
:priority 100 ; High priority to ensure cost-checks happen first
|
|
:trigger (lambda (context) (eq (getf (getf context :payload) :sensor) :cost-audit))
|
|
:neuro (lambda (context) nil)
|
|
:symbolic (lambda (action context) (economist-route-task context)))
|
|
#+end_src
|