Skip to main content

Python SDK for agentlog - a local-first decision log daemon for agentic workflows

Project description

agentlog Python SDK

Python client for agentlog - a local-first decision log daemon for agentic workflows.

Installation

pip install agentlog-sdk

Quickstart

import agentlog

agentlog.write("decision", "Use PostgreSQL for persistence")
entries = agentlog.query("database")

Requirements

  • Python 3.9+
  • A running agentlogd daemon (see the main project README)

Usage

Writing entries

import agentlog

# Write a decision entry (session created automatically)
agentlog.write(
    "decision",
    "Use Redis for caching",
    body="Redis provides sub-millisecond reads and built-in TTL support.",
    tags=["infrastructure", "caching"],
    files=["config/redis.yaml"],
)

# Supported entry types: decision, attempt_failed, deferred, assumption, question
agentlog.write("assumption", "All users have Python 3.9+")
agentlog.write("question", "Should we use async or sync HTTP client?")

Searching entries

# Full-text search
results = agentlog.query("database migration")

# Search with filters
results = agentlog.query("caching", type="decision", limit=5)

Listing entries

# List entries by type
entries = agentlog.log(type="decision")

# List entries by session
entries = agentlog.log(session="your-session-id")

# List entries by tag
entries = agentlog.log(tag="infrastructure")

# List entries from the last hour
entries = agentlog.log(since="1h")

Getting context for prompts

# Get a formatted text block for prompt injection
context = agentlog.context(query="authentication")
print(context)
# Output:
# # Recent decisions
#
# ## [decision] Use JWT for API auth (2026-03-15 10:30)
# JWTs are stateless and work well with our microservices architecture.
# Tags: auth, api
# Files: internal/auth/jwt.go

Using the client class directly

from agentlog import AgentlogClient

# Custom socket path
client = AgentlogClient(agentlog_dir="/custom/path")

# Or explicit socket path
client = AgentlogClient(socket_path="/tmp/agentlogd.sock")

# All methods are available on the client instance
entry_id = client.write("decision", "Use gRPC for internal services")

Configuration

The SDK looks for the daemon socket at ~/.agentlog/agentlogd.sock by default. Override this with:

  • The AGENTLOG_DIR environment variable
  • The agentlog_dir constructor argument
  • The socket_path constructor argument (takes precedence)

Error handling

from agentlog import AgentlogError, ConnectionError, DaemonNotRunning

try:
    agentlog.write("decision", "Test entry")
except DaemonNotRunning:
    print("Start the daemon first: agentlog start")
except ConnectionError as e:
    print(f"Connection failed: {e}")
except AgentlogError as e:
    print(f"Unexpected error: {e}")

Development

# Install in development mode
pip install -e sdk/python/

# Run tests
python -m pytest sdk/python/tests/ -v

# Run only unit tests (no daemon required)
python -m pytest sdk/python/tests/test_client.py -v

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

agentlog_sdk-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

agentlog_sdk-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file agentlog_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: agentlog_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agentlog_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ccb14a0a39273b3568b1e930d50c4b18a233feb74424a77f99d957822fe6b611
MD5 11611af9362d0f7223a37d42b259b092
BLAKE2b-256 b4ccb7b49b31a1e8338820973999b3a0d5d2f8ce0eb8cf7b52f97784116c75e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentlog_sdk-0.1.0.tar.gz:

Publisher: publish-pypi.yml on byronxlg/agentlog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentlog_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agentlog_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agentlog_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba714038124dbbe631f85548aeda9172a8755dc364920286ef6f5d9bd44a59fe
MD5 0890a72beaff01e056691e951862253e
BLAKE2b-256 5e02276e5dd871ff20b73d7783d0d4dd7eaf27d01496f617ac8972f984f58141

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentlog_sdk-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on byronxlg/agentlog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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