Skip to Content

Recursive Agent Harness² & Evolution

The Agent SDK features Recursive Agent Harness² (Harness²)—an autonomous dual-level self-improvement architecture that adapts agent scaffolding at runtime without retraining base model weights, coupled with Agent Lightning for long-term reinforcement learning.

Overview

Traditional agent development relies on manual prompt tuning or static harnesses. When models change or edge-case errors occur, developers must inspect traces and hand-craft new rules.

Harness² solves this through Dual-Level Recursion:

  1. Task-Level Recursion (Inner Loop / Fast Loop):
    • Evaluates failed execution traces.
    • Diagnoses which of the 8 required harness components failed.
    • Proposes targeted harness modifications and probes them in sandboxed environments.
    • Composes verified improvements into an updated execution harness.
  2. Harnessing-Level Recursion (Outer Loop / Slow Loop):
    • Retains causal diagnostics in Self-Improvement Memory (SIM).
    • Ensures cross-model transferability (lessons survive when switching between Claude, Gemini, and GPT).
    • Feeds contrastive rollout pairs into isA_Model Lightning training (DPO/GRPO).

The 8 Harness Components

In isA_Agent_SDK, every agent execution substrate is governed by a versioned HarnessManifest. No editable component may be implicit:

ComponentResponsibility
system_promptBase role instructions and invariant rules
tool_policyStructural tool constraints, required prerequisites, and parameter bounds
middlewareRequest preprocessing, context pruning, and token management
model_routingProvider selection, fallback order, and failover triggers
memory_policyRetention thresholds, compaction limits, and SIM priming rules
loop_policyIteration limits, cycle detection, and timeout budgets
verification_policyOutput validation contracts and independent reviewer gates
delegation_policySubagent spawning permissions, authority boundaries, and budget handover

Quickstart: Recursive Synthesis

Use the RecursiveHarnessSynthesizer to automatically propose and probe harness patches when errors occur:

from isa_agent_sdk.evolution.harness import ( HarnessManifest, HarnessComponent, HarnessExperimentRunner, HarnessPromotionController, HarnessExperimentPolicy, ) from isa_agent_sdk.evolution._harness_synthesizer import RecursiveHarnessSynthesizer from isa_agent_sdk.memory.sim import ( SelfImprovementMemory, CausalFailureLog, FailureCategory, ) # 1. Initialize SIM and the Recursive Synthesizer sim_store = SelfImprovementMemory( backend="sqlite", connection_string="sqlite+aiosqlite:///sim_store.db" ) synthesizer = RecursiveHarnessSynthesizer( sim_store=sim_store, max_probe_cases=5, probe_timeout_seconds=30.0, ) # 2. Synthesize candidate proposal from a detected failure diagnostic = CausalFailureLog( session_id="session-402", failure_category=FailureCategory.TOOL_SCHEMA_MISMATCH, component_kind="tool_policy", root_cause="Tool 'query_sql' called with unquoted table name containing hyphens", remedy={"table_name_quote": True}, ) # 3. Propose and probe in sandboxed test cases proposal = await synthesizer.propose_and_probe( diagnostic=diagnostic, baseline_manifest=current_manifest, test_suite=eval_cases, ) if proposal and proposal.is_verified: print(f"Synthesized candidate manifest: {proposal.candidate.ref}")

Sandbox Probing & Safety Bounds

To prevent runaway self-mutation or excessive token consumption, HarnessExperimentRunner enforces strict deterministic bounds:

policy = HarnessExperimentPolicy( max_probe_cases=5, # Ceiling on test cases per probe probe_timeout_seconds=30.0, # Hard timeout ceiling per probe minimum_verification_rate=0.95, # Minimum verification pass rate allow_safety_regression=False, # Zero tolerance for safety failures require_predictions_met=True, # Falsifiable hypothesis must hold )

Cryptographic Manifest Trust & Signing

Self-improving manifests cannot bypass enterprise security policies. Before a candidate manifest can enter production:

  1. It must pass all evaluation suite gates.
  2. It must be packaged with a HarnessManifestEnvelope signed by an external KMS Ed25519 authority key.
  3. The runtime verifies the signature and records atomic consumption (consumed_at IS NULL) to prevent replay attacks.

Verify a manifest package via the CLI:

python -m isa_agent_sdk.cli verify-harness-manifest \ --envelope promoted-harness.json \ --trust-policy /run/secrets/harness-trust-roots.json

Integration with isA_Model Lightning

When a task fails and is subsequently remedied by a probe, the SDK emits a Contrastive Rollout Pair:

  • Rejected Rollout: The trace of the run that failed.
  • Accepted Rollout: The probe-verified trace that succeeded.

The isA_Model Lightning training service ingests these pairs through SIMPreferenceConverter:

from isa_model.training.lightning.sim_preference_converter import SIMPreferenceConverter converter = SIMPreferenceConverter() dpo_dataset = converter.convert_contrastive_pairs( contrastive_pairs=sim_contrastive_rollouts, algorithm="dpo", # or "grpo" )

This closes the loop: immediate errors are resolved in minutes via the SDK’s peripheral harness (Fast Loop), while underlying model weights are continuously fine-tuned via offline RL (Slow Loop).

Was this page helpful?