Skip to main content

Harness v2 (Pi-inspired patterns)

The "harness" is the code around the language model that decides what goes into its context on each turn: which messages, which injected memory or hints, and how old history is compacted. Harness v2 is a set of optional improvements to that code, each behind its own feature flag, so they can be rolled out one at a time. This page lists the flags and their effect; it is for developers working on the agent runtime.

AION keeps Haystack as the agent runtime. Harness v2 ports context-shaping patterns from Pi without replacing the Python stack.

All flags default to off for safe rollout. Enable incrementally and run the focused pytest modules under src/test/test_aion_* and src/test/test_*_policy.py.

Feature flags​

FlagModuleEffect
AION_HARNESS_V2_MESSAGESsrc/runtime/messages/Two-layer transcript → convert_to_llm()
AION_HARNESS_V2_INJECTIONSsrc/runtime/context_builder.pyLTM/nudge/hooks as XML injection layers, not fake user text
AION_HARNESS_V2_COMPACTIONsrc/runtime/compaction/Valid cut points (never split tool pairs)
AION_HARNESS_V2_PROVIDERsrc/runtime/provider_adapter.pyUnified stream chunk + generation kwargs merge
AION_HARNESS_V2_TOOLSsrc/runtime/tool_protocol.pySkip tool execution after finish_reason=length
AION_HARNESS_V2_TURNsrc/runtime/turn/model.pyExplicit input message count instead of object-identity slicing

Phase 0 quick wins (always on unless overridden)​

VariableDefaultNotes
AION_CONTEXT_COMPRESS_MID_TURN_REASONING0No sync compaction on every reasoning chunk
AION_CONTEXT_COMPRESS_MID_TURN_SYNC0Mid-turn LLM summarization off on agent thread
AION_CONTEXT_COMPRESS_MID_TURN_RATIO0.92Higher bar before mid-turn compact
AION_STREAM_LOOP_LEGACY0StreamLoop v2 is default

Compaction summaries use Pi-style <summary> blocks via format_compaction_block() in context_compressor.py.

Architecture sketch​

Out of scope​

Fase 7 (native Python agent loop / Haystack removal) is not part of this harness. See the main agent pipeline docs for the current Haystack integration.