Skip to content

fix: improve playground bot flow#2381

Merged
MaojiaSheng merged 9 commits into
volcengine:mainfrom
yufeng201:fix/playground-route-keys
Jun 2, 2026
Merged

fix: improve playground bot flow#2381
MaojiaSheng merged 9 commits into
volcengine:mainfrom
yufeng201:fix/playground-route-keys

Conversation

@yufeng201
Copy link
Copy Markdown
Contributor

@yufeng201 yufeng201 commented Jun 2, 2026

Description

This PR updates the Web Studio surface into the Playground workflow and improves the bot/chat inspection path.

Backend scope is intentionally limited to bot/vikingbot: it exposes the already-running automatic OpenViking memory lookup through the existing string-based tool_call / tool_result event stream, and reduces the built-in openviking_search default result limit from 20 to 10. The PR does not change openviking retrieval logic, bot API event payload shape, tool execution contracts, identity binding, provenance, or trace data.

Related Issue

N/A

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

  • Rename the Studio route surface to Playground, including navigation labels, route keys, and persisted storage keys.
  • Improve Playground bot/session flow, bot health handling, streaming display, and clickable OpenViking reference rendering.
  • Display automatic OpenViking memory lookup as a real openviking_search tool call/result using the existing stream contract, so the UI shows tool arguments, raw result, and clickable viking:// refs.
  • Keep frontend parsing aligned with the current bot stream contract instead of adding compatibility for new tool_result.success or retrieval trace payloads.
  • Reduce built-in openviking_search default result limit from 20 to 10.

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

Validation performed:

  • git diff --check
  • pnpm -C web-studio exec tsc --noEmit
  • python3 -m py_compile bot/vikingbot/agent/loop.py bot/vikingbot/agent/tools/ov_file.py

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)

N/A

Additional Notes

Relative to main, backend changes are limited to bot/vikingbot/agent/loop.py and bot/vikingbot/agent/tools/ov_file.py. There is no openviking directory diff in the final PR.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

PR Reviewer Guide 🔍

(Review updated until commit d8d1fbe)

Here are some key observations to aid the review process:

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

Sub-PR theme: Backend: Improve bot memory lookup and commit result

Relevant files:

  • bot/vikingbot/agent/tools/ov_file.py
  • bot/vikingbot/agent/memory.py
  • bot/vikingbot/agent/loop.py

Sub-PR theme: Frontend: Rename Studio to Playground and improve UI flow

Relevant files:

  • web-studio/src/**

⚡ Recommended focus areas for review

Potential missing URI collection from structured arrays

The collectStructuredUris function stops recursing into arrays when the parent key is a URI array key (e.g., 'uris', 'added_uris'), even if array items are objects with nested URI fields. This could miss URIs in objects inside URI-named arrays.

function collectStructuredUris(
  value: unknown,
  seen: Set<string>,
  path: string[] = [],
): void {
  if (typeof value === 'string') {
    collectUrisFromText(value, seen)
    return
  }

  if (Array.isArray(value)) {
    const parentKey = path[path.length - 1]
    if (isUriArrayKey(parentKey)) {
      for (const item of value) {
        if (typeof item !== 'string') continue
        const uri = cleanVikingUri(item)
        if (uri) seen.add(uri)
      }
      return
    }

    for (const item of value) collectStructuredUris(item, seen, path)
    return
  }
Redundant memory limiting

The memory search is already limited to 10 results, then _limit_memory_groups is called with the same limit. This is redundant and could be simplified.

    query=current_message,
    user_ids=search_user_ids,
    agent_user_id=admin_user_id,
    limit=10,
)
if not result:
    return ""
result = self._limit_memory_groups(result, limit=10)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Deduplicate URIs with a set to avoid quadratic time complexity

The current implementation uses a linear scan (uri not in modified_uris) to
deduplicate URIs, resulting in O(n²) time complexity. Use a set to track seen URIs
for O(n) deduplication instead.

bot/vikingbot/agent/tools/ov_file.py [557-561]

 added_uris = _uris('adds')
 updated_uris = _uris('updates')
 deleted_uris = _uris('deletes')
+seen = set()
 modified_uris = []
 for uri in [*added_uris, *updated_uris, *deleted_uris]:
-    if uri not in modified_uris:
+    if uri not in seen:
+        seen.add(uri)
         modified_uris.append(uri)
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies a minor performance optimization (switching from O(n²) to O(n) deduplication using a set), which improves code efficiency without changing behavior. The improvement is valid but not critical for functionality.

Low

@yufeng201 yufeng201 force-pushed the fix/playground-route-keys branch from a9b2f45 to 11dfb7b Compare June 2, 2026 07:54
@yufeng201 yufeng201 marked this pull request as ready for review June 2, 2026 08:47
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Persistent review updated to latest commit d8d1fbe

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

PR Code Suggestions ✨

No code suggestions found for the PR.

@MaojiaSheng MaojiaSheng merged commit c9abc2e into volcengine:main Jun 2, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Jun 2, 2026
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