Skip to content

fix: exclude vector arrays from CLI --json output#337

Closed
dingguagua996-stack wants to merge 1 commit intoCortexReach:masterfrom
dingguagua996-stack:fix/issue-302
Closed

fix: exclude vector arrays from CLI --json output#337
dingguagua996-stack wants to merge 1 commit intoCortexReach:masterfrom
dingguagua996-stack:fix/issue-302

Conversation

@dingguagua996-stack
Copy link
Copy Markdown
Contributor

Summary

The --json output for list, search, and stats CLI commands included full vector arrays (768-1024 dimensional floats per entry), making output extremely verbose and unreadable.

Changes

Use a JSON replacer function in formatJson() to automatically filter out vector fields from all CLI JSON output. This is consistent with the export command which already strips vectors (line 888: vector: undefined).

Before

{
  "id": "abc123",
  "text": "Some memory",
  "vector": [0.023, -0.045, 0.012, ...],  // 768+ numbers!
  ...
}

After

{
  "id": "abc123",
  "text": "Some memory",
  ...
}

Files Changed

File Change
cli.ts formatJson() now uses JSON replacer to exclude vector key

Fixes #302

The --json output for list/search/stats commands included full vector
arrays (768-1024 dimensional floats), making output extremely verbose
and unreadable.

Use a JSON replacer function in formatJson() to automatically filter
out 'vector' fields. This is consistent with the export command which
already strips vectors (line 888).

Fixes CortexReach#302
@AliceLJY
Copy link
Copy Markdown
Collaborator

方向对,CLI --json 去掉 vector 数组确实是刚需。

麻烦 rebase 到最新 master(我们刚发了 beta.10),然后补一个 test/cli-smoke.mjs 的断言:search 和 list 的 --json 输出里不包含 "vector" 字段。

rebase + 补测试后可以合 👍

Copy link
Copy Markdown
Collaborator

@AliceLJY AliceLJY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — changes are clean, on-topic, and well-tested. Approving.

Copy link
Copy Markdown

app3apps commented Apr 3, 2026

这个改动方向是对的,但目前 formatJson() 用的是全局 replacer:只要 key === "vector" 就会被删掉。这样不仅会去掉 memory entry 里的 embedding 数组,也会把 search --json 结果中的 sources.vector 命中元数据一起删掉。

也就是说,这里修复了“输出太冗长”,但同时改变了 search --json 的返回结构。search 的非 JSON 输出仍然把 result.sources.vector 当成有效信息使用,所以这更像是一个行为回归,不只是展示层调整。当前测试看起来也只覆盖了 entry.id,抓不到这个问题。

建议把过滤范围收窄到真正的 embedding 字段,比如只去掉 entry/memory row 上的大向量数组,保留 sources.vector.score/rank 这类检索元数据;然后补一个 search --json 的断言,确保既不输出大数组,也不丢失 sources.vector

@rwmjhb rwmjhb closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI --json output includes verbose vector array making it unreadable

4 participants