Skip to main content

Weights & Biases Agent Library - A minimal framework for building LLM agents

Project description

WBAL

Weights & Biases Agent Library — a compact framework for wiring LLM agents, environments, and tools.

What’s inside

  • Agent loop: Agent implements the perceive → invoke → do cycle. OpenAIWBAgent is the reference implementation tuned for the OpenAI Responses API (adds exit(), reasoning/message rendering, optional parallel tool calls).
  • Environments: Environment is the base; DataEnv adds persisted notes/observations; PollEnv adds write tools; ChatEnv adds a chat() tool and input gating. Configured variants can attach tools from importable modules.
  • LM adapters: OpenAIResponsesLM, GPT5Large, GPT5MiniTester, ScriptedLM (deterministic), and KimiK2LM (W&B Inference chat-completions).
  • YAML-first agents: YamlAgent + AgentManifest/PromptManifest wire prompts, LMs, env kind, tool modules, and explicit delegates (run_agent / list_agents).
  • CLI + bundles: wbal CLI runs chat/poll/baseline or YAML agents and validates/runs WandBSwarm-compatible bundles (run.sh + optional install.sh).

Installation

  • Python >=3.13,<3.14
  • LLMs require OPENAI_API_KEY (and WANDB_API_KEY for KimiK2LM)

From PyPI:

pip install wbal

From source:

git clone <this-repo>
cd wbal
uv sync

Quick start (code)

import os
import weave
from wbal import GPT5MiniTester, OpenAIWBAgent, weaveTool
from wbal.environments.chat_env import ChatEnv

weave.init(os.getenv("WEAVE_PROJECT", "my-project"))

class MyEnv(ChatEnv):
    env = "You are a helpful assistant."
    include_working_directory_listing = False

    @weaveTool
    def greet(self, name: str) -> str:
        """Greet someone by name."""
        return f"Hello, {name}!"

env = MyEnv(task="Use greet to say hello to Alice, then call exit().", working_directory="./.wbal_state")
agent = OpenAIWBAgent(
    env=env,
    lm=GPT5MiniTester(),
    maxSteps=10,
    system_prompt="Use tools when helpful. Call exit() when you're done.",
)
agent.run()

CLI (high level)

# Baseline (non-interactive) run
wbal run --project myproj --task "Say hello"

# Interactive chat
wbal chat --project myproj --task "Help the user"

# Polling loop (optionally on an interval)
wbal poll --project myproj --task "Check status" --interval 300

# YAML-first (recommended)
wbal agents run --spec path/to/agent.yaml --task "Do the thing"
wbal agents validate --spec path/to/agent.yaml
wbal agents list --dir examples/agents

# Bundles (WandBSwarm contract: run.sh required, install.sh optional)
wbal bundle validate --agent-dir path/to/agent
wbal bundle run --agent-dir path/to/agent --task-dir ./task --workspace-dir ./workspace
wbal bundle shell --agent-dir path/to/agent --task-dir ./task --workspace-dir ./workspace

Common YAML flags: --var KEY=VALUE (prompt templating), --set PATH=VALUE (override instantiated fields), --env KEY=VALUE (env vars before load), --weave-project, --metadata-out.

YAML agents (essentials)

wbal.manifests.AgentManifest fields:

name: orchestrator
description: Optional summary

prompt: prompts/orchestrator.prompt.yaml    # or set system_prompt/system_messages inline

lm:
  kind: openai_responses                    # or gpt5_large, gpt5_mini, scripted
  model: gpt-5-mini
  temperature: 1.0
  reasoning: { effort: minimal }

env:
  kind: poll                                # basic | data | chat | poll
  env: "Context shown to the agent"
  working_directory: ./.wbal_state
  include_working_directory_listing: true
  include_tools_in_observe: false

tools:
  env: [wbal.tools.bash]                    # import specs; merged with env methods
  agent: []                                 # import specs; merged with agent methods

delegates:                                  # explicit subagents for run_agent()
  researcher: worker_research.agent.yaml
share_working_directory: true
max_steps: 30
tool_timeout: 60
parallel_tool_calls: true
max_concurrent_tool_calls: 4

Template vars (--var key=val) render {key} placeholders in prompts/env fields. Delegates resolve relative to the manifest path.

Components (exports)

from wbal import (
    # Core primitives
    WBALObject, Agent, Environment, StatefulEnvironment, LM,
    # Environments
    DataEnv, ChatEnv, PollEnv,
    # Agents
    OpenAIWBAgent, YamlAgent, ExitableAgent,
    # LMs
    GPT5Large, GPT5MiniTester, OpenAIResponsesLM, ScriptedLM, KimiK2LM,
    # Manifests + runner
    AgentManifest, PromptManifest, build_agent_from_file, load_agent_manifest,
    load_prompt_manifest, run_agent_spec,
    # Tooling
    tool, weaveTool, get_tools, extract_tool_schema, to_openai_tool, to_anthropic_tool,
    format_openai_tool_response, tool_timeout, ToolTimeoutError,
    # Bundles
    AgentBundleEntry, validate_agent_bundle, run_agent_bundle, shell_agent_bundle,
)

Examples

  • examples/simple_example.py — minimal ChatEnv + OpenAIWBAgent.
  • examples/zagent_v1.py — orchestrator-style agent with persistent notes and bash tool wiring.
  • examples/agents/ — YAML manifests (baseline, orchestrator with delegates, worker agents + prompts).
  • examples/story_summarizer.py — custom Agent/Environment pair that reads files and summarizes.
  • examples/bundles/hello_bundle — minimal bundle exercising the WandBSwarm contract.

Run an example:

uv run python examples/zagent_v1.py --task "Inspect this repo, take notes, then exit()"

Testing

uv run pytest

Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wbal-0.6.0.tar.gz (132.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wbal-0.6.0-py3-none-any.whl (45.0 kB view details)

Uploaded Python 3

File details

Details for the file wbal-0.6.0.tar.gz.

File metadata

  • Download URL: wbal-0.6.0.tar.gz
  • Upload date:
  • Size: 132.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for wbal-0.6.0.tar.gz
Algorithm Hash digest
SHA256 a8cdf343876761e8fbad90bfc319f8d6881edeba5d6119762db54476355d6c5a
MD5 db8dc0d72eb85a385b292c8fd991e3e1
BLAKE2b-256 4ff934ed871fde8faa6102543e39fd1b950bcacb03c79b275ba218084becde56

See more details on using hashes here.

File details

Details for the file wbal-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: wbal-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 45.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for wbal-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2a2b037770b1ffd5aea8b8b08f9b0673f9ae3769e78813858403af1aae8a53d
MD5 dce52d30e30e3597d2316ef1d88ffa4d
BLAKE2b-256 2cfd362691a11eab0719f6104679270c806da3398e203045e3805c85a571974c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page