Skip to main content

lampson (Python SDK)

Talk to Lampson agents from Python. Standard library only.

from lampson import Lampson

# server mode: a running Lampson, an API key from `lampson key add`
lampson = Lampson(url="https://my-lampson.com/w/<workspace>", key="lk_...")

# or local mode: Lampson as a child process on this machine (needs the `lampson` command)
lampson = Lampson(local={"workspace": "./my-project"})

r = lampson.ask(agent="shop", thread="customer-42", text="do you have whole-wheat bread?")
print(r["text"])

for ev in lampson.stream(agent="shop", thread="customer-42", text="and the price?"):
    if ev["kind"] == "assistant":
        print(ev["data"])

lampson.close()

An agent for your customers should have only the tools you give it. In local mode, lampson_tools: False removes every tool of Lampson's own (bash, read, write, fetch…) from that process, and agent= sets the agent that answers when a message does not name one:

lampson = Lampson(agent="shop", local={"workspace": "./my-project", "lampson_tools": False})
lampson.ask(thread="customer-42", text="where is my order?")

Your app's functions as tools: the schema comes from the type hints, the docstring is the description, and ctx (who is writing, the thread, your meta) comes from your app, never from the model:

@lampson.tool
def stock(product: str, ctx: dict) -> dict:
    """Units in stock of a product."""
    return db.stock(product, customer=ctx["from"]["id"])

lampson.ask(thread="customer-42", text="do you have bread?", **{"from": {"id": "c-42"}})

With Lampson on another machine the tool code is the same: pass tools_url (the public URL of your endpoint, in the key's --callback list) and tools_secret (the whsec_… that lampson key add shows), and mount the endpoint. Lampson POSTs each call there, signed (RFC 9421); it is verified, run, and a repeated call_id gets 409:

lampson = Lampson(url=..., key=..., tools_url="https://my-app.com/lampson/tools", tools_secret=os.environ["LAMPSON_TOOLS_SECRET"])
app.mount("/lampson/tools", lampson.tools_asgi())     # FastAPI / Starlette; any other: lampson.handle_tool_request(...)

With several workers, give it a shared store for the call_ids: tools_asgi(seen=...).

Or write the tool in Synsema (.lampson/tools/stock.syn, one file per tool): its requires are everything it can touch, and it runs only once a person approved that exact content (lampson tools approve or the web UI; for development, local={"approve_tools": True}). See lampson.org/docs/sdk.

If an agent lists a tool it will not have (a plugin that is off, a typo), you get a line on stderr at start (on_warning= to change it, None to silence it) and the list in lampson.warnings.

The same methods in both modes: ask, stream, agents, job (server), close, and Lampson.verify_signature(raw_body, signature, secret) for callbacks and verify_tool_request(...) for tool calls.

Metadata

Release files for lampson 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lampson 0.5.1
File Size Uploaded Provenance Actions
lampson-0.5.1.tar.gz 13.3 kB With provenance Details for lampson-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lampson 0.5.1
File Interpreter ABI Platform Actions
lampson-0.5.1-py3-none-any.whl Python 3 none any Details for lampson-0.5.1-py3-none-any.whl

Total release size: 25.9 kB

Release files / lampson-0.5.1.tar.gz

Download URL lampson-0.5.1.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
10581e48d26aa097085499d6e957c98c5cb9bf26d059c4d03e5bcdf3d84e5909
BLAKE2b-256 checksum
How to use checksums
90ae576f5aac8159a14a85218dab8e64d40b2007bae886a6b4310c1ff364bf69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 19, 2026.

Transparency log

Release files / lampson-0.5.1-py3-none-any.whl

Download URL lampson-0.5.1-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55c941243d1f157a6596470f507f6608390c753171060a38fe4f686d68d5b759
BLAKE2b-256 checksum
How to use checksums
afb8fcf167686dbc601155c6b25c69ebb084990a49c6986135ad79d2adaf54e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 19, 2026.

Transparency log

Security for lampson 0.5.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lampson-0.5.1.tar.gz

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 Oct 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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