File size: 1,371 Bytes
e13493c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import json
import sys
PROTOCOL = "mnemosyne-external-strategy/v1"
def main():
request = json.loads(sys.stdin.readline())
if request.get("protocol_version") != PROTOCOL:
raise ValueError("unsupported protocol")
observations = request.get("observations", [])
current = observations[-1]["content"] if observations else None
result = {
"protocol_version": PROTOCOL,
"run_id": request["run_id"],
"strategy_id": "example_python",
"scenario_id": request["scenario_id"],
"current_answer": current,
"historical_answer": None,
"abstained": not bool(observations),
"confidence": 0.5 if observations else 0.0,
"recalled_records": [o["observation_id"] for o in observations[-4:]],
"selected_context": [o["content"] for o in observations[-4:]],
"lifecycle_actions": [],
"promotion_actions": [],
"evidence_families_counted": sorted({o["evidence_family_id"] for o in observations[-4:]}),
"active_memory_ids": [],
"superseded_memory_ids": [],
"explanation": "Selected the most recent bounded observations; no evaluator labels were used.",
"warnings": ["demonstration adapter; not a production memory strategy"],
}
sys.stdout.write(json.dumps(result, sort_keys=True) + "\n")
if __name__ == "__main__":
main()
|