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
| Flag | Module | Effect |
|---|---|---|
AION_HARNESS_V2_MESSAGES | src/runtime/messages/ | Two-layer transcript → convert_to_llm() |
AION_HARNESS_V2_INJECTIONS | src/runtime/context_builder.py | LTM/nudge/hooks as XML injection layers, not fake user text |
AION_HARNESS_V2_COMPACTION | src/runtime/compaction/ | Valid cut points (never split tool pairs) |
AION_HARNESS_V2_PROVIDER | src/runtime/provider_adapter.py | Unified stream chunk + generation kwargs merge |
AION_HARNESS_V2_TOOLS | src/runtime/tool_protocol.py | Skip tool execution after finish_reason=length |
AION_HARNESS_V2_TURN | src/runtime/turn/model.py | Explicit input message count instead of object-identity slicing |
Phase 0 quick wins (always on unless overridden)
| Variable | Default | Notes |
|---|---|---|
AION_CONTEXT_COMPRESS_MID_TURN_REASONING | 0 | No sync compaction on every reasoning chunk |
AION_CONTEXT_COMPRESS_MID_TURN_SYNC | 0 | Mid-turn LLM summarization off on agent thread |
AION_CONTEXT_COMPRESS_MID_TURN_RATIO | 0.92 | Higher bar before mid-turn compact |
AION_STREAM_LOOP_LEGACY | 0 | StreamLoop 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.