Skip to main content

ph-clm

The model edits its own context: tombstone, replace and rewrite sections of what it sees, with every original kept in the log.

After Context Language Models: a model keeps the context it works best with when it may edit that context itself. In pH an edit never rewrites the log. Each one is a surface replace — the mechanism compaction and paste offload already use — so the model's view changes, the log keeps the originals, and the person's transcript still shows the conversation they had.

Sections

The model's context is cut into sections where no tool call is outstanding: a user message, an assistant reply, or an assistant message with every result it asked for. Each is named by the seq of its first event (S412), which never changes, so an id read on one call is good on the next.

Tools

tool does
context_sections the map: each section's id, kind, size, and how much follows it
context_tombstone replace a run of sections with a one-line marker saying why
context_replace replace a run of sections with text the model wrote — a summary, or a rewrite
context_rewrite change one passage inside one section's tool output or reply
context_restore undo a section's latest edit, one level: a rewrite exactly, a removed or replaced run as the text it held
context_recall read back the originals a revised section stands for
context_diff a unified diff of a section against the originals it stands for, after the edits that led there

Every edit reports what it costs: a provider's prefix cache cannot serve anything after the first change, so the sections after an edit are read again once.

Readouts

When a tool result takes the context past a share of its window, that result ends with one line giving the context's size and how to free space. Each share is reported once, and again only after an edit brings the context back below it. The shares are the clm-context row's remindAt, [0.5, 0.75] by default; [] turns readouts off. With compaction mounted, the last reminder comes lastMargin (0.2) below its trigger instead, 65% under the default 0.85, so the model has room to act before a summary is written for it. Under Code Mode the readout spells the call out, keywords and all.

The context file

The clm-mirror row writes the model's context to a file in the agent's workspace scratch before each request, one [[SECTION S<id>]] block per section. The model edits it with whatever it already uses: edit, sed, Python in a cell. When the call that touched the file finishes, its changes land through the same editor the tools use, in one batch, before the call's result. The result carries the receipt.

in the file becomes
a section deleted a tombstone
a tool result's text changed that result rewritten in place
a step's result lines removed the step replaced by the text left
a message's text changed a replacement (a reply is rewritten in place)
no section lines left one replacement for everything editable

A revised section's header line says what it stands for. The text under it is only what the model may edit.

A reorder, a damaged header, an edit to a protected section, or a file written before the context was last revised is refused. The call's result says why, and the file is rewritten.

The file is a whole conversation, so it is kept private and short-lived:

  • its directory is 0700 and the file 0600;
  • it is deleted when the session leaves the store;
  • a link put in its place is replaced, never read through.

Only an edit a tool call makes is applied. A file changed outside any call (in an editor, or by another process) is recorded as declined and rewritten before the next request.

phern --profile rlm-clm

Metadata

Release files for ph-clm 0.10.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 ph-clm 0.10.0
File Size Uploaded Provenance Actions
ph_clm-0.10.0.tar.gz 49.9 kB Without provenance Details for ph_clm-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ph-clm 0.10.0
File Interpreter ABI Platform Actions
ph_clm-0.10.0-py3-none-any.whl Python 3 none any Details for ph_clm-0.10.0-py3-none-any.whl

Total release size: 91.0 kB

Release files / ph_clm-0.10.0.tar.gz

Download URL ph_clm-0.10.0.tar.gz
Size 49.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1196c7ed12224137c0a0900a31aa0c8fe57e8b37322ddc95c8d75b6209bf5f8d
BLAKE2b-256 checksum
How to use checksums
31d7cf8b6e6bae0f890242a91d4ffeccbb1dd1390dcca709a6142e4c1f79da87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ph_clm-0.10.0-py3-none-any.whl

Download URL ph_clm-0.10.0-py3-none-any.whl
Size 41.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36b08f8bbb6a801d30362ca01da7343e2a302a64f07050ae008cee558de0fcc2
BLAKE2b-256 checksum
How to use checksums
fc27224b5f75700326cfb2f2257acd33c9ded7b1c9222637e1df3f1e7ffbebf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for ph-clm 0.10.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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