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.1.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.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agentlog_sdk-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 6265ea9816e0ab5762f4c3f3c8866f4c738b22af1a86b5789811e06d80acd57d
MD5 e1e2a1c2f97d39b0d1bdbb353d99ab65
BLAKE2b-256 ca0f9e9027009d881115e37c14e9e84456a040160c644adbea519510480e013e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: agentlog_sdk-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a51a436b722a1e3a341c1adc7e6736166e49579e562c170d6793c1bb03ab46a0
MD5 03ba5e4cd0f631c4c21c6814947e2d14
BLAKE2b-256 cb876f75e2a6fbebc2742e562db122d24a95d4b25044d1830fdc3b0d45df45e6

See more details on using hashes here.

Provenance

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