draftcrew

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 17 Imported by: 0

README

DraftCrew

High-performance Go framework for AI agent orchestration.

Inspired by CrewAI — built for Go. Agents, tasks, crews, and all 6 process types (sequential, hierarchical, consensual, reflective, flow, state machine) in a single binary with zero runtime dependencies.

go get github.com/bzdvdn/draftcrew@latest

Why DraftCrew?

Python-based agent frameworks (CrewAI, AutoGen, LangGraph) are powerful but hit walls in production: GIL contention, no native concurrency, heavy dependency trees, and complex deployment. DraftCrew brings agent orchestration to Go's world:

  • Goroutines, not GIL — true parallel agent execution via Go's concurrency model
  • Static typing — catch misconfigurations at compile time, not runtime
  • Single binary — no Python runtime, no pip install, no virtualenvs
  • Type-safe toolsGetOutput[T](result) via generics, zero reflection
  • Production observability — built-in event bus, telemetry, OpenTelemetry bridging
  • MCP-native — Model Context Protocol client for tool discovery (stdio + SSE)

Status: v0.4 — Ecosystem (Knowledge ✅, Browser ✅, Guardrails ✅, Training ✅)

Core primitives + A2A delegation + MCP server + WASM/Docker sandbox + knowledge ingestion (RAG) + browser automation + output guardrails. 16 packages, race-detector clean.

What works today
Feature Status
Agent with ReAct loop, tool calling, memory
Task with context passing, HITL
Crew: sequential, hierarchical, consensual, reflective, flow, state machine
LLM providers: OpenAI, Anthropic, Gemini, DeepSeek, Mistral, Ollama, OpenRouter, Azure
Built-in tools: shell, calculator, file I/O, web search, ask human, delegate, A2A delegate, code interpreter
A2A protocol: message envelope, typed payloads, W3C trace context
A2A client: Bearer auth, exponential backoff, circuit breaker, WebSocket streaming
A2A server: POST /, WebSocket /ws, Bearer auth, graceful shutdown
Agent registry: Register, Unregister, Lookup, FindByCapability, ListAll
Agent integration: DelegateTo(), DelegationFuture.Await(), auto-register on start
MCP client (stdio + SSE)
MCP server (SSE + POST, JSON-RPC 2.0, tool/resource registration, agent self-exposure)
Knowledge sources (RAG: text, PDF, CSV, JSON, URL via draftRAG)
Wasm sandbox (wazero — compile & run Go WASM with memory/timeout limits)
Docker sandbox (optional — Python in container with resource limits)
YAML config parser
Event bus + telemetry + OTEL bridge
Eval criteria (contains, regex, LLM judge)
Output guardrails (regex, length, contains, banned words, JSON schema) with task-level retry
Browser automation tool (chromedp: navigate, click, type, extract, screenshot, scroll)
Training/HITL loop: Crew.Train(), feedback persistence, advice injection
CLI (draftcrew run, draftcrew start)

Where we're heading

DraftCrew aims to match CrewAI's feature set and then surpass it in areas where Go excels. The roadmap:

Near-term (v0.4–v0.5)
  • Knowledge ingestion — RAG with PDF/CSV/URL sources ✅ done
  • Browser automation — chromedp-based web interaction ✅ done
  • Output guardrails — regex, length, contains, banned words, JSON schema ✅ done
  • Training/HITL loop — feedback-loop agent improvement ✅ done
Long-term vision
  • Visual workflow builder — DAG-based crew designer
  • gRPC mesh server — distributed agent orchestration across machines
  • Cloud control plane — fleet management for production agent deployments
  • Training/fine-tuning pipeline — feedback-loop agent improvement
Out of scope (for now)

DraftCrew will not become a vector database, a training framework, or a cloud platform. We build the orchestration layer — you bring the infrastructure.

Quick start

package main

import (
    "context"
    "fmt"

    "github.com/bzdvdn/draftcrew/src/pkg/agent"
    "github.com/bzdvdn/draftcrew/src/pkg/crew"
    "github.com/bzdvdn/draftcrew/src/pkg/llm"
    "github.com/bzdvdn/draftcrew/src/pkg/task"
)

func main() {
    llmClient := llm.NewOpenAI("sk-...", "gpt-4")

    a := agent.New(agent.Config{
        Role:    "Researcher",
        Goal:    "Research Go 1.22 features",
        LLM:     llmClient,
        MaxIter: 15,
    })

    t := task.New(task.Config{
        Description:    "Find key features",
        ExpectedOutput: "List of features",
        Agent:          a,
    })

    c := crew.New(crew.Config{
        Agents:  []*agent.Agent{a},
        Tasks:   []*task.Task{t},
        Process: crew.ProcessSequential,
    })

    result, err := c.Kickoff(context.Background())
    if err != nil {
        panic(err)
    }
    fmt.Printf("%+v\n", result)
}

See the Quickstart Guide for the full walkthrough.

Installation

go get github.com/bzdvdn/draftcrew@latest

Or install the CLI:

go install github.com/bzdvdn/draftcrew/cmd/draftcrew@latest

Requires Go 1.22+.

Documentation

Roadmap

Release Focus
v0.1 Foundation — core primitives, sequential process
v0.2 A2A Protocol — agent-to-agent delegation
v0.3 MCP Server + Sandbox — expose agents as MCP servers, WASM/Docker code execution
v0.4 Ecosystem — knowledge ✅, browser ✅, guardrails ✅, training ✅

Detailed roadmap: ROADMAP.md

Contributing

We welcome contributions. See the specs for active work items and AGENTS.md for workflow conventions.

License

MIT — see LICENSE.

Documentation

Overview

Package draftcrew provides a high-performance, idiomatic Go framework for AI agent orchestration.

Includes A2A (agent-to-agent) protocol for inter-agent delegation with HTTP+WebSocket transport, circuit breaker, and agent registry.

Basic usage:

llm := draftcrew.NewOpenAI(os.Getenv("OPENAI_API_KEY"), "gpt-4")
agent := draftcrew.NewAgent(draftcrew.AgentConfig{Role: "Researcher", Goal: "Find trends", LLM: llm})
task := draftcrew.NewTask(draftcrew.TaskConfig{Description: "Research Go 1.22", Agent: agent})
crew := draftcrew.NewCrew(draftcrew.CrewConfig{Agents: []*draftcrew.Agent{agent}, Tasks: []*draftcrew.Task{task}})
result, err := crew.Kickoff(context.Background())

Index

Constants

View Source
const (
	ProcessSequential   = crew.ProcessSequential
	ProcessHierarchical = crew.ProcessHierarchical
	ProcessConsensual   = crew.ProcessConsensual
	ProcessReflective   = crew.ProcessReflective
	ProcessFlow         = crew.ProcessFlow
	ProcessStateMachine = crew.ProcessStateMachine
)

ProcessType constants for crew execution modes.

View Source
const (
	PhaseAgentInit        = callback.PhaseAgentInit
	PhaseAgentThink       = callback.PhaseAgentThink
	PhaseAgentTool        = callback.PhaseAgentTool
	PhaseAgentOutput      = callback.PhaseAgentOutput
	PhaseAgentComplete    = callback.PhaseAgentComplete
	PhaseAgentError       = callback.PhaseAgentError
	PhaseTaskStart        = callback.PhaseTaskStart
	PhaseTaskComplete     = callback.PhaseTaskComplete
	PhaseTaskError        = callback.PhaseTaskError
	PhaseCrewStart        = callback.PhaseCrewStart
	PhaseCrewComplete     = callback.PhaseCrewComplete
	PhaseCrewError        = callback.PhaseCrewError
	PhaseHumanInput       = callback.PhaseHumanInput
	PhaseReviewRequired   = callback.PhaseReviewRequired
	PhaseFlowStart        = callback.PhaseFlowStart
	PhaseFlowNodeStart    = callback.PhaseFlowNodeStart
	PhaseFlowNodeComplete = callback.PhaseFlowNodeComplete
	PhaseFlowComplete     = callback.PhaseFlowComplete
)

Callback phase constants for agent, task, crew, and flow lifecycle events.

View Source
const (
	EventPhaseTransition = telemetry.EventPhaseTransition
	EventLLMCall         = telemetry.EventLLMCall
	EventToolExecution   = telemetry.EventToolExecution
	EventError           = telemetry.EventError
	EventCheckpoint      = telemetry.EventCheckpoint
)

Telemetry event type constants.

View Source
const (
	PhaseCheckpointSave = callback.PhaseCheckpointSave
	PhaseCheckpointLoad = callback.PhaseCheckpointLoad
	PhaseResumeStart    = callback.PhaseResumeStart
	PhaseResumeComplete = callback.PhaseResumeComplete
)

Checkpoint and resume callback phases.

Variables

View Source
var (
	NewTextFileSource = knowledge.NewTextFileSource
	NewPDFSource      = knowledge.NewPDFSource
	NewCSVSource      = knowledge.NewCSVSource
	NewJSONSource     = knowledge.NewJSONSource
	NewURLSource      = knowledge.NewURLSource
)

Knowledge source constructors.

View Source
var (
	NewOpenAI           = llm.NewOpenAI
	NewAnthropic        = llm.NewAnthropic
	NewGemini           = llm.NewGemini
	NewDeepSeek         = llm.NewDeepSeek
	NewMistral          = llm.NewMistral
	NewOpenRouter       = llm.NewOpenRouter
	NewAzureOpenAI      = llm.NewAzureOpenAI
	NewOllama           = llm.NewOllama
	NewOpenAICompatible = llm.NewOpenAICompatible
	WithTemperature     = llm.WithTemperature
	WithMaxTokens       = llm.WithMaxTokens
	WithTopP            = llm.WithTopP
	WithTools           = llm.WithTools
)

LLM provider constructors and options.

View Source
var (
	NewTool             = tools.New
	ShellTool           = tools.ShellTool
	CalculatorTool      = tools.CalculatorTool
	ReadFileTool        = tools.ReadFileTool
	WriteFileTool       = tools.WriteFileTool
	WebSearchTool       = tools.WebSearchTool
	AskHumanTool        = tools.AskHumanTool
	DelegateWorkTool    = tools.DelegateWorkTool
	DelegateToAgentTool = tools.DelegateToAgentTool
	AskAgentTool        = tools.AskAgentTool
	BrowserTool         = tools.BrowserTool
	WithChromePath      = tools.WithChromePath
	WithTabTimeout      = tools.WithTabTimeout
	WithHeadless        = tools.WithHeadless
)

Built-in tool constructors.

View Source
var (
	NewA2AClient = a2a.NewA2AClient
	NewA2AServer = a2a.NewA2AServer
)
View Source
var (
	NewShortTerm    = memory.NewShortTerm
	NewEntityMemory = memory.NewEntityMemory
)

Memory store constructors.

View Source
var (
	ErrNoAgents           = errors.ErrNoAgents
	ErrNoTasks            = errors.ErrNoTasks
	ErrAgentNil           = errors.ErrAgentNil
	ErrLLMFailed          = errors.ErrLLMFailed
	ErrMaxIterations      = errors.ErrMaxIterations
	ErrMaxRPM             = errors.ErrMaxRPM
	ErrInvalidProcess     = errors.ErrInvalidProcess
	ErrToolFailed         = errors.ErrToolFailed
	ErrGuardrail          = errors.ErrGuardrail
	ErrTaskFailed         = errors.ErrTaskFailed
	ErrNoMatchingPath     = errors.ErrNoMatchingPath
	ErrCycleDetected      = errors.ErrCycleDetected
	WrapError             = errors.Wrap
	WrapErrorE            = errors.WrapE
	IsError               = errors.Is
	ErrCheckpointNotFound = errors.ErrCheckpointNotFound
)

Sentinel errors and error helpers.

View Source
var (
	NewFlow             = flow.New
	NewEventBus         = telemetry.NewEventBus
	NewMetricsCollector = telemetry.NewMetricsCollector
	NewCallbackBridge   = telemetry.NewCallbackBridge
	NewOTELBridge       = telemetry.NewOTELBridge
)

Constructor functions.

View Source
var (
	NewRegexGuardrail       = guardrail.NewRegexGuardrail
	NewLengthGuardrail      = guardrail.NewLengthGuardrail
	NewContainsGuardrail    = guardrail.NewContainsGuardrail
	NewBannedWordsGuardrail = guardrail.NewBannedWordsGuardrail
	NewJSONSchemaGuardrail  = guardrail.NewJSONSchemaGuardrail
)

Guardrail constructors.

View Source
var (
	NewTrainingStore    = training.NewFileStore
	NewFileStore        = training.NewFileStore
	ConsolidateFeedback = training.Consolidate

	// LoadTrainingAdvice loads consolidated advice for an agent.
	LoadTrainingAdvice = training.LoadAdvice
)

Training constructors.

View Source
var (
	// ParseYAML parses a crew.yaml file.
	ParseYAML     = yamlconfig.Parse
	ParseYAMLFile = yamlconfig.ParseFile
	ToCrewConfig  = yamlconfig.ToCrewConfig
)

CLI entrypoint.

View Source
var NewAgent = agent.New

NewAgent creates a new Agent with the given configuration.

View Source
var NewCrew = crew.New

NewCrew creates a new Crew with the given configuration.

View Source
var NewTask = task.New

NewTask creates a new Task with the given configuration.

Functions

func GetOutput

func GetOutput[T any](r *crew.Result, taskID string) (T, error)

GetOutput extracts and unmarshals a typed result from a crew execution result.

Types

type A2AClient added in v0.2.0

type A2AClient = a2a.A2AClient

A2A protocol types and constructors.

type A2AMessage added in v0.2.0

type A2AMessage = a2a.A2AMessage

A2A protocol types and constructors.

type A2AServer added in v0.2.0

type A2AServer = a2a.A2AServer

A2A protocol types and constructors.

type Agent

type Agent = agent.Agent

Agent is a type alias for agent.Agent.

type AgentConfig

type AgentConfig = agent.Config

AgentConfig is a type alias for agent.Config.

type Callback

type Callback = callback.Callback

Callback is a type alias for callback.Callback.

type CallbackBridge

type CallbackBridge = telemetry.CallbackBridge

CallbackBridge is a type alias for telemetry.CallbackBridge.

type Checkpoint

type Checkpoint = crew.Checkpoint

Checkpoint is a type alias for crew.Checkpoint.

type CheckpointStore

type CheckpointStore = crew.CheckpointStore

CheckpointStore is a type alias for crew.CheckpointStore.

type Crew

type Crew = crew.Crew

Crew is a type alias for crew.Crew.

type CrewConfig

type CrewConfig = crew.Config

CrewConfig is a type alias for crew.Config.

type CrewError

type CrewError = errors.CrewError

CrewError is a type alias for errors.CrewError.

type Criterion

type Criterion = eval.Criterion

Criterion is a type alias for eval.Criterion.

type DurationHistogram

type DurationHistogram = telemetry.DurationHistogram

DurationHistogram is a type alias for telemetry.DurationHistogram.

type EvalResult

type EvalResult = eval.Result

EvalResult is a type alias for eval.Result.

type EventBus

type EventBus = telemetry.EventBus

EventBus is a type alias for telemetry.EventBus.

type EventType

type EventType = telemetry.EventType

EventType is a type alias for telemetry.EventType.

type Flow

type Flow = flow.Flow

Flow is a type alias for flow.Flow.

type FlowEdge

type FlowEdge = flow.Edge

FlowEdge is a type alias for flow.Edge.

type FlowNode

type FlowNode = flow.Node

FlowNode is a type alias for flow.Node.

type FlowResult

type FlowResult = flow.Result

FlowResult is a type alias for flow.Result.

type GenerateOption

type GenerateOption = llm.GenerateOption

GenerateOption is a type alias for llm.GenerateOption.

type Guardrail added in v0.4.0

type Guardrail = guardrail.Guardrail

Guardrail is a type alias for guardrail.Guardrail.

type KnowledgeChunk added in v0.4.0

type KnowledgeChunk = knowledge.Chunk

KnowledgeChunk is a type alias for knowledge.Chunk.

type KnowledgeSource added in v0.4.0

type KnowledgeSource = knowledge.KnowledgeSource

KnowledgeSource is a type alias for knowledge.KnowledgeSource.

type LLM

type LLM = llm.Client

LLM is a type alias for llm.Client.

type MemoryEntry

type MemoryEntry = memory.Entry

MemoryEntry is a type alias for memory.Entry.

type MemoryStore

type MemoryStore = memory.Store

MemoryStore is a type alias for memory.Store.

type Message

type Message = llm.Message

Message is a type alias for llm.Message.

type MetricsSnapshot

type MetricsSnapshot = telemetry.MetricsSnapshot

MetricsSnapshot is a type alias for telemetry.MetricsSnapshot.

type NodeState

type NodeState = crew.NodeState

NodeState is a type alias for crew.NodeState.

type OTELBridge

type OTELBridge = telemetry.OTELBridge

OTELBridge is a type alias for telemetry.OTELBridge.

type OutputCondition

type OutputCondition = flow.OutputCondition

OutputCondition is a type alias for flow.OutputCondition.

type Phase

type Phase = callback.Phase

Phase is a type alias for callback.Phase.

type ProcessType

type ProcessType = crew.ProcessType

ProcessType is a type alias for crew.ProcessType.

type Response

type Response = llm.Response

Response is a type alias for llm.Response.

type Result

type Result = crew.Result

Result is a type alias for crew.Result.

type StepInfo

type StepInfo = callback.StepInfo

StepInfo is a type alias for callback.StepInfo.

type StreamChunk

type StreamChunk = llm.StreamChunk

StreamChunk is a type alias for llm.StreamChunk.

type Task

type Task = task.Task

Task is a type alias for task.Task.

type TaskConfig

type TaskConfig = task.Config

TaskConfig is a type alias for task.Config.

type TelemetryEvent

type TelemetryEvent = telemetry.Event

