| 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() |
|
|