Skip to content

fix(cohere): capture rerank relevant_spans - #1010

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/cohere-rerank-spans-08e6d9d0
Oct 26, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/cohere-rerank-spans-08e6d9d0

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

🤖 This text was AI-generated.

Cohere v2 rerank dropped the relevant_spans request option from trace
metadata and discarded the matching passages returned by v5 models:

before: output[] = {index, relevance_score}

Capture the option in the metadata allowlist and include each returned
passage's character offsets and relevance score:

after: metadata.relevant_spans = {mode, threshold?, max_spans?}
       output[] = {index, relevance_score, relevant_spans?: [{start, end, score}]}

Omit relevant_spans when absent from a result. Add a recorded v5 example
covering both cases and skip it on SDK versions without the request option.

Fixes #1004
Linear: SDK-630

> 🤖 **This text was AI-generated.**

Cohere v2 rerank dropped the relevant_spans request option from trace
metadata and discarded the matching passages returned by v5 models:

```text
before: output[] = {index, relevance_score}
```

Capture the option in the metadata allowlist and include each returned
passage's character offsets and relevance score:

```text
after: metadata.relevant_spans = {mode, threshold?, max_spans?}
       output[] = {index, relevance_score, relevant_spans?: [{start, end, score}]}
```

Omit relevant_spans when absent from a result. Add a recorded v5 example
covering both cases and skip it on SDK versions without the request option.

Fixes #1004
Refs: https://linear.app/braintrustdata/issue/SDK-630
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T13:20:31.885312Z ce2d8f6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit cc400a1 into main Oct 26, 2026
98 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/cohere-rerank-spans-08e6d9d0 branch October 26, 2026 15:35
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.

cohere: capture rerank relevant_spans

1 participant