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 context by topic
context = agentlog.context(topic="authentication")

# Get context by file paths
context = agentlog.context(files=["internal/auth/jwt.go"])

# Combine both
context = agentlog.context(files=["internal/auth/jwt.go"], topic="authentication")

# Limit results
context = agentlog.context(topic="caching", limit=5)

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.2.0.tar.gz (13.2 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.2.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agentlog_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 13.2 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.2.0.tar.gz
Algorithm Hash digest
SHA256 b37530cae98256b50b4290d36515ab29f6514cd4243ea41b546160d5cd9dd318
MD5 77bd7e0c1bc026773422e4a4be006551
BLAKE2b-256 5ba58437227dbd38f65b35468968727a2800807e1fa287801ef46f56f6d8274c

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentlog_sdk-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: agentlog_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b5da1d08ccb6ddd0e3a2aa0c258d55c9d3f0ea9033a252a7e17417188ec109f
MD5 2b74bbfce03fdfd5975b867c49b05f7e
BLAKE2b-256 343cc399dd9bc94b8ec3216df503acedb104c578c8dbb163661b648a15d74f9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentlog_sdk-0.2.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