feat(agent): Skill Compilation + Adaptive Routing (v2/P4)
Episode → maybe_learn → llm_free skills, plus abstract router backends (marqdo/small-llm/jev?/llm/auto) via plugins/agent; no core host changes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8489d90926
commit
a9ee858f53
14 files changed
+5785
-7
No files matched your search
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: Agent Framework P4 — Adaptive Routing + Policy Compilation (offline)
|
||||
description: Learn skill, compile policy from skill-tagged episodes, route via marqdo backend without Jev/LLM.
|
||||
import json:lib/json.mq.md
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**p = > plugin.native_path name="agent"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=no-agent-plugin
|
||||
> sys.exit code=1
|
||||
|
||||
**paths = > json.parse text={"mem":".marqdo/agent-memory-p4-test","kb":".marqdo/agent-kb-p4-test","task":"Reply with exactly the word pong and nothing else.","skill":"concepts/skills/reply-with-exactly-the-word-pong-and-nothing-els.md"}**
|
||||
**mem = > json.get value=`paths` key="mem"**
|
||||
**kb = > json.get value=`paths` key="kb"**
|
||||
**task = > json.get value=`paths` key="task"**
|
||||
**skill = > json.get value=`paths` key="skill"**
|
||||
|
||||
> agent_memory_ensure memory_dir=`mem`
|
||||
|
||||
**ep1 = > agent_record_episode task=`task` status="ok" result="pong" mode="explore" skill=`skill` llm_calls=2 memory_dir=`mem`**
|
||||
**ep2 = > agent_record_episode task=`task` status="ok" result="pong" mode="explore" skill=`skill` llm_calls=2 memory_dir=`mem`**
|
||||
**ep3 = > agent_record_episode task=`task` status="ok" result="pong" mode="explore" skill=`skill` llm_calls=2 memory_dir=`mem`**
|
||||
|
||||
**learned = > agent_maybe_learn task=`task` memory_dir=`mem` kb_dir=`kb` improve_every=3 promote=True**
|
||||
**did = > json.get value=`learned` key="learned"**
|
||||
1. `did`
|
||||
> print text=skill-learned
|
||||
2. *
|
||||
> print text=skill-skip
|
||||
|
||||
**ep4 = > agent_record_episode task=`task` status="ok" result="pong" mode="compiled" skill=`skill` llm_calls=0 memory_dir=`mem`**
|
||||
**ep5 = > agent_record_episode task=`task` status="ok" result="pong" mode="compiled" skill=`skill` llm_calls=0 memory_dir=`mem`**
|
||||
**ep6 = > agent_record_episode task=`task` status="ok" result="pong" mode="compiled" skill=`skill` llm_calls=0 memory_dir=`mem`**
|
||||
|
||||
**pol = > agent_compile_policy memory_dir=`mem` min_evidence=3**
|
||||
**pok = > json.get value=`pol` key="ok"**
|
||||
1. `pok`
|
||||
> print text=policy-ok
|
||||
2. *
|
||||
> print text=policy-fail
|
||||
|
||||
**routed = > agent_route task=`task` backend="auto" memory_dir=`mem` kb_dir=`kb`**
|
||||
**matched = > json.get value=`routed` key="matched"**
|
||||
**needs = > json.get value=`routed` key="needs_llm"**
|
||||
1. `matched`
|
||||
1. not `needs`
|
||||
> print text=route-hit
|
||||
2. *
|
||||
> print text=route-needs-llm
|
||||
2. *
|
||||
> print text=route-miss
|
||||
|
||||
**backend = > json.get value=`routed` key="backend"**
|
||||
> print text=`backend`
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: Agent Framework v2 — episode → learn → compile (offline)
|
||||
description: Record three identical successes, maybe_learn compiles llm_free skill, resolve hits compiled path.
|
||||
import agent:ext/ai/agent.mq.md
|
||||
import fs:lib/fs.mq.md
|
||||
import json:lib/json.mq.md
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
**p = > plugin.native_path name="agent"**
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=no-agent-plugin
|
||||
> sys.exit code=1
|
||||
|
||||
**paths = > json.parse text={"mem":".marqdo/agent-memory-v2-test","kb":".marqdo/agent-kb-v2-test","task":"Reply with exactly the word pong and nothing else."}**
|
||||
**mem = > json.get value=`paths` key="mem"**
|
||||
**kb = > json.get value=`paths` key="kb"**
|
||||
**task = > json.get value=`paths` key="task"**
|
||||
|
||||
> agent_memory_ensure memory_dir=`mem`
|
||||
|
||||
**ep1 = > agent_record_episode task=`task` status="ok" result="pong" mode="explore" llm_calls=2 memory_dir=`mem`**
|
||||
**ep2 = > agent_record_episode task=`task` status="ok" result="pong" mode="explore" llm_calls=2 memory_dir=`mem`**
|
||||
**ep3 = > agent_record_episode task=`task` status="ok" result="pong" mode="explore" llm_calls=2 memory_dir=`mem`**
|
||||
**ok = > json.get value=`ep3` key="ok"**
|
||||
1. `ok`
|
||||
> print text=ep-ok
|
||||
2. *
|
||||
> print text=ep-fail
|
||||
|
||||
**listed = > agent_list_episodes memory_dir=`mem` task=`task`**
|
||||
**n = > json.get value=`listed` key="count"**
|
||||
> print text=`n`
|
||||
|
||||
**learned = > agent_maybe_learn task=`task` memory_dir=`mem` kb_dir=`kb` improve_every=3 promote=True**
|
||||
**did = > json.get value=`learned` key="learned"**
|
||||
1. `did`
|
||||
> print text=learned
|
||||
2. *
|
||||
> print text=learn-skip
|
||||
|
||||
**resolved = > agent_resolve task=`task` kb_dir=`kb`**
|
||||
**lf = > json.get value=`resolved` key="llm_free"**
|
||||
1. `lf`
|
||||
> print text=llm-free
|
||||
2. *
|
||||
> print text=not-free
|
||||
|
||||
**m = > agent_metrics memory_dir=`mem`**
|
||||
**eps = > json.get value=`m` key="episodes"**
|
||||
> print text=`eps`
|
||||
Reference in new issue
Block a user