Files
librefang-registry/plugins/echo-memory/hooks/after_turn.py
T
2026-03-21 01:57:04 +09:00

28 lines
642 B
Python

#!/usr/bin/env python3
"""Echo memory after_turn hook — demo plugin.
Logs the number of messages in the conversation after each turn.
Receives via stdin:
{"type": "after_turn", "agent_id": "...", "messages": [...]}
Prints to stdout:
{"type": "ok"}
"""
import json
import sys
def main():
request = json.loads(sys.stdin.read())
agent_id = request.get("agent_id", "unknown")
messages = request.get("messages", [])
# In a real plugin you might update an index or persist state here.
# For this demo we just acknowledge.
print(json.dumps({"type": "ok"}), flush=True)
if __name__ == "__main__":
main()