Skip to main content

pi-agent-harness-lc (pi_agent_harness)

PyPI Python License

pi-agent-harness-lc (pi_agent_harness) is the higher-level harness runtime package for pi-agent-core-lc, corresponding to packages/agent/src/harness in the pi project (unofficial Python port).

What it provides

It contains the Phase 3 runtime pieces that are intentionally kept outside the lightweight core loop:

  • AgentHarness — stateful session runtime coordinating hooks, steering/follow-up queues, tool execution gating, model/thinking changes, and persistence
  • Session tree storage & repositories — append-only JSONL and in-memory session stores (Session, JsonlSessionStorage, DeferredJsonlSessionStorage, MemorySessionStorage, JsonlSessionRepo, MemorySessionRepo, build_session_context)
  • Compaction & tree navigation — context compaction (CompactionSettings, CompactionPreparation, CompactionResult), branch summaries, leaf/tree switching, and optional auto-compaction
  • Harness-specific custom messages — extensible AgentMessageProtocol and built-in custom message roles with LLM boundary conversion (harness_convert_to_llm)
  • Skills, prompt templates & system prompt assembly — load_skills, format_skills_for_system_prompt, load_prompt_templates, build_harness_system_prompt
  • Execution environment — ExecutionEnv protocol and LocalExecutionEnv (filesystem + shell abstraction)

Install

Install alongside core:

pip install pi-agent-core-lc pi-agent-harness-lc

For local development from the monorepo:

pip install -e ".[dev]" -e "./packages/pi-agent-harness"
uv run --extra dev --extra harness python -m pytest

Custom messages

AgentMessage is structurally open: anything with a string role flows through the loop and persists to the session (AgentMessageProtocol, a runtime-checkable Protocol in pi_agent_harness). The harness ships four custom roles — bashExecution, custom, branchSummary, compactionSummary — and harness_convert_to_llm decides how each role reaches the LLM; unknown roles are dropped at that boundary:

from pydantic import BaseModel
from pi_agent_harness import AgentMessageProtocol
from pi_agent_harness.messages import BashExecutionMessage, harness_convert_to_llm

# Built-in custom role: record a shell run in the session/context
bash = BashExecutionMessage(command="pytest -q", output="97 passed", exitCode=0, timestamp=0)
await harness.append_message(bash)  # persisted; replayed to the LLM as a user message


# Your own role: any object with `role: str` satisfies the protocol
class DeployNote(BaseModel):
    role: str = "deployNote"
    environment: str
    timestamp: int


assert isinstance(DeployNote(environment="staging", timestamp=0), AgentMessageProtocol)

To make a custom role visible to the LLM, wrap harness_convert_to_llm (or pass your own convert_to_llm to the core loop) and map it to a UserMessage — the same pattern the harness uses for its own roles.

Metadata

Release files for pi-agent-harness-lc 1.1.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 pi-agent-harness-lc 1.1.0
File Size Uploaded Provenance Actions
pi_agent_harness_lc-1.1.0.tar.gz 92.6 kB Without provenance Details for pi_agent_harness_lc-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pi-agent-harness-lc 1.1.0
File Interpreter ABI Platform Actions
pi_agent_harness_lc-1.1.0-py3-none-any.whl Python 3 none any Details for pi_agent_harness_lc-1.1.0-py3-none-any.whl

Total release size: 150.9 kB

Release files / pi_agent_harness_lc-1.1.0.tar.gz

Download URL pi_agent_harness_lc-1.1.0.tar.gz
Size 92.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a8f7f7a13ce36fe7026f821d8feb54b99ab81b270511f48b68041ec3d50127a6
BLAKE2b-256 checksum
How to use checksums
5720b511d3536f45e8cab810a6394d53af4feca635f7ed8bd6857e0abd63d524
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pi_agent_harness_lc-1.1.0-py3-none-any.whl

Download URL pi_agent_harness_lc-1.1.0-py3-none-any.whl
Size 58.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57e259437e1e4beb1e78cf34e7df48d6932a650de9d53020345eb4aba1d23218
BLAKE2b-256 checksum
How to use checksums
89165c77189f2c3c44e42ec46983f557ed5d593d0cd50dd3308be95509f8247d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pi-agent-harness-lc 1.1.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