qwen_agent/skills/developing/user-context-loader/hooks/post_agent.py
朱潮 425f3c5bb4 chore: replace Chinese comments and log messages with English
Convert all Chinese comments, docstrings, logger/print output,
HTTPException detail messages, and API response messages to English
across the entire codebase. Functional zh/ja localized strings
(e.g. prompt templates, timezone display names, date formats) are
preserved as-is.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-30 19:45:35 +08:00

34 lines
1.0 KiB
Python

#!/usr/bin/env python3
"""
PostAgent Hook - Post-response processing example
Executed after the agent finishes; can be used to record analytics data,
trigger follow-up workflows, etc.
"""
import os
import sys
def main():
"""Read parameters from environment variables and process them."""
response = os.environ.get('RESPONSE', '')
metadata = os.environ.get('METADATA', '')
user_identifier = os.environ.get('USER_IDENTIFIER', '')
session_id = os.environ.get('SESSION_ID', '')
# Example: record response length for analytics
if response:
response_length = len(response)
print(f"PostAgent hook: User={user_identifier}, Session={session_id}, Response Length={response_length}", file=sys.stderr)
# Additional logic can be added here, such as:
# - Sending analytics data to a monitoring system
# - Triggering async tasks (e.g., sending notification emails)
# - Recording user behavior for personalized recommendations
return 0
if __name__ == '__main__':
sys.exit(main())