Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
49 lines
2.4 KiB
Python
49 lines
2.4 KiB
Python
import json
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from agent import ReferenceAgent
|
|
from harness import LongitudinalEvaluator
|
|
|
|
|
|
TASKS = json.loads(Path(__file__).with_name("dataset.json").read_text(encoding="utf-8"))["tasks"]
|
|
|
|
|
|
class LongitudinalEvaluationTest(unittest.TestCase):
|
|
def test_evolving_agent_transfers_updates_and_retains(self):
|
|
report = LongitudinalEvaluator().run(ReferenceAgent("evolving"), TASKS)
|
|
self.assertEqual(1.0, report["transfer_accuracy"])
|
|
self.assertEqual(1, report["adaptation"]["tasks_after_change_signal_to_recover"])
|
|
self.assertEqual(1.0, report["retention_rate"])
|
|
self.assertGreater(report["cost"]["storage_bytes"], 0)
|
|
|
|
def test_append_only_agent_cannot_replace_changed_rule(self):
|
|
report = LongitudinalEvaluator().run(ReferenceAgent("append_only"), TASKS)
|
|
self.assertEqual(0.0, report["phase_accuracy"]["change"])
|
|
self.assertLess(report["retention_rate"], 1.0)
|
|
self.assertGreater(report["negative_transfer_rate"], 0.0)
|
|
|
|
def test_static_agent_does_not_look_like_continual_learning(self):
|
|
report = LongitudinalEvaluator().run(ReferenceAgent("static"), TASKS)
|
|
self.assertEqual(0.0, report["transfer_accuracy"])
|
|
self.assertEqual(0, report["cost"]["storage_bytes"])
|
|
|
|
def test_all_four_phases_are_reported(self):
|
|
report = LongitudinalEvaluator().run(ReferenceAgent("evolving"), TASKS)
|
|
self.assertEqual({"learning", "transfer", "change", "retention"}, set(report["phase_accuracy"]))
|
|
self.assertEqual(6, len(report["learning_curve"]))
|
|
|
|
def test_replacement_and_update_activation_are_separate_metrics(self):
|
|
evolving = LongitudinalEvaluator().run(ReferenceAgent("evolving"), TASKS)
|
|
append_only = LongitudinalEvaluator().run(ReferenceAgent("append_only"), TASKS)
|
|
self.assertEqual(1.0, evolving["replacement"]["rule_replacement_accuracy"])
|
|
self.assertEqual(0.0, evolving["replacement"]["obsolete_rule_reference_rate"])
|
|
self.assertEqual(0.0, append_only["replacement"]["rule_replacement_accuracy"])
|
|
self.assertEqual(1.0, append_only["replacement"]["obsolete_rule_reference_rate"])
|
|
self.assertEqual(1.0, evolving["update_metrics"]["artifact_activation_rate"])
|
|
self.assertEqual(1.0, evolving["update_metrics"]["memory_adherence_rate"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|