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
agentlogddaemon (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_DIRenvironment variable - The
agentlog_dirconstructor argument - The
socket_pathconstructor 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b37530cae98256b50b4290d36515ab29f6514cd4243ea41b546160d5cd9dd318
|
|
| MD5 |
77bd7e0c1bc026773422e4a4be006551
|
|
| BLAKE2b-256 |
5ba58437227dbd38f65b35468968727a2800807e1fa287801ef46f56f6d8274c
|
Provenance
The following attestation bundles were made for agentlog_sdk-0.2.0.tar.gz:
Publisher:
publish-pypi.yml on byronxlg/agentlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentlog_sdk-0.2.0.tar.gz -
Subject digest:
b37530cae98256b50b4290d36515ab29f6514cd4243ea41b546160d5cd9dd318 - Sigstore transparency entry: 1117392044
- Sigstore integration time:
-
Permalink:
byronxlg/agentlog@97b772a87766d048383ad0c23e2dc09ffe1cd3f5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/byronxlg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@97b772a87766d048383ad0c23e2dc09ffe1cd3f5 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b5da1d08ccb6ddd0e3a2aa0c258d55c9d3f0ea9033a252a7e17417188ec109f
|
|
| MD5 |
2b74bbfce03fdfd5975b867c49b05f7e
|
|
| BLAKE2b-256 |
343cc399dd9bc94b8ec3216df503acedb104c578c8dbb163661b648a15d74f9e
|
Provenance
The following attestation bundles were made for agentlog_sdk-0.2.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on byronxlg/agentlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentlog_sdk-0.2.0-py3-none-any.whl -
Subject digest:
5b5da1d08ccb6ddd0e3a2aa0c258d55c9d3f0ea9033a252a7e17417188ec109f - Sigstore transparency entry: 1117392060
- Sigstore integration time:
-
Permalink:
byronxlg/agentlog@97b772a87766d048383ad0c23e2dc09ffe1cd3f5 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/byronxlg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@97b772a87766d048383ad0c23e2dc09ffe1cd3f5 -
Trigger Event:
push
-
Statement type: