Skip to main content

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

Release files for agentlog-sdk 0.2.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 agentlog-sdk 0.2.0
File Size Uploaded
agentlog_sdk-0.2.0.tar.gz 13.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentlog-sdk 0.2.0
File Interpreter ABI Platform
agentlog_sdk-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / agentlog_sdk-0.2.0.tar.gz

Download URL agentlog_sdk-0.2.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b37530cae98256b50b4290d36515ab29f6514cd4243ea41b546160d5cd9dd318
BLAKE2b-256 checksum
How to use checksums
5ba58437227dbd38f65b35468968727a2800807e1fa287801ef46f56f6d8274c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 17, 2026.

Transparency log

Release files / agentlog_sdk-0.2.0-py3-none-any.whl

Download URL agentlog_sdk-0.2.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b5da1d08ccb6ddd0e3a2aa0c258d55c9d3f0ea9033a252a7e17417188ec109f
BLAKE2b-256 checksum
How to use checksums
343cc399dd9bc94b8ec3216df503acedb104c578c8dbb163661b648a15d74f9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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