Skip to content

Fix/feishu reaction feedback#2157

Open
myysy wants to merge 6 commits into
mainfrom
fix/feishu-reaction-feedback
Open

Fix/feishu reaction feedback#2157
myysy wants to merge 6 commits into
mainfrom
fix/feishu-reaction-feedback

Conversation

@myysy
Copy link
Copy Markdown
Collaborator

@myysy myysy commented May 21, 2026

Description

Improve visibility and accounting for Feishu reaction-based feedback in vikingbot.
This PR makes Feishu reaction feedback easier to diagnose by adding explicit runtime logs around reaction event registration, receipt, filtering, deduplication, storage, and session matching. It also updates feedback stats so responses tracked via response_facts are counted as tracked responses even when no feedback has been received yet. Documentation is updated to clarify the required Feishu event subscription for reaction feedback, and the demo Grafana dashboard now defaults to a relative time range.

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Add detailed Feishu reaction feedback logs for SDK registration, event intake, invalid event filtering, dedup hits, successful persistence, and failed session lookup paths.
  • Count metadata.response_facts entries as tracked responses in feedback statistics so coverage metrics reflect tracked assistant responses even before feedback arrives.
  • Add a regression test covering tracked-response counting from response_facts.
  • Update Feishu channel documentation to explicitly require the im.message.reaction.created_v1 event subscription for reaction-based feedback metrics.
  • Change the demo Grafana dashboard default time range from a fixed timestamp window to now-1h through now.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Additional Notes

  • No related issue is linked in this PR body.
  • Local full test execution was not run as part of this change set.

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🏅 Score: 90
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 Multiple PR themes

Sub-PR theme: Feishu reaction feedback support

Relevant files:

  • bot/vikingbot/channels/feishu.py
  • bot/tests/test_feishu_feedback.py
  • bot/docs/CHANNEL.md
  • bot/docs/vikingbot-phase2-feedback-validation-with-openviking-server.md

Sub-PR theme: Natural language feedback detection

Relevant files:

  • bot/vikingbot/agent/loop.py
  • bot/vikingbot/observability/outcome.py
  • bot/tests/test_agent_loop_outcome.py
  • bot/tests/test_outcome_evaluator.py
  • docs/zh/guides/12-vikingbot-metrics-validation.md

Sub-PR theme: Tracked responses from response_facts

Relevant files:

  • bot/vikingbot/observability/feedback_stats.py
  • bot/tests/test_feedback_stats.py

Sub-PR theme: Grafana dashboard default time range

Relevant files:

  • examples/grafana/openviking_demo_dashboard.json

⚡ Recommended focus areas for review

Suggestion: Add JSON repair for LLM feedback classifier output

The LLM feedback classifier parses raw JSON output with json.loads without fallback repair. While the prompt asks for valid JSON, models occasionally return slightly malformed output (e.g., extra text, trailing commas). Adding a JSON repair step here would improve robustness.

try:
    payload = json.loads(text)
except json.JSONDecodeError:
    logger.warning("LLM feedback classification returned non-JSON content")
    return None
Performance Note: Full session scan for reaction feedback fallback

When a Feishu reaction event lacks chat context, the code scans all sessions for the channel to find the matching platform_message_id. For deployments with many sessions, this could become slow. Consider adding an index or limiting the scan to recent sessions.

for session_info in self._session_manager.list_sessions():
    session_key = session_info.get("key")
    if not isinstance(session_key, SessionKey):
        continue
    if session_key.type != str(getattr(self.channel_type, "value", self.channel_type)):
        continue
    if session_key.channel_id != self.channel_id:
        continue

    try:
        session, feedback_update = await self._session_manager.update_session(
            session_key,
            lambda session: self._apply_reaction_feedback(
                session,
                session_key=session_key,
                platform_message_id=platform_message_id,
                user_id=user_id,
                emoji_type=emoji_type,
                feedback_type=feedback_type,
            ),
            skip_heartbeat=True,
        )
    except LookupError:
        continue

    if feedback_update is None:
        logger.info(
            "Feishu reaction deduped by message lookup for session={} message_id={} user_id={} feedback_type={}",
            session_key.safe_name(),
            platform_message_id,
            user_id,
            feedback_type,
        )
        return

    logger.info(
        "Feishu reaction stored by message lookup for session={} message_id={} user_id={} feedback_type={}",
        session_key.safe_name(),
        platform_message_id,
        user_id,
        feedback_type,
    )
    await self._publish_reaction_feedback_update(session, feedback_update)
    return

logger.info(

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant