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. It needs Node.js: it uses the `lampson` command if
# installed, else `npx lampson@<this version>` (fetched once)
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()

Another Lampson for local mode: local={"workspace": ..., "command": ["node", "node_modules/lampson/bin/lampson.js"]}. A relative path there is resolved against your app's directory, not the workspace.

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"})   # from_: `from` is a keyword

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.3

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.3
File Size Uploaded Provenance Actions
lampson-0.5.3.tar.gz 14.0 kB With provenance Details for lampson-0.5.3.tar.gz

Built distribution (wheel)

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

Total release size: 27.2 kB

Release files / lampson-0.5.3.tar.gz

Download URL lampson-0.5.3.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3a05797bd42270347256bcb6e49b7534e5b3f2a2440f816382db7dd8c41e868b
BLAKE2b-256 checksum
How to use checksums
4c0b4bfb4ee26410ab2aa004ecbe2090488fcc6fe98aae418884f8795557a2dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 25, 2026.

Transparency log

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

Download URL lampson-0.5.3-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1b42984550c8fc6c08dcdd272389697917b4427720e6c695e64c313f0edba87
BLAKE2b-256 checksum
How to use checksums
1804ef03a01f3accdbd2c3f20a3af185c0b28f844c54035dfa29be9d13a28258
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 25, 2026.

Transparency log

Security for lampson 0.5.3

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.3.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 25, 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