OpenProgram Docs

自编程 AI Agent

  1. Agent 用普通文件工具在 ~/.openprogram/programs/<name>/ 写一个 Workflow 包。
  2. openprogram programs check 测试、提交并记录为已检查。
  3. worker 无需重启即可加载;之后的回合从与现有工具相同的注册表调用其入口。

写入包目录不会被拒绝;能否运行取决于检查。编辑或普通的 git commit 在检查通过前都不会生效。

Agent 写什么

from openprogram import Agent, Context

reviewer = Agent(instructions="You find concrete defects.", tools=[])
editor = Agent(instructions="You revise drafts.", tools=[])


def review_then_revise(draft: str) -> str:
    """Review a draft, then revise it against the review."""
    ctx = Context({"draft": draft})
    review = reviewer("Identify concrete defects in this draft", context=ctx)
    return editor("Revise the draft using the review",
                  context=ctx.derive({"review": review}))


PROGRAM_ENTRIES = [review_then_revise]

Python 固定顺序;两个角色完成语义步骤,各自只看到自己 Context 里的内容块。

让它写一个

curl -fsSL https://fzkuji.github.io/OpenProgram/install | sh
openprogram
Create a Workflow named review_then_revise. It must review a draft, revise it
against the review, return only the final text, and include a behavior test.

仍然生效的控制

控制位置
工具权限每个角色的 tools 和配置的审批策略
记录每次角色调用及其确切请求,记入会话图
资源限制、取消、结构化输出校验、Provider 计费运行时
源码普通文件,有自己的 Git 历史:可检查、可测试、可回退。只加载通过检查的提交,从解出的副本运行,之后的编辑影响不到它。导入失败时之前的版本继续运行,Program 显示 error,备注写明两个版本。

何时使用

任务使用
重复出现,需要可复用、可检查的流程,语义步骤需要模型判断自编程
完全确定性普通函数
已有稳定实现现有工具

编写并检查 Workflow · Agentic Programming 指南 · Agent 参考 · 设计理念

Last updated · 2026-11-25