Halo adapter for Claude on two runtimes (Python): the Agent SDK (install_halo — a PostToolUse encode hook + a single in-process halo_fetch MCP tool) and the raw Messages API (halo_format_claude.raw — create_raw_halo, no Agent SDK needed). Tool results become a shape map kept out of context.
Project description
halo-format-claude
Halo adapter for Claude on two runtimes (Python): the Claude Agent SDK and the raw Claude Messages API. Same engine — encode a large tool result, hand the model a shape map, let it pull back only the leaves it needs, verified on read — bound to whichever loop you run.
Agent SDK — install_halo()
install_halo() wires the adapter in one call (install the Agent SDK extra:
pip install halo-format-claude[agent-sdk]):
- a PostToolUse encode hook that replaces a large tool result with a halo shape map (root kind + one line per field: ref, kind, and a bounded preview), so the payload stays out of the model's context while it still sees what's there;
- a single in-process
halo_fetchMCP tool the model uses to pull back only the leaves it needs, verified on read — a ref that lands on a branch returns that branch's sub-refs, so one batch API both pulls and expands (there is no separatehalo_walk).
from claude_agent_sdk import ClaudeAgentOptions, query
from halo_format_claude import install_halo
result = install_halo(ClaudeAgentOptions(...))
# pass result.options to query(); result.session holds the shared store for audit/inspection
The encode hook is deterministic plumbing (it always fires, even for built-in tools); the Halo Skill
is the navigation guidance. Pass store=FileStore(dir) for the heavy/persistent deployment.
Raw Messages API — halo_format_claude.raw
No hook exists on the raw API — you own the tool-use loop on messages.create(...). create_raw_halo()
gives you the same mechanism to drive by hand. This submodule imports zero Agent SDK code (the
package imports the SDK lazily), so pip install halo-format-claude without the agent-sdk extra is
enough for the raw path. This is the runtime where Halo's token win is largest: the raw API re-sends
every tool result in context each turn, so keeping a heavy payload out of context is a real, growing
saving.
import json
from anthropic import Anthropic
from halo_format_claude.raw import create_raw_halo
halo = create_raw_halo(threshold=2048)
tools = [*domain_tools, halo.tool_def] # add the halo_fetch tool
system = SYSTEM_PROMPT + halo.guidance # add the navigation guidance
# inside your loop, per tool_use block:
async def run_tool(name, args):
if halo.is_fetch(name):
return halo.fetch(args["refs"]) # verified leaves; never re-encode
result = await dispatch[name](**args)
return halo.encode_result(name, args, result) # shape map if large, else passthrough
encode_result size-gates (shape map above the threshold, raw JSON below); fetch returns the
verified per-ref results as a JSON string for the tool_result content. The core engine is
halo-format; this package is only the shim that binds it to
the two Claude runtimes.
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
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 halo_format_claude-0.2.0.tar.gz.
File metadata
- Download URL: halo_format_claude-0.2.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e4e893f59b45f59e682aa8e76b90ed5f0b29fe915aaaf4fa6e0d27d12069d43
|
|
| MD5 |
2967c306f007db2743d755bcb527701f
|
|
| BLAKE2b-256 |
19e64418a08ba308aa3ef89bb356b202a09620fe727dee1fa80069a2306130d4
|
Provenance
The following attestation bundles were made for halo_format_claude-0.2.0.tar.gz:
Publisher:
publish-python-claude.yml on halo-format/halo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
halo_format_claude-0.2.0.tar.gz -
Subject digest:
2e4e893f59b45f59e682aa8e76b90ed5f0b29fe915aaaf4fa6e0d27d12069d43 - Sigstore transparency entry: 1739573321
- Sigstore integration time:
-
Permalink:
halo-format/halo@037715e7631663c0e70c9b950909efc0cc825c7c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/halo-format
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-claude.yml@037715e7631663c0e70c9b950909efc0cc825c7c -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file halo_format_claude-0.2.0-py3-none-any.whl.
File metadata
- Download URL: halo_format_claude-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c71d9b5bce23bc7dc4f22100bb8ada9de85ad28b694132f28ebcab249aafa130
|
|
| MD5 |
92a8a57317b0add397e723c1583f1b36
|
|
| BLAKE2b-256 |
16fad8cb23fbe009212b108fb590b5461c0c06f32133a46314e95cd57a288185
|
Provenance
The following attestation bundles were made for halo_format_claude-0.2.0-py3-none-any.whl:
Publisher:
publish-python-claude.yml on halo-format/halo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
halo_format_claude-0.2.0-py3-none-any.whl -
Subject digest:
c71d9b5bce23bc7dc4f22100bb8ada9de85ad28b694132f28ebcab249aafa130 - Sigstore transparency entry: 1739573323
- Sigstore integration time:
-
Permalink:
halo-format/halo@037715e7631663c0e70c9b950909efc0cc825c7c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/halo-format
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-claude.yml@037715e7631663c0e70c9b950909efc0cc825c7c -
Trigger Event:
workflow_run
-
Statement type: