Skip to content

feat(bot):Werewolf demo fix, Add one-click startup script#1473

Merged
qin-ctx merged 5 commits intomainfrom
feature_werewolf_demo
Apr 15, 2026
Merged

feat(bot):Werewolf demo fix, Add one-click startup script#1473
qin-ctx merged 5 commits intomainfrom
feature_werewolf_demo

Conversation

@yeshion23333
Copy link
Copy Markdown
Collaborator

@yeshion23333 yeshion23333 commented Apr 15, 2026

Description


Summary / 概要

本 PR 新增并完善了狼人杀 demo,补齐启动脚本、裁判/玩家 SOUL、后端服务和前端 UI,并支持真人玩家参与。真人模式下,真人可以通过独立面板与 god 私聊或公开发言,且不会泄露其他玩家身份;同时回放能力已整合进主页面。

This PR adds and refines the Werewolf demo, including the startup script, god/player SOUL prompts, backend service, and frontend UI, while also introducing human-player support. In human mode, a real player can interact with god
through a dedicated panel for private or public messages without leaking other players’ identities, and replay is now integrated into the main UI.


Key Changes / 核心改动

  • 新增狼人杀 demo 启动脚本 start_werewolf_demo.py

  • 新增 SOUL-god.md 与 SOUL-player.md,完善裁判与玩家规则

  • 扩展 werewolf_server.py:

    • 支持 human player 模式
    • 支持真人私聊 / 全员广播
    • 修复 loop 提前停止问题
    • 修复结束状态过早显示问题
    • 持久化 game_mode,支持重启恢复
    • 真人模式不计入 leaderboard
  • 重构 werewolfUI.html:

    • 新增真人模式入口和真人交互面板
    • 真人模式下隐藏其他玩家身份与私有信息
    • 优化主界面布局与交互
    • 将 replay 整合到主页面
  • 删除独立 replay.html 页面及 /replay 路由

  • Added the Werewolf demo bootstrap script start_werewolf_demo.py

  • Added SOUL-god.md and SOUL-player.md to define host/player rules

  • Extended werewolf_server.py to:

    • support human-player mode
    • support private human messages and public broadcast
    • fix premature loop termination
    • fix premature game-end display
    • persist game_mode across restarts
    • exclude human games from leaderboard scoring
  • Reworked werewolfUI.html to:

    • add human-mode entry and interaction panel
    • hide other players’ identities/private info in human mode
    • improve main layout and interactions
    • integrate replay into the main page
  • Removed standalone replay.html and the /replay route

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

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

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

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

Sub-PR theme: Add profile_user_list and memory_user to bot channel config

Relevant files:

  • bot/vikingbot/agent/context.py
  • bot/vikingbot/agent/loop.py
  • bot/vikingbot/agent/memory.py
  • bot/vikingbot/config/schema.py

Sub-PR theme: Werewolf demo improvements and startup script

Relevant files:

  • bot/demo/werewolf/werewolf_server.py
  • bot/demo/werewolf/start_werewolf_demo.py
  • bot/demo/werewolf/SOUL-god.md

Sub-PR theme: Add troubleshooting section to locomo benchmark README

Relevant files:

  • benchmark/locomo/README.md

⚡ Recommended focus areas for review

API Compatibility Risk

The signature of build_system_prompt and _build_user_memory changed, removing/renaming parameters. If external code calls these methods directly (unclear if public), this would break. Keep old signatures as deprecated aliases if these are part of the public agent API.

async def build_system_prompt(
    self, session_key: SessionKey, ov_tools_enable: bool = True, profile_user_list: list[str] | None = None
) -> str:
Missing License Header

New Python file added without AGPL-3.0 license header. Add the standard copyright header at the top of the file.

from __future__ import annotations
Unclosed VikingClient

get_viking_user_profiles creates a new VikingClient but does not explicitly close it. This could lead to resource leaks if called frequently. Add a context manager or explicit close for the client.

client = await VikingClient.create(agent_id=workspace_id)

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Ensure VikingClient cleanup

Ensure proper resource cleanup for the VikingClient instance by using an async
context manager (if supported) or explicitly closing it after use. This avoids
potential resource leaks.

bot/vikingbot/agent/memory.py [164-207]

 async def get_viking_user_profiles(self, workspace_id: str, user_ids: list[str]) -> str:
     ...
     client = await VikingClient.create(agent_id=workspace_id)
+    try:
+        async def fetch_profile(user_id: str) -> tuple[str, str]:
+            ...
+        # Fetch all profiles concurrently
+        tasks = [fetch_profile(user_id) for user_id in user_ids]
+        results = await asyncio.gather(*tasks, return_exceptions=True)
+        ...
+    finally:
+        if hasattr(client, "aclose"):
+            await client.aclose()
+        elif hasattr(client, "close"):
+            if asyncio.iscoroutinefunction(client.close):
+                await client.close()
+            else:
+                client.close()
 
-    async def fetch_profile(user_id: str) -> tuple[str, str]:
-        ...
-
Suggestion importance[1-10]: 6

__

Why: Adds proper resource cleanup for the VikingClient instance to avoid potential resource leaks, which is a moderate improvement for code reliability.

Low

@qin-ctx qin-ctx merged commit 5f5e16e into main Apr 15, 2026
5 checks passed
@qin-ctx qin-ctx deleted the feature_werewolf_demo branch April 15, 2026 09:02
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Apr 15, 2026
@yeshion23333 yeshion23333 restored the feature_werewolf_demo branch April 15, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants