feat(agent): Wave B0 constitution demos + harness
Lock code-as-doc / call_site / OKF as first-class: reorder step context, ship agent-pong and okf-flywheel examples, offline harness, and skill/docs refresh. Dev LLM template via .env.example only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ff1b846b73
commit
d1b4e62d4d
18 files changed
+428
-29
No files matched your search
@@ -0,0 +1,13 @@
|
||||
# agent-okf-flywheel(Wave B0)
|
||||
|
||||
演示 **文档即知识库(OKF)**:固化工作簿 promote 后,相同 goal 的 `plan` 走 `cache=hit`(`llm_free` 路径),无需再问模型。
|
||||
|
||||
```bash
|
||||
cargo build --release -p marqdo -p marqdo_plugin_agent
|
||||
export MARQDO_EXT="$PWD/.marqdo-ext"
|
||||
./target/release/marqdo run examples/agent-okf-flywheel/index.mq.md
|
||||
```
|
||||
|
||||
期望:`promoted` · `hit` · `flywheel-ok`。
|
||||
|
||||
见 [okf.md](../../doc/design/okf.md) · [agent-framework-2026-09.md](../../doc/research/agent-framework-2026-09.md)。
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: agent-okf-flywheel (Wave B0)
|
||||
description: Promote solidified workbook; second plan is cache=hit — document as knowledge base (OKF).
|
||||
import llm:ext/ai/llm.mq.md
|
||||
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
|
||||
|
||||
OKF flywheel offline: promote → plan same goal → `cache=hit` (no live LLM required for the hit path).
|
||||
|
||||
*p = > plugin.native_path name="agent"*
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=no-agent-plugin
|
||||
> sys.exit code=1
|
||||
|
||||
> sys.env_set name="OPENAI_API_KEY" value="offline-okf-dummy"
|
||||
*model = > llm.llm*
|
||||
*tools = > json.parse text=[]*
|
||||
*助手 = > agent.agent model=`model` tools=`tools` standing="offline okf flywheel"*
|
||||
|
||||
*kb = ".marqdo/agent-kb-example-flywheel"*
|
||||
*wb = ".marqdo/agent-runs/example-pong-solid.mq.md"*
|
||||
*goal = "Reply with exactly the word pong and nothing else."*
|
||||
*body = "---\ntitle: okf pong\n---\n\n# main\n\n*msg = \"pong\"*\n\n**msg**\n"*
|
||||
|
||||
1. > fs.exists path=`kb`
|
||||
> fs.remove path=`kb`
|
||||
2. *
|
||||
---
|
||||
|
||||
> fs.write_text path=`wb` text=`body`
|
||||
|
||||
*prom = > agent_kb_promote kb_dir=`kb` goal=`goal` workbook=`wb`*
|
||||
*okp = > json.get value=`prom` key="promoted"*
|
||||
1. `okp`
|
||||
> print text=promoted
|
||||
2. *
|
||||
> print text=promote-fail
|
||||
> sys.exit code=1
|
||||
|
||||
*out = > `助手`.plan goal=`goal` max_rounds=2 writeback=False kb_dir=`kb` explore_n=0 promote=False*
|
||||
*cache = > json.get value=`out` key="cache"*
|
||||
> print text=`cache`
|
||||
*match = > json.get value=`out` key="match"*
|
||||
> print text=`match`
|
||||
*val = > json.get value=`out` key="result"*
|
||||
> print text=`val`
|
||||
|
||||
1. `cache` == "hit"
|
||||
> print text=flywheel-ok
|
||||
2. *
|
||||
> print text=flywheel-miss
|
||||
> sys.exit code=1
|
||||
@@ -0,0 +1,16 @@
|
||||
# agent-pong(Wave B0)
|
||||
|
||||
演示 Marqdo 智能体宪法:**代码即文档** — 模型上下文含 **call site** 与本文件 **source**;工具是同文件里的 `## 获取时间`。
|
||||
|
||||
```bash
|
||||
# 仓库根目录
|
||||
cargo build --release -p marqdo -p marqdo_plugin_agent
|
||||
export MARQDO_EXT="$PWD/.marqdo-ext" # 或: marqdo ext add agent
|
||||
# 可选 live:仓库根 `.env` + `AGENT_LIVE=1 marqdo run examples/agent-pong/index.mq.md`
|
||||
./target/release/marqdo run examples/agent-pong/index.mq.md
|
||||
```
|
||||
|
||||
期望离线输出含:`call-site-ok` · `source-ok` · `tool-in-source-ok`。
|
||||
配置真实 `.env` 时还会跑一次 `step`(CALL 工具)。
|
||||
|
||||
见 [agent-framework-2026-09.md](../../doc/research/agent-framework-2026-09.md)。
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
title: agent-pong (Wave B0)
|
||||
description: >-
|
||||
Constitution demo — call_site + source in step context; optional live CALL via .env.
|
||||
Code is documentation; tools are ## in this same file.
|
||||
import llm:ext/ai/llm.mq.md
|
||||
import agent:ext/ai/agent.mq.md
|
||||
import json:lib/json.mq.md
|
||||
import plugin:lib/plugin.mq.md
|
||||
import sys:lib/sys.mq.md
|
||||
import time:lib/time.mq.md
|
||||
---
|
||||
|
||||
## 获取时间
|
||||
|
||||
Return today's date string (tool visible in source to the model).
|
||||
|
||||
*u = > time.now_unix*
|
||||
**> time.format unix=`u` pattern="%Y-%m-%d"**
|
||||
|
||||
# main
|
||||
|
||||
*p = > plugin.native_path name="agent"*
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=no-agent-plugin
|
||||
> sys.exit code=1
|
||||
|
||||
> llm.load_env path="../../.env"
|
||||
|
||||
`工具表` =
|
||||
|
||||
| 工具 |
|
||||
|------|
|
||||
| 获取时间 |
|
||||
|
||||
*model = > llm.llm*
|
||||
*助手 = > agent.agent model=`model` tools=`工具表` standing="You are a Marqdo agent. Prefer CALL:获取时间 when the task needs today's date."*
|
||||
|
||||
Assert constitution markers in the assembled prompt (call site before how-to-act):
|
||||
|
||||
*ctx = > agent.build_step_context agent=`助手` task="What is today's date? Use the tool in this runbook."*
|
||||
|
||||
*parts = > split value=`ctx` sep="--- call site ---"*
|
||||
*n = > len value=`parts`*
|
||||
1. `n` > 1
|
||||
> print text=call-site-ok
|
||||
2. *
|
||||
> print text=call-site-missing
|
||||
> sys.exit code=1
|
||||
|
||||
*parts2 = > split value=`ctx` sep="--- source (.mq.md) ---"*
|
||||
*n2 = > len value=`parts2`*
|
||||
1. `n2` > 1
|
||||
> print text=source-ok
|
||||
2. *
|
||||
> print text=source-missing
|
||||
> sys.exit code=1
|
||||
|
||||
*parts3 = > split value=`ctx` sep="获取时间"*
|
||||
*n3 = > len value=`parts3`*
|
||||
1. `n3` > 1
|
||||
> print text=tool-in-source-ok
|
||||
2. *
|
||||
> print text=tool-in-source-missing
|
||||
> sys.exit code=1
|
||||
|
||||
*site = > agent_call_site*
|
||||
*fn = > json.get value=`site` key="function"*
|
||||
> print text=`fn`
|
||||
|
||||
Optional live step — set env AGENT_LIVE=1 and put keys in repo-root `.env`:
|
||||
|
||||
*live = > sys.env_get name="AGENT_LIVE"*
|
||||
*key = > sys.env_get name="OPENAI_API_KEY"*
|
||||
1. `live` == "1"
|
||||
1. `key`
|
||||
*out = > `助手`.step task="请调用获取时间工具,然后只回复日期字符串。" writeback=False*
|
||||
*status = > json.get value=`out` key="status"*
|
||||
> print text=`status`
|
||||
*tool = > json.get value=`out` key="tool"*
|
||||
> print text=`tool`
|
||||
*result = > json.get value=`out` key="result"*
|
||||
> print text=`result`
|
||||
2. *
|
||||
> print text=live-skipped-no-key
|
||||
2. *
|
||||
> print text=live-skipped
|
||||
Reference in new issue
Block a user