Skip to content

feat: [CMPS-1476] add relevant spans to search_documents and search_chunks - #259

Open
corafid wants to merge 1 commit into
mainfrom
corafid/feat/rerank-relevant-spans
Open

corafid wants to merge 1 commit into
mainfrom
corafid/feat/rerank-relevant-spans

Conversation

@corafid

@corafid corafid commented Nov 26, 2026

Copy link
Copy Markdown
Member

[Section to be filled by Rafid]


[🤖 Rafid's Bot · opencode · claude-opus-5-5] Everything below this line is AI generated.

Linear: CMPS-1476

Compass search can now return Rerank v5 "relevant spans": the passages of each reranked chunk that the rerank model finds relevant to the query (cohere-ai/compass, branch corafid/feat/rerank-relevant-spans). This exposes that in the SDK, so callers such as the Compass MCP server can show agents only those passages.

  • search_documents and search_chunks (sync and async) take relevant_spans: RelevantSpansInput | None. It is sent only when given.
  • RetrievedScoredChunk gains relevant_spans: list[RelevantSpan] | None. Responses from servers without the feature still parse, with None.
  • Version 2.28.0 → 2.29.0.

Decision for review: RelevantSpansInput.mode defaults to "enabled" in the SDK, so RelevantSpansInput() turns the feature on. On the server, mode is required. The SDK always sends it, so the request is valid either way.

Requires the Compass change to be deployed. Older servers ignore the field, and a Compass deployment whose rerank model isn't Rerank v5 answers 400 (raised as CompassClientError).

Tests cover the request body on both clients and endpoints, validation of threshold and max_spans, and parsing of spans, [], null and an omitted field.

…hunks

Compass can now ask Rerank v5 for the passages of each reranked chunk that
are relevant to the query, so callers such as agents can read only those
passages instead of whole chunks. The SDK mirrors the API: an optional
relevant_spans option on both search methods (sync and async), and a
relevant_spans list on every scored chunk in the responses.

The option is left out of the request body when not given, so existing
calls send the same request to any server. The response field defaults to
None, so responses from servers that predate it still parse.

Bumps the version to 2.29.0, a minor release because this adds public API.
@corafid
corafid requested a review from a team as a code owner November 26, 2026 00:19
@corafid
corafid requested a review from luca-cohere November 26, 2026 00:19

This branch has not been deployed

No deployments
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