hermes - ✅(Solved) Fix [Bug]: openviking plugin — viking_read returns 500 for file URIs on abstract/overview levels [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#12755Fetched 2026-04-20 12:17:06
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
referenced ×3cross-referenced ×2

Error Message

  • /api/v1/content/abstract — only accepts directory URIs → file URIs return {"error": {"code": "INTERNAL"}}
  • /api/v1/content/overview — only accepts directory URIs → file URIs return {"error": {"code": "INTERNAL"}} Actual: 500 Internal Server Error

Root Cause

Root cause confirmed by API testing:

  • /api/v1/content/abstract — only accepts directory URIs → file URIs return {"error": {"code": "INTERNAL"}}
  • /api/v1/content/overview — only accepts directory URIs → file URIs return {"error": {"code": "INTERNAL"}}
  • /api/v1/content/download — only accepts file URIs → directory URIs return a non-JSON response

Fix Action

Fix

Before calling an endpoint, determine URI type via fs/stat (isDir field), then route:

  • file/api/v1/content/download
  • directory + abstract/api/v1/content/abstract
  • directory + overview/api/v1/content/overview

Or migrate to the official SDK which handles this dispatch internally.

PR fix notes

PR #12757: fix(openviking): route viking_read to correct endpoint for file URIs

Description (problem / solution / changelog)

Summary

viking_read called /content/abstract and /content/overview for ALL URIs, but these endpoints only accept directory URIs — file URIs cause HTTP 500.

Fix

Before routing, call fs/stat to check isDir, then:

URI typeLevelEndpoint
directoryabstract/overview/full/content/abstract|overview|read
fileany/content/read

/content/read handles both file and directory types, unlike abstract/overview which are directory-only.

Verification

# File URI — was 500, now 200
GET /content/read?uri=viking://user/default/memories/events/mem_xxx.md
→ 200 OK, result: "用户发送了一条带有..."

# Directory URI — unchanged
GET /content/overview?uri=viking://user/default/memories/events/
→ 200 OK, overview with navigation structure

Testing

See reproduction in #12755.

Fixes #12755

Changed files

  • plugins/memory/openviking/__init__.py (modified, +20/-6)

PR #12937: fix(openviking): viking_read fails on file URIs — route to /content/read

Description (problem / solution / changelog)

Summary

viking_read routes file URIs to /api/v1/content/abstract and /api/v1/content/overview, but these endpoints only accept directory URIs, causing all file-level reads to return 412 Precondition Failed.

Root Cause

OpenViking API endpoint design:

  • /api/v1/content/abstract — accepts directory URIs only
  • /api/v1/content/overview — accepts directory URIs only
  • /api/v1/content/read — accepts file URIs only

The original code did not distinguish between URI types, so file URIs with level=abstract|overview always hit 412.

Fix

  1. Add _is_directory() method to detect URI type via /api/v1/fs/stat
  2. File URIs → route to /api/v1/content/read (ignore level parameter)
  3. Directory URIs → route to /content/abstract or /content/overview by level

Test Plan

  • File URI + level=abstract → calls /content/read, returns file content
  • File URI + level=overview → calls /content/read, returns file content
  • Directory URI + level=overview → calls /content/overview, returns directory summary

Closes #4740 Closes #10124 Closes #12755

Changed files

  • plugins/memory/openviking/__init__.py (modified, +25/-6)

Code Example

{
  "uri": "viking://user/default/memories/events/mem_cf3e006a-5cdf-4680-b8ec-aa9cf3676426.md",
  "level": "abstract"
}

---

if level == "abstract":
    resp = self._client.get("/api/v1/content/abstract", params={"uri": uri})  # ← directory-only
elif level == "full":
    resp = self._client.get("/api/v1/content/read", params={"uri": uri})
else:  # overview
    resp = self._client.get("/api/v1/content/overview", params={"uri": uri})  # ← directory-only
RAW_BUFFERClick to expand / collapse

Bug Description

The viking_read tool in the openviking memory plugin returns HTTP 500 when reading file URIs at abstract or overview detail levels.

Root cause confirmed by API testing:

  • /api/v1/content/abstract — only accepts directory URIs → file URIs return {"error": {"code": "INTERNAL"}}
  • /api/v1/content/overview — only accepts directory URIs → file URIs return {"error": {"code": "INTERNAL"}}
  • /api/v1/content/download — only accepts file URIs → directory URIs return a non-JSON response

The plugin routes ALL URIs through abstract and overview regardless of type, but these endpoints are directory-only. File content must go through /api/v1/content/download.

Steps to Reproduce

{
  "uri": "viking://user/default/memories/events/mem_cf3e006a-5cdf-4680-b8ec-aa9cf3676426.md",
  "level": "abstract"
}

Expected: ~100 token abstract of the file
Actual: 500 Internal Server Error

Verified API Behavior

EndpointDirectory URIFile URI
GET /content/abstract✅ 200 OK❌ 500 INTERNAL
GET /content/overview✅ 200 OK❌ 500 INTERNAL
GET /content/download❌ non-JSON✅ 200 (raw content)

Code Location

plugins/memory/openviking/__init__.py, _tool_read() lines 573–599:

if level == "abstract":
    resp = self._client.get("/api/v1/content/abstract", params={"uri": uri})  # ← directory-only
elif level == "full":
    resp = self._client.get("/api/v1/content/read", params={"uri": uri})
else:  # overview
    resp = self._client.get("/api/v1/content/overview", params={"uri": uri})  # ← directory-only

Fix

Before calling an endpoint, determine URI type via fs/stat (isDir field), then route:

  • file/api/v1/content/download
  • directory + abstract/api/v1/content/abstract
  • directory + overview/api/v1/content/overview

Or migrate to the official SDK which handles this dispatch internally.

Environment

  • openviking server: 0.3.9
  • hermes-agent plugin: openviking 2.0.0

extent analysis

TL;DR

Modify the _tool_read() function to determine the URI type and route requests accordingly, using /api/v1/content/download for files and the existing endpoints for directories.

Guidance

  • Check the fs/stat response for the isDir field to determine if the URI is a file or directory.
  • Update the _tool_read() function to use the correct endpoint based on the URI type and level:
    • For files, use /api/v1/content/download regardless of level.
    • For directories, use /api/v1/content/abstract for the "abstract" level and /api/v1/content/overview for the "overview" level.
  • Consider migrating to the official SDK, which handles this dispatch internally, to simplify the code and reduce the chance of errors.

Example

if fs_stat_response['isDir']:
    if level == "abstract":
        resp = self._client.get("/api/v1/content/abstract", params={"uri": uri})
    elif level == "overview":
        resp = self._client.get("/api/v1/content/overview", params={"uri": uri})
else:
    resp = self._client.get("/api/v1/content/download", params={"uri": uri})

Notes

The provided fix assumes that the fs/stat response contains an isDir field that accurately indicates whether the URI is a file or directory. If this is not the case, additional error handling may be necessary.

Recommendation

Apply the workaround by modifying the _tool_read() function to correctly route requests based on URI type and level, as this is a more immediate solution that can be implemented without waiting for a potential SDK update.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING