fix(qq): add LLM-based self-healing for send errors#1560
fix(qq): add LLM-based self-healing for send errors#1560leoleils wants to merge 2 commits intoagentscope-ai:mainfrom
Conversation
- Simplify LLM prompt: just send error info and let LLM decide how to fix - Apply LLM fixing to all QQ send errors (not just content violation) - Token 过期自动刷新重试 - Markdown 问题自动转纯文本 - Remove unused helper functions
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the robustness of the QQ channel's message sending capabilities by introducing self-healing mechanisms. It leverages an LLM to intelligently correct messages that fail to send, automatically refreshes expired API tokens to prevent service interruptions, and improves markdown handling, thereby reducing manual intervention and improving message delivery reliability. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a robust self-healing mechanism for QQ message sending. It adds logic to automatically handle token expiration by refreshing the token and retrying, and it leverages an LLM to fix message content for other types of send errors. The implementation is logical and enhances the reliability of the QQ channel. My review includes one suggestion to improve code readability in an error logging statement.
| logger.warning( | ||
| "QQ send failed (%s), trying LLM to fix", | ||
| error_info.get("err_code") or error_info.get("code", "unknown") | ||
| if isinstance(error_info, dict) | ||
| else str(exc)[:50], | ||
| ) |
There was a problem hiding this comment.
The conditional expression to determine the error code for logging is quite complex and embedded within the logger.warning call, which makes it difficult to read and understand at a glance. For better readability and maintainability, consider extracting this logic into a separate variable before the logging call.
| logger.warning( | |
| "QQ send failed (%s), trying LLM to fix", | |
| error_info.get("err_code") or error_info.get("code", "unknown") | |
| if isinstance(error_info, dict) | |
| else str(exc)[:50], | |
| ) | |
| if isinstance(error_info, dict): | |
| err_code = error_info.get("err_code") or error_info.get("code", "unknown") | |
| else: | |
| err_code = str(exc)[:50] | |
| logger.warning( | |
| "QQ send failed (%s), trying LLM to fix", | |
| err_code, | |
| ) |
Extract complex conditional expression into separate variable for better readability. Addresses review feedback from PR agentscope-ai#1560.
Description
[Describe what this PR does and why]
Related Issue: Fixes #(issue_number) or Relates to #(issue_number)
Security Considerations: [If applicable, e.g. channel auth, env/config handling]
Type of Change
Component(s) Affected
Checklist
pre-commit run --all-fileslocally and it passespytestor as relevant) and they passTesting
[How to test these changes]
Local Verification Evidence
Additional Notes
[Optional: any other context]