Hacker News 熱門精选71

Show HN:AgentRun:将 agents 转化为工作流的 DSL

Show HN: AgentRun: DSL to turn agents into workflows

· 20天前
跳到正文

精选理由

帮助开发者将可重复的智能体任务编排为可检查、低成本的工作流。

AI 摘要

嗨,HN 用户们: 我刚刚开源了我们在 grep.ai 中使用的 harness 所采用的 DSL,它可以将 agents 工作中可重复的部分转化为工作流。你可以组合使用工具调用、代码、由 Jev 驱动的系统 1 决策(用于路由和证据筛选等任务),以及在某个步骤需要进一步调查时调用 agents。 我们的 harness 会利用 agents 执行任务时留下的 traces 和复盘笔记,找出其中哪些部分可以变成工作流。这样做的目的是让工作更容易理解,并避免在不需要完整 agent 循环的地方为其付费。 例如,一个研究工作流可以将问题拆分成多个子问题,派遣 agents 并行开展研究,使用 Jev 筛选证据,再让另一个 agent 撰写报告。你可以检查各个步骤,单独评估证据筛选过程,或者更换某个 agent,而无需重建整个流程。 DSL 和示例都在我们的 GitHub 中。你可以运行一个无需 API 密钥的脚本化演示: https://github.com/Parcha-ai/agentrun 你也可以将其作为 Pi 扩展,用于构建、检查和运行工作流: https://github.com/Parcha-ai/agentrun#use-it-in-pi 如果这对其他人也有用,我很希望听听大家的意见。 这段视频中介绍了 AgentRun 工作原理的更多背景: https://www.youtube.com/watch?v=vOVhtGjtwpg 。你也可以在这篇文章中了解我们的使用场景: https://x.com/MiguelriosEN/status/2101029313906987422 。 评论链接: https://news.ycombinator.com/item?id=49821438 得分:15 评论数:0

正文

agent.run()

Add Jev-powered workflows to your agents.

AgentRun is a workflow language for the agents you already run. Define repeatable steps, use Jev for focused decisions, and call an agent when the work needs investigation. Your application keeps its tools, model access, permissions, and budgets.

Quickstart · Documentation · Examples · Pi extension · Agent instructions

Support workflow: search for an answer, check it with Jev, and return it or ask an agent to investigate. Check the investigation before returning it or escalating for review.

View the static diagram · Run this example

The support example below follows this workflow with scripted tools and model responses.

Quickstart

Requires Node 22.19+ and npm. In your project:

npm install @parcha/agentrun-dsl@beta
npx agentrun demo

This ticket-routing demo uses scripted decisions and needs no API key. Next, run and change a workflow in your own app. To run the support workflow shown above, use the checkout below. To build workflows with your agent, install the Pi extension.

Run the support example

To run the workflow in the animation, clone the examples and build:

git clone --branch main --single-branch https://github.com/Parcha-ai/agentrun.git
cd agentrun
# With nvm: nvm install && nvm use
npm ci --ignore-scripts
npm run build
npm run demo:support

This runs the interpreter with scripted tools, Jev answers, and agent responses. It needs no API key and sends no customer replies.

The command prints a report for each case:

Request Agent calls Decision calls Result
Reset a password 0 1 Return the help answer
Find an invoice 0 1 Return the help answer
Investigate a failed payment 1 2 Return the investigation answer
Payment still unresolved 1 2 Escalate for review
npm run demo:support -- payment
npm run test:support

Try npm run demo:support -- unresolved to see an escalation. It exits with code 2. The responses are scripted; changing a prompt does not change them.

Connect live Jev and your agent, or give these instructions to your coding agent.

What a workflow looks like

The support workflow requires answer text and a source reference. Jev must also answer yes with confidence of at least 0.8. Otherwise, the workflow allows one agent attempt and checks again. If the answer still fails those checks, it escalates for review. You choose the criteria and thresholds for your task.

These are the search and decision nodes from that workflow:

