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.0.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 pi-agent-harness-lc 1.0.1
File Size Uploaded Provenance Actions
pi_agent_harness_lc-1.0.1.tar.gz 87.8 kB Without provenance Details for pi_agent_harness_lc-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 143.9 kB

Release files / pi_agent_harness_lc-1.0.1.tar.gz

Download URL pi_agent_harness_lc-1.0.1.tar.gz
Size 87.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e7d7a21474c7d702254d6f9ac5104f7e86b964751a76ae67fa5fce9818ecd2c4
BLAKE2b-256 checksum
How to use checksums
3a37a386595ed818043aa66944f472a31da60d24845e0e18cd1aeb65a52ec0f5
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.0.1-py3-none-any.whl

Download URL pi_agent_harness_lc-1.0.1-py3-none-any.whl
Size 56.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f3c2f91b3b3b57561398819c5c11dcda5834e1ae08f5b7d03ae903769b5a410
BLAKE2b-256 checksum
How to use checksums
20c1bf006dee5408d66bdc6a82b776e2e31a5f9ab62517120040a7cf6a8413ab
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.0.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.

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