@burtson-labs/agent-core

中文文档
1.6.96发布于 2026/11/08Apache-2.0TypeScriptCommonJS近 30 天下载 2099

Core reasoning and planning engine for Bandit Agent Framework.

原始使用文档
文档目录9 节
  1. Install
  2. Quick start
  3. Typical pairings
  4. What's inside
  5. Running tests
  6. Adding a regression fixture from a real failure trace
  7. Conventions
  8. Position in the framework
  9. License
Burtson Labs

@burtson-labs/agent-core

Core reasoning and planning engine for the Bandit Agent Framework.

Owns the ToolUseLoop — the iteration controller that drives every Bandit agent run, parent or subagent, in both the VS Code extension and the CLI host.


Install

pnpm add @burtson-labs/agent-core

Quick start

agent-core is provider-agnostic — pair it with a provider client (@burtson-labs/agent-adapters-provider wraps Ollama, OpenAI-compatible endpoints, and the hosted Bandit gateway) and a host-side tool set (@burtson-labs/host-kit ships the extras the CLI and extension use). The minimal shape:

import { createAgentRuntime } from "@burtson-labs/agent-core";

const runtime = createAgentRuntime({
  providerClient,                    // satisfies ProviderClient
  systemPrompt: "You are a helpful coding agent.",
  tools: [/* built-ins + your own */]
});

const plan = await runtime.plan("Summarize this repo");
const result = await runtime.execute();
const report = await runtime.report();

The host wires up streaming + auth on the provider; the loop owns iteration, retry/fallback, compaction, output-budget serialization, and the detector contract.

Typical pairings

You needAdd
LLM provider (Ollama / OpenAI / cloud)@burtson-labs/agent-adapters-provider
Run on Node (shell + filesystem)@burtson-labs/agent-adapters-node
Run in the browser@burtson-labs/agent-adapters-web
Run inside a VS Code extension@burtson-labs/agent-adapters-vscode
Run from a GitHub Action@burtson-labs/agent-adapters-github
Memory / hooks / @-mentions / extra tools@burtson-labs/host-kit
Pre-built runtime (CLI + extension parity)@burtson-labs/stealth-core-runtime
React UI for plan / chat / diff / telemetry@burtson-labs/agent-ui

What's inside

PathPurpose
src/tools/tool-use-loop.tsThe loop itself. Orchestrates LLM call → response parsing → detector pass → tool execution → repeat.
src/tools/tool-use-parser.tsExtracts <tool_call> envelopes (XML, fenced, bare-JSON, pythonic fallbacks).
src/tools/tool-registry.tsTool registration + native-schema generation for Ollama's tools field.
src/tools/core-tools.tsBuilt-in tools: read_file, apply_edit, apply_patch, run_command, git_*, etc.
src/tools/compactMessages.tsGreedy compaction of stale tool-result messages when the message-token budget bites.
src/tools/post-edit-checks.tsAuto type-check after TS/TSX edits.
src/security/secretPatterns.tsSecret detection + redactSecretsString (used everywhere user/tool text is surfaced).
src/telemetry/otlpExporter.tsOpt-in, SDK-less OTLP exporter (TelemetryExporter, resolveTelemetryConfig). Host-agnostic (Web Crypto + fetch); maps a turn to a trace + token/TTFT/duration metrics. Shared by the CLI and IDE host.

Running tests

pnpm --filter @burtson-labs/agent-core test

The suite is split across synthetic contract tests (one file per detector cluster) and real-trace replay tests (turn logs from .bandit/turns/ replayed through a fresh loop):

ConcernFile
Constructor options merged into runtimetest/constructorOptionsContract.test.ts
"Claim without doing" detectors (false-completion, partial-completion, announce-then-stall)test/claimWithoutDoingDetectors.test.ts
"Structured output instead of tool" detectors (code-fence, JSON-todo auto-promote)test/structuredOutputDetectors.test.ts
Loop detectors (prose-loop, todo-churn)test/loopDetectors.test.ts
Malformed/empty recovery (empty-retry, thinking-off-recovery, parse-retry)test/malformedEmptyDetectors.test.ts
Hallucinated <tool_result> recoverytest/hallucinationDetectors.test.ts
Subagent coordination (fired-and-forgotten)test/subagentCoordinationDetectors.test.ts
Tool execution edge cases (dedup, cap, repeat-breaker, not-found, error, todo-progress)test/toolExecutionDetectors.test.ts
Cancellation contracttest/cancellationContract.test.ts
Compaction + goal-anchor contracttest/compactionContract.test.ts
Real-trace replaytest/turnReplay.test.ts

Adding a regression fixture from a real failure trace

When you see a weird agent behavior in a real run, drop the turn-log fixture into the test suite so a future loop change can't silently regress it. See test/fixtures/turns/README.md for the full guide — replay-completeness limits, naming conventions, what to assert, and a copy-paste test template.

Conventions

  • Every detector is one-shot per turn. Each tool_loop:*_nudge event fires at most once before the loop terminates or the model recovers. Adding a new detector means adding the gate flag + a contract test.
  • Constructor options must flow through to runtime. ToolUseLoopOptions set at construction time apply to every runWithMessages call. The merge happens in runWithMessages — see effectiveOptions = { ...defaultOptions, ...perCall }. New options need a corresponding entry in test/constructorOptionsContract.test.ts (the file's exhaustiveness check fails build if you forget).
  • Helpers go in test/_helpers.ts; the replay harness in test/_replay.ts. Both file names start with _ so they're excluded from vitest's test/**/*.test.ts glob.

Position in the framework

[host: VS Code extension or CLI]
              │
              ▼
       ┌──────────────┐
       │ ToolUseLoop  │  ← this package
       └──────┬───────┘
              │
        ┌─────┴─────┐
        ▼           ▼
 [tool registry]   [chat function]
        │              │
        ▼              ▼
  [host-kit tools]   [Ollama / Bandit cloud / etc.]

The loop is host-agnostic. Hosts wire up the chat function (with their own watchdogs / streaming / auth) and supply a tool registry; the loop owns iteration, retry/fallback policy, compaction, output-budget serialization, and the detector contract.

License

Apache License 2.0 — Copyright 2026 Burtson Labs.

版本与发布记录

@burtson-labs/agent-core 共发布 81 个版本,首次发布于 2026/06/05;过去 12 个月发布了 81 个版本。

版本发布日期距今
1.6.96latest2026/11/08今天
1.6.952026/11/036 天前
1.6.942026/10/061 个月前
1.6.932026/10/051 个月前
1.6.922026/10/041 个月前
1.6.912026/09/291 个月前

关于 @burtson-labs/agent-core 的常见问题

@burtson-labs/agent-core 是什么?

Core reasoning and planning engine for Bandit Agent Framework.

如何安装 @burtson-labs/agent-core?

在项目目录运行 npm install @burtson-labs/agent-core,或使用 pnpm add / yarn add / bun add。

@burtson-labs/agent-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@burtson-labs/agent-core 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@burtson-labs/agent-core 可以商用吗?

@burtson-labs/agent-core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@burtson-labs/agent-core 的下载量有多少?

根据 npm 官方下载统计,@burtson-labs/agent-core 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,099 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@burtson-labs/agent-core 还在维护吗?

最新版本 1.6.96 发布于 2026/11/08(今天);至今共发布 81 个版本,其中过去 12 个月发布了 81 个;首次发布于 2026/06/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。