{
  node: 'call', label: 'find-answer', via: 'tool',
  tool: 'help.search', args: { request: '{request}' },
  out: 'Candidate', as: 'answer', deadline_s: 10,
},
{
  node: 'judge', label: 'check-existing-answer',
  state: { request: '{request}', answer: '{answer}' },
  out: 'Fit', as: 'fit',
}

Candidate and Fit refer to schemas in the workflow. Fit defines the question and its yes, no, and uncertain criteria. Code reads the decision and its confidence to choose the next step. Read the complete definition, including the agent and review path.

Write workflows as JSON or use the TypeScript builder and Zod contracts. The builder infers input and output types. The interpreter checks intermediate state paths at runtime. Workflows can call other workflows, map work in parallel, and run bounded loops.

Connect your application

Install the core and Jev adapter in your application with npm install @parcha/agentrun-dsl@beta @parcha/agentrun-jev@beta. Then:

  1. Supply adapters. Connect tools through runEffect, your existing agent through runNode, and Jev decisions through createJevRunner() as runJudge.
  2. Define and test the workflow. Write its schemas, steps, thresholds, and review path. Start with fixtures, then evaluate real decisions on labeled cases from your task.
  3. Give your agent a workflow tool. Register a function that calls runWorkflow as one of your agent's tools. Handle the workflow's output, escalation, and errors.

The support integration guide has a config template and live command. Live Jev calls need TYPESAFE_API_KEY from the TypeSafe dashboard, separate from your coding-agent login. Workflows without Jev decisions do not need that key. See host integration for permissions, cancellation, and recovery.

Use it in Pi

With Pi 0.87.0 installed, run these commands in your project:

pi install npm:@parcha/agentrun-pi@0.1.0-beta.4 -l
pi --offline

-l installs in this project; --offline skips startup downloads. Pi asks whether you trust the project before loading its extension. No AgentRun checkout is needed.

  • /agentrun demo loads the scripted research example; /agentrun run repeats it without model calls.
  • /agentrun demo live uses your configured Pi model and Jev.
  • /agentrun status checks setup; /agentrun shows the graph; /agentrun stop requests cancellation.

Once Pi has model access, ask it to build a workflow:

/agentrun Research how this repository handles cancellation. Investigate the runtime and tests separately, then report gaps with file references.

Pi uses the packaged skill to build, inspect, and run the workflow. Run /reload if you install into an open Pi session. Use /agentrun save <name> and /agentrun load <name> for project-local definition revisions. Saves contain neither run input nor execution permission. Pi setup and limits.

More examples

Example What it demonstrates
Support answers Search, Jev checks, optional investigation, review fallback
Research a decision Nested workflows, parallel research, evidence selection, report writing
Standalone TypeScript starter Install the packages in your own app; search and screen evidence

Research demo

From the built checkout, run a scripted research workflow: "Should our team move its docs from a wiki into the code repository?"

npm run demo
npm run eval:research

It plans subquestions, researches them in parallel, screens evidence, and writes a report. The evaluation checks six labeled cases with scripted responses. Connect real Jev and Pi models.

Packages, status, and contributing

Package Responsibility
@parcha/agentrun-dsl Define, validate, inspect, and execute workflows
@parcha/agentrun-jev Connect Jev typed decisions
@parcha/agentrun-pi Pi extension and agent runner

This release is 0.1.0-beta.4. See the changelog and contracts and limits.

Ordinary functions may be enough for a fixed sequence. AgentRun stores the steps in a workflow document that you can inspect, rerun, or call from an agent. Code nodes execute JavaScript with process privileges; untrusted workflow authors require a host-controlled sandbox. Typed decisions and validated output shapes do not prove that an answer is factually correct.

For development setup and checks, see Contributing. Open an issue for bugs or proposals.

Code and documentation use Apache-2.0. Copyright 2026 Parcha Labs, Inc. Dependencies retain their own licenses. Built by Grep.ai.

查看原文(Hacker News 熱門)