TelemetryEvent is a type alias for telemetry.Event.

type TelemetryMetadata

type TelemetryMetadata = telemetry.Metadata

TelemetryMetadata is a type alias for telemetry.Metadata.

type Tool

type Tool = tools.Tool

Tool is a type alias for tools.Tool.

type ToolCall

type ToolCall = llm.ToolCall

ToolCall is a type alias for llm.ToolCall.

type ToolDef

type ToolDef = llm.ToolDef

ToolDef is a type alias for llm.ToolDef.

type TrainingFeedback added in v0.4.0

type TrainingFeedback = training.Feedback

TrainingFeedback is a type alias for training.Feedback.

type TrainingStore added in v0.4.0

type TrainingStore = training.Store

TrainingStore is a type alias for training.Store.

type Transport

type Transport = mcp.Transport

Transport is a type alias for mcp.Transport.

type Usage

type Usage = llm.Usage

Usage is a type alias for llm.Usage.

type YAMLEvalConfig

type YAMLEvalConfig = yamlconfig.EvalConfig

YAMLEvalConfig is a type alias for yamlconfig.EvalConfig.

type YAMLEvalCriterionConfig

type YAMLEvalCriterionConfig = yamlconfig.EvalCriterionConfig

YAMLEvalCriterionConfig is a type alias for yamlconfig.EvalCriterionConfig.

type YAMLLLMConfig

type YAMLLLMConfig = yamlconfig.LLMConfig

YAMLLLMConfig is a type alias for yamlconfig.LLMConfig.

type YAMLMCPServerConfig

type YAMLMCPServerConfig = yamlconfig.MCPServerConfig

YAMLMCPServerConfig is a type alias for yamlconfig.MCPServerConfig.

type YAMLMCPSetup

type YAMLMCPSetup = yamlconfig.MCPSetup

YAMLMCPSetup is a type alias for yamlconfig.MCPSetup.

Directories

Path Synopsis
examples
a2a command
@sk-task a2a#polish: A2A example — two agents communicating via HTTP
@sk-task a2a#polish: A2A example — two agents communicating via HTTP
features/browser command
@sk-task browser-tool#T4.1: browser example
@sk-task browser-tool#T4.1: browser example
features/guardrails command
This example demonstrates output validation guardrails:
This example demonstrates output validation guardrails:
features/knowledge command
@sk-task knowledge-sources#T4.2: knowledge example
@sk-task knowledge-sources#T4.2: knowledge example
features/training command
This example demonstrates the Training/HITL loop:
This example demonstrates the Training/HITL loop:
mcp-server command
MCP server example — exposes a DraftCrew agent as an MCP-compatible endpoint.
MCP server example — exposes a DraftCrew agent as an MCP-compatible endpoint.
quickstart command
@sk-task foundation#T5.1: write quickstart example (AC-001, AC-015)
@sk-task foundation#T5.1: write quickstart example (AC-001, AC-015)
sandbox command
Sandbox example — runs code in an isolated WASM sandbox.
Sandbox example — runs code in an isolated WASM sandbox.
src
cmd/draftcrew command
@sk-task ecosystem#T1.2: CLI entrypoint with cobra + viper (AC-001, AC-002)
@sk-task ecosystem#T1.2: CLI entrypoint with cobra + viper (AC-001, AC-002)
eval
@sk-task ecosystem#T3.1: Eval package (contains, regex, llm_judge)
@sk-task ecosystem#T3.1: Eval package (contains, regex, llm_judge)
mcp
@sk-task ecosystem#T2.2: MCP client (connect, tools/list, tools/call)
@sk-task ecosystem#T2.2: MCP client (connect, tools/list, tools/call)
pkg/dashboard
@sk-task dashboard-polish#T1.1: Dashboard package with SSE handler + HTML (AC-001, AC-003)
@sk-task dashboard-polish#T1.1: Dashboard package with SSE handler + HTML (AC-001, AC-003)
pkg/guardrail
Package guardrail provides output validation guardrails for AI agent responses.
Package guardrail provides output validation guardrails for AI agent responses.
pkg/llm
Package llm provides LLM provider abstractions for DraftCrew.
Package llm provides LLM provider abstractions for DraftCrew.
pkg/sandbox
Package sandbox provides sandboxed code execution via WASM (wazero) or Docker.
Package sandbox provides sandboxed code execution via WASM (wazero) or Docker.
pkg/yamlconfig
@sk-task ecosystem#T1.1: YAML config parser (AC-001, AC-002, AC-010)
@sk-task ecosystem#T1.1: YAML config parser (AC-001, AC-002, AC-010)
telemetry module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL