Skip to main content

labs-agent-lib

Shared utilities extracted from candidate-match-agent for building Claude-agent-based projects:

  • labs_agent_lib.agent_settings — a pydantic-settings AgentSettings model (gateway provider, log level, Portkey/Anthropic credentials, prompt-caching toggle).
  • labs_agent_lib.logger — centralized stderr logging, configured from AgentSettings.log_level.
  • labs_agent_lib.file_reader — extracts plain text from .pdf, .docx, .txt, .md, and .markdown files.
  • labs_agent_lib.agent_environment — builds the ClaudeAgentOptions.env dict (base URL, API key, custom headers) for the configured provider.
  • labs_agent_lib.observability — PromptLogWriter/AgentTranscriptWriter: JSONL writers for a prompt log ("what we asked the model") and an agent transcript ("what happened, step by step"), correlated by a caller-supplied correlation_id. Each consuming project supplies its own settings object (just needs observability_enabled, prompt_log_dir, agent_transcript_dir) and a service name.

Install

uv add labs-agent-lib
# or
pip install labs-agent-lib

Configuration

AgentSettings reads from your project's own .env file (or real environment variables), with every key prefixed LABS_AGENT_LIB_:

Env var Default Description
LABS_AGENT_LIB_PROVIDER portkey Gateway to route through: portkey or anthropic.
LABS_AGENT_LIB_LOG_LEVEL INFO DEBUG, INFO, WARNING, or ERROR.
LABS_AGENT_LIB_PORTKEY_BASE_URL https://portkeygateway.perficient.com Portkey gateway base URL.
LABS_AGENT_LIB_PORTKEY_API_KEY "" Portkey API key (secret).
LABS_AGENT_LIB_PORTKEY_VIRTUAL "" Provider/credential alias from the Portkey dashboard (e.g. aws-bedrock-use2).
LABS_AGENT_LIB_ANTHROPIC_BASE_URL https://api.anthropic.com Anthropic API base URL.
LABS_AGENT_LIB_ANTHROPIC_API_KEY "" Anthropic API key (secret).
LABS_AGENT_LIB_DISABLE_PROMPT_CACHING false Disable Anthropic prompt caching, e.g. while iterating on a system prompt.

Example .env:

LABS_AGENT_LIB_PROVIDER=anthropic
LABS_AGENT_LIB_ANTHROPIC_API_KEY=sk-ant-...

Usage

from labs_agent_lib import get_logger, get_agent_settings, get_agent_environment
from labs_agent_lib.file_reader import extract_text

logger = get_logger(__name__)
settings = get_agent_settings()
env = get_agent_environment(settings)
text = extract_text("resume.pdf")

Development

uv sync
uv run pytest

Metadata

Release files for labs-agent-lib 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for labs-agent-lib 0.1.0
File Size Uploaded Provenance Actions
labs_agent_lib-0.1.0.tar.gz 8.8 kB Without provenance Details for labs_agent_lib-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for labs-agent-lib 0.1.0
File Interpreter ABI Platform Actions
labs_agent_lib-0.1.0-py3-none-any.whl Python 3 none any Details for labs_agent_lib-0.1.0-py3-none-any.whl

Total release size: 24.2 kB

Release files / labs_agent_lib-0.1.0.tar.gz

Download URL labs_agent_lib-0.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d915da67123e43806ae135f481bac437226caafa9385e7aa9920f4e220f88872
BLAKE2b-256 checksum
How to use checksums
bddfb1288fe3922f3a1569e2f6386d2497598c863daf1e44b8cba5bd7c9b00fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / labs_agent_lib-0.1.0-py3-none-any.whl

Download URL labs_agent_lib-0.1.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49bd222c096d8448ca5d564b20ac2414751d00fad30494c8899f8f5cc1c6c694
BLAKE2b-256 checksum
How to use checksums
5835eb89f233a9b8cd13338a085b754d2771e2a26f74bba9b22d2a1474be6098
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for labs-agent-lib 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page