Context
buildCohereCountTokensText flattens Responses messages into a single plain-text payload for Cohere tokenization. It handles several message shapes (plain text, content blocks, reasoning summaries) but has no dedicated unit tests, and there is no count_tokens_test.go next to the implementation yet.
What to do
Create deepintshield_server/core/providers/cohere/count_tokens_test.go (using the same style as rerank_test.go) with cases for:
- A single text message.
- Multiple sequential messages.
- An empty message slice (must not panic; returns empty string).
- Messages whose content is a list of content blocks containing text.
- Messages carrying reasoning summaries.
- Mixed content (text + blocks + reasoning).
- Messages with nil fields.
- Messages with empty/whitespace strings (verify trimming behavior).
Acceptance criteria
File pointers
- Function under test:
deepintshield_server/core/providers/cohere/count_tokens.go:89 (buildCohereCountTokensText)
- Related schemas:
deepintshield_server/core/providers/cohere/count_tokens.go (request/response types near the top)
- Test-style reference:
deepintshield_server/core/providers/cohere/rerank_test.go
Context
buildCohereCountTokensTextflattens Responses messages into a single plain-text payload for Cohere tokenization. It handles several message shapes (plain text, content blocks, reasoning summaries) but has no dedicated unit tests, and there is nocount_tokens_test.gonext to the implementation yet.What to do
Create
deepintshield_server/core/providers/cohere/count_tokens_test.go(using the same style asrerank_test.go) with cases for:Acceptance criteria
deepintshield_server/core/providers/cohere/count_tokens_test.go.go test ./core/providers/cohere/....rerank_test.go.File pointers
deepintshield_server/core/providers/cohere/count_tokens.go:89(buildCohereCountTokensText)deepintshield_server/core/providers/cohere/count_tokens.go(request/response types near the top)deepintshield_server/core/providers/cohere/rerank_test.go