Files
united-workforce/packages/workflow-agent-llm
xiaoju e9e4960714 refactor(workflow): migrate downstream packages to workflow-runtime (Phase 2+3)
- Verify createWorkflow in runtime has zero I/O imports
- Migrate agent-cursor, agent-hermes to pure workflow-runtime dependency
- Migrate agent-llm, util-agent, templates to dual dependency
  (runtime for types, engine for CAS/merkle/buildDescriptor)
- All 377 tests passing

Refs #121, relates #123 #124
2026-05-08 06:33:52 +00:00
..

@uncaged/workflow-agent-llm

AgentFn adapter that calls an OpenAI-compatible POST /chat/completions endpoint using @uncaged/workflow’s LlmProvider (base URL, API key, model).

Single-turn: system text is the current role’s systemPrompt, user text is the thread’s initial prompt (ctx.start.content). Errors from HTTP, JSON, or empty choices are thrown as Error with a JSON payload string.

Install

bun add @uncaged/workflow-agent-llm @uncaged/workflow

In this monorepo: "@uncaged/workflow-agent-llm": "workspace:*", "@uncaged/workflow": "workspace:*".

Usage

import { createLlmAdapter } from "@uncaged/workflow-agent-llm";

const agent = createLlmAdapter({
  baseUrl: "https://api.openai.com/v1",
  apiKey: process.env.OPENAI_API_KEY!,
  model: "gpt-4.1-mini",
});

API overview

Export Description
createLlmAdapter(provider) LlmProviderAgentFn
chatCompletionText({ provider, messages }) Low-level Result<string, LlmChatError> helper
LlmMessage { role: "system" | "user" | "assistant"; content: string }
LlmChatError Discriminated error kinds for failed completions