[Bug]: viking_read on a directory URI returns bare INVALID_ARGUMENT instead of degrading to .overview.md / children
Issue Origin
Observed or reproduced in a real environment
Bug Description
viking_read (and the underlying read API) refuses directory URIs with a hard INVALID_ARGUMENT: Cannot read directory as file error, even when the directory has a generated .overview.md / .abstract.md and readable child files. This forces every caller to do a 3-step dance (list → pick a leaf → read) just to look at the directory's own content.
The API surface is inconsistent with find / search, which already understand directories and route to overview / children automatically.
Steps to Reproduce
- Have any resource directory with an auto-generated overview, e.g.
viking://resources/leq_qgyg_kanban/(a KANBAN board directory with two child.mdfiles and.overview.md). - Call
readon the directory URI directly:
viking_read(uri="viking://resources/leq_qgyg_kanban/")
- Server returns:
INVALID_ARGUMENT: Cannot read directory as file: viking://resources/leq_qgyg_kanban/
Expected Behavior
read on a directory URI should transparently degrade to a sensible default, matching how find / search already treat directories. Any of the following would be acceptable:
level=overview/abstract→ return the auto-generated.overview.md/.abstract.mdcontent.level=full→ return concatenated children (with per-child head truncation and total-size guard).- Or, at minimum, return a structured hint (
{"error":"is_directory","children":[...],"overview_uri":"..."}) instead of a bareINVALID_ARGUMENT, so the agent can react without doing a separatebrowse listcall.
Actual Behavior
Bare INVALID_ARGUMENT: Cannot read directory as file. No pointer to .overview.md, no child list, no suggestion. The caller has to know to fall back to browse list and then read a specific leaf.
Minimal Reproducible Example
# fails
client.read("viking://resources/leq_qgyg_kanban/")
# workaround (3 calls to do what feels like 1)
entries = client.browse("list", "viking://resources/leq_qgyg_kanban/")
first_leaf = entries[0]["uri"]
content = client.read(first_leaf)
Error Logs
INVALID_ARGUMENT: Cannot read directory as file: viking://resources/leq_qgyg_kanban/
OpenViking Version
0.4.7
Python Version
3.10
Operating System
Linux
Model Backend
Volcengine (Doubao)
Additional Context
- Observed while an LLM agent tried to read a KANBAN board directory that was known (by the agent) to have
.overview.md. The agent had to be re-prompted to runbrowse listfirst, which is exactly the friction.overview.mdis meant to remove. - Related but distinct: #2383 (repeated
add_resourcere-embeds unchanged content) — same "directory should be first-class" theme, different API. Complementary, not duplicate. - Sibling issues in this batch: #3306 (
add_resourcetimeout returns notask_id) and #3307 (content-awareadd_resource). All three fall under "makeviking://directory / URI semantics symmetric across read / write paths".