:PROPERTIES: :ID: a44d29c6-a686-451e-b4e6-b060c3aa7524 :CREATED: [2026-03-30 Mon 21:16] :EDITED: [2026-04-07 Tue 13:42] :END: #+TITLE: SKILL: Anthropic Provider Agent (Universal Literate Note) #+STARTUP: content #+FILETAGS: :llm:provider:anthropic:claude:psf: * Overview The *Anthropic Provider Agent* integrates Anthropic's Claude family of models as a pluggable System 1 (neural) backend. It enables high-intelligence reasoning, drafting, and analysis within the PSF. * Phase A: Demand (PRD) :PROPERTIES: :STATUS: FROZEN :END: ** 1. Purpose Define the interface for reliable communication with the Anthropic Messages API. ** 2. User Needs - *Connectivity:* Reliable I/O with Claude models. - *Configurability:* Model selection via Environment Configuration. - *Context Management:* Leverage Claude's large context windows. - *Safety:* Graceful error handling for API failures or missing keys. ** 3. Success Criteria *** TODO API Authentication *** TODO Model Resolution Loop *** TODO Response Parsing Verification * Phase B: Blueprint (PROTOCOL) :PROPERTIES: :STATUS: SIGNED :END: ** 2. Semantic Interfaces *** `execute-anthropic-request` :signature `(execute-anthropic-request prompt system-prompt &key model) :string` :description "Direct call to the Anthropic Messages API." * Phase D: Build (Implementation) #+begin_src lisp :tangle ../projects/org-skill-provider-anthropic/src/provider-logic.lisp (in-package :org-agent) (defun execute-anthropic-request (prompt system-prompt &key model) (let ((api-key (uiop:getenv "ANTHROPIC_API_KEY")) (endpoint "https://api.anthropic.com/v1/messages") (model-id (or model "claude-3-5-sonnet-20240620"))) (unless api-key (return-from execute-anthropic-request "(:type :LOG :payload (:text \"Anthropic API Key missing\"))")) (let* ((headers `(("Content-Type" . "application/json") ("x-api-key" . ,api-key) ("anthropic-version" . "2023-06-01"))) (body (cl-json:encode-json-to-string `((model . ,model-id) (max_tokens . 4096) (system . ,system-prompt) (messages . (( (role . "user") (content . ,prompt) ))))))) (handler-case (let* ((response (dex:post endpoint :headers headers :content body :connect-timeout 10 :read-timeout 30)) (json (cl-json:decode-json-from-string response))) ;; Anthropic response structure: content[0].text (cdr (assoc :text (car (cdr (assoc :content json)))))) (error (c) (format nil "(:type :LOG :payload (:text \"Anthropic Failure: ~a\"))" c)))))) #+end_src * Registration #+begin_src lisp (progn (org-agent:register-neuro-backend :anthropic #'execute-anthropic-request) (defskill :skill-provider-anthropic :priority 110 :trigger (lambda (context) nil) :neuro (lambda (context) nil) :symbolic (lambda (action context) action))) #+end_src