Show HN: Autonomy – Self-Harness/Self-Directed AI Agent Core Under Development

agentic_vector1 pts0 comments

Autonomy — 自律型 AI 代理人系統 | Bill Liu

AgentLoop · ConversationLoop<br>Python 3.13 · 自律執行中

Autonomy

自律型 AI

代理人框架

以 Beam Search 候選排序 、受管行動閘道 與程序技能學習 為核心,

打造真正能自主感知、規劃、執行並持續進化的 AI 代理人系統。

探索核心模組

查看原始碼

內建 Procedure Skills

+ 內建工具

支援 AI Provider

Beam Width

設計理念

AgentLoop:自導向任務迴圈

每個執行回合(Turn)依固定五步驟推進,直到目標達成、被封鎖或超過步數上限

AgentLoop 是 Autonomy 的核心驅動器——一個「自導向任務迴圈」,不需要人工介入即可從目標出發,自主選擇工具、執行行動並從結果中學習。

每個 Turn 的執行流程:①從技能庫選取相關 ProcedureSkill,②由 LLM 提案 + RecipeEngine 產出候選動作路徑,③以 5 維評分排序(Beam<br>Width=3),④透過 ActionGateway 受管執行,⑤評估結果並觸發學習。

終止條件明確:ACHIEVED(目標完成)、BLOCKED(無法繼續)、NO_CANDIDATES、APPROVAL_DENIED、MAX_STEPS_REACHED、或<br>FAILED——系統永遠不會陷入無限循環。

AgentLoop<br>ActionGateway<br>CandidateSelector<br>LearningLoop<br>CuratorDaemon

📚

disclose_procedure_skills()<br>選取相關技能

💡

generate_candidates()<br>LLM 提案 + Recipe Engine

📊

rank_candidates()<br>5 維評分 · Beam Width=3

ActionGateway.execute_next()<br>ApprovalPolicy 授權 · 受管執行

🧠

evaluate_outcome() + learn()<br>結果評估 · Recipe 學習

核心模組

十二大技術特點

每個特點都直接對應 Autonomy 原始碼中的具體實作

🔄

自導向代理人迴圈

AgentLoop.run(goal, max_steps=12)<br>啟動後完全自主執行,每步驟透過 run_turn() 推進。支援互動模式(interactive=True)與批次模式,所有事件均以<br>run_id 記錄於 AutonomyStore。

AgentLoop

RunState

TerminationReason

🛡️

受管行動閘道

所有工具呼叫必須通過 ActionGateway 的<br>ApprovalPolicy 授權。每個動作帶有 RiskLevel(LOW / MEDIUM /<br>HIGH)、expected_effect 與 verification_plan,確保執行可控、可審計。

ActionGateway

ApprovalPolicy

RiskLevel

📊

5 維 Beam Search 評分

CandidateSelector 以<br>evidence_strength(+0.30)、purpose(+0.10)、risk(−0.35)、side_effects(−0.20)、penalty(−1.0)五個維度計算總分,選出前<br>beam_width=3 名候選路徑送往執行。

CandidateSelector

CandidatePath

beam_width=3

🎯

混合結果評估

DeterministicOutcomeEvaluator 優先判斷執行失敗(直接<br>BLOCKED),成功但結果不確定時再交由 ModelAssistedOutcomeEvaluator 呼叫 LLM 語義判斷——最小化昂貴的模型呼叫次數。

DeterministicEvaluator

ModelAssistedEvaluator

GoalStatus

📚

程序技能庫(13 內建)

ProcedureSkillLibrary 內建 13 個 bundled<br>skills,涵蓋<br>api-debugging、browser-navigation、code-editing、codebase-documentation、plan、procedure-skill-authoring、process-management、requesting-code-review、systematic-debugging、technical-spike、TDD、website-inspection、writing-plans,每步動態選取最相關技能載入。

ProcedureSkillLibrary

ProcedureSkill

requires_tools

🧠

後執行學習迴路

每次 Run 結束後,LearningLoop.review_run()<br>自動觸發:若結果為 ACHIEVED 且有 ≥2 個成功步驟,自動起草新 ProcedureSkillDraft(信心度 0.85),生成<br>LearningProposal 等待審核。

LearningLoop

LearningProposal

confidence=0.85

⚗️

Action Recipe 引擎

RecipeEngine 監控每個成功動作的 SHA-256<br>指紋——當同一動作成功次數 ≥ candidate_threshold=2,自動升格為候選<br>Recipe,下次直接作為行動選項(source=action_skill)提出,無需 LLM 重新推理。

RecipeEngine

ActionRecipe

action fingerprint

🗂️

技能策展守護程序

每次 Run 結束後,CuratorDaemon<br>在後台執行緒(daemon=True)非同步啟動 SkillCurator.apply_auto_merges(),自動偵測並合併重複(信心 0.95)或子集(信心<br>0.90)技能,防止技能庫膨脹。

CuratorDaemon

SkillCurator

async merge

🧰

可擴展工具集目錄

TOOLSET_CATALOG 涵蓋 4<br>個預設啟用工具集:file、terminal、search、skills,加上 opt-in 的 project(git / JSON / YAML / 測試探索)與 browser(Playwright<br>headless Chromium,11 工具)。規劃中:memory、delegate、cronjob、computer_use。

ToolsetCatalog

ToolRegistry

ApprovalPolicy

📡

完整事件溯源稽核

AutonomyStore 以 Event Sourcing<br>模式記錄整個執行生命週期:run_started → skills_selected → candidates_ranked → action_selected → approval_decision →<br>observation → outcome_evaluated → recipe_learned → learning_review → run_finished,完整可重播。

AutonomyStore

record_event()

Event Sourcing

🖥️

TUI 終端互動介面

autonomy tui 啟動豐富終端介面,提供 session<br>總覽面板、回合記錄、Action trail、compact/full 切換模式與 / 指令面板。自然語言直接流入 AgentLoop,UI 永遠不直接執行工具。

ConversationLoop

SessionShell

autonomy tui

🌐

多 Provider 支援

支援 ollama(本地)與 8 個 OpenAI-compatible<br>providers:openai-api、nvidia、openrouter、deepseek、xai、zai、kimi-coding、alibaba。提供 API 金鑰管理與 provider<br>設定,autonomy doctor 可檢查端點走通性。

ollama

openrouter

nvidia / deepseek / xAI

CandidateSelector

5 維候選評分系統

每個候選動作路徑依以下公式計算總分,選出前 3 名送往執行

score =

evidence_strength × +0.30<br>purpose × +0.10<br>risk × −0.35<br>side_effects × −0.20<br>penalty × −1.0

evidence_strength<br>+0.30

動作有充分依據與證據加分

purpose<br>+0.10

有明確目的說明加分

risk<br>−0.35

HIGH risk 扣最多,LOW 不扣分

side_effects<br>−0.20

有副作用的動作扣分

penalty<br>−1.0

已執行過或工具不可用,大量扣分

系統架構

真實模組關係圖

每個方塊對應 Autonomy 原始碼中的實際類別或模組

Entry · Interactive TUI / CLI run

🖥️<br>SessionShell → ConversationLoop<br>autonomy tui · 互動式對話

🎯<br>AgentLoop.run(goal)<br>autonomy run · max_steps · UUID run_id

Turn Loop · run_turn()

📚<br>ProcedureSkillLibrary<br>index() · load_selected()

⚗️<br>RecipeEngine<br>candidates_for() · learn()

📊<br>CandidateSelector<br>beam_width=3 · 5-dim score

Execution · ActionGateway

🛡️<br>ApprovalPolicy<br>authorize(action, interactive)

ActionGateway<br>execute_next() · risk assessment

🧰<br>ToolRegistry<br>execute(action) → Observation

Post-Run · finish_run()

🎯<br>OutcomeEvaluator<br>Deterministic + Model-assisted

🧠<br>LearningLoop<br>review_run() · draft skill

🗂️<br>CuratorDaemon<br>async thread · auto-merge

Persistence · AutonomyStore

📁 runs

📡 events

⚗️ recipes

📚 skills

💡 proposals

🗂️ curator_log

TOOLSET_CATALOG — 工具集 & AI Providers

fileread / write / patch / diff /<br>outline / symbol_search / syntax_check…

terminalshell.execute / process.start<br>/ poll / log / wait / stop

searchsearch.text...

autonomy agentloop actiongateway beam candidateselector approvalpolicy

Related Articles