Skip to content

YANJ-446: add concise MCP and CLI recall output - #221

Open
mameikagou wants to merge 1 commit into
CaviraOSS:mainfrom
mameikagou:fix/recall-compact-output
Open

mameikagou wants to merge 1 commit into
CaviraOSS:mainfrom
mameikagou:fix/recall-compact-output

Conversation

@mameikagou

Copy link
Copy Markdown
Contributor

Recall currently serializes full candidate nodes even when the context token budget is small. The CLI also includes embeddings because its JSON output does not use the MCP vector filter.

This change makes MCP recall return context (text, tokens_used, budget) and concise hits (id, observed_at, score, status, text). Compact output defaults to 8 hits; optional k is passed to the core engine. verbose: true returns the existing full response structure and preserves the engine's candidate count when k is omitted. Recall vectors require explicit include_vectors: true with verbose output.

CLI --brief selects the same concise structure, with ok, mode, and query. The CLI keeps its detailed fields by default because existing scripts consume items and context_packet; --full selects that explicitly, and --include-vectors restores embeddings. The existing --compact whitespace option keeps its meaning. Both transports share hit formatting and vector filtering. Historical brief output limits chronological hits and builds context with the existing budgeted context builder; verbose historical output keeps the complete timeline.

Measured on a self-hosted database before and after rebuilding the container, using strict mode and token_budget=300 (UTF-8 JSON payload bytes, excluding the MCP transport envelope):

Query Interface Before After
选股策略 MCP default 2,308,344 (204 candidates) 8,723 (8 hits)
dsh web plugin MCP default 4,291,140 (602 candidates) 8,511 (8 hits)
选股策略 CLI, k=5 191,683 5,255 with --brief
dsh web plugin CLI, k=5 303,778 5,771 with --brief

token_budget bounds context text; k bounds hit count. Hit text is preserved, so neither is a total byte limit. Existing MCP consumers of full nodes/traces should add verbose: true.

Validation: typecheck, recall:check, build, branding:check, integration:check, and bench:ci passed. Added real SQLite/CLI and SDK MCP tests for all four modes, default/explicit limits, context preservation, observation dates, empty results, scope rejection, and vector opt-in. Also ran recall checks with the global MCP vector default enabled, verified the clean main-based branch, and exercised the rebuilt HTTP MCP server through initialize and tools/call.

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.

1 participant