Repository navigation
fix(cohere): trace v2 clients and streaming lifecycle - #350
Merged
Merged
Conversation
Preserve the instrumentor API and SDK promise/iterator contracts while tracing generated v2 clients, v1 camelCase payloads, embeddings and reranking. Add offline real-SDK coverage, OTLP privacy assertions and a dedicated CI gate. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Keep generated outputs visible while omitting echoed history, embedding texts, reranked documents and citation sources when inputs are hidden. Treat EOF without a terminal event as incomplete without changing consumer iteration. Cover SDK floor and current release with independent privacy flags and OTLP assertions. Co-Authored-By: Claude Code <noreply@anthropic.com>
Preserve v2 content-start text, share finish classification across chat paths, and keep SDK requests and responses unchanged. Cover credential OTLP export, terminal statuses with content hidden, and partial start-event output. Co-Authored-By: Claude Code <noreply@anthropic.com>
…v2-streams Co-Authored-By: Claude Code <noreply@anthropic.com>
Preserve indexed v2 thinking blocks in streaming output and input-hidden response projections. Accumulate v1 tool-call deltas without parsing partial argument strings, and replace them with authoritative final calls. Add 45 real-SDK regressions with OTLP checks for completion, interruption, multiple content/tool indices, input hiding, and all output hiding controls. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Keep and repair
@traceai/cohere; do not delete it. The old integration missed generated v2 clients and allchatStreamcalls, and treated SDK camelCase fields as wire-format snake_case.CohereClient.v2, covering bothclient.v2and the methods bound byCohereClientV2. KeepCohereInstrumentation/manuallyInstrumentworking.HttpResponsePromise.withRawResponse().EMBEDDINGspans and useRERANKERfor reranking instead of treating everything as an LLM call.Why this route
Cohere 8.3.0 binds v2 methods to a separate generated client, rather than the v1 prototype: SDK source. The public
client.v2accessor exposes that same generated implementation: SDK source. Prototype discovery constructs an inert client with no I/O or environment credential lookup. Instrumentation must be configured before constructing customer clients.The existing package API is retained instead of requiring customers to copy helper code or migrate to a different client wrapper. Endpoint scope remains
chat,chatStream,embed, andrerank.Verification
Before the implementation change, the real-SDK reproducer failed all three cases: v2 emitted zero spans; v1 history extraction omitted earlier messages; the global patched flag also prevented a second SDK copy from being instrumented.
After the change:
All local build/test/package commands ran under the supplied outbound-network-denied sandbox, with localhost permitted. No vendor/model API calls or real credentials were used. The dedicated CI job repeats the tests inside a network namespace with only loopback enabled.
E2E coverage
not applicable (no product e2e/ harness) · flows hit: n/a · marker: n/a · verdict: not applicable
The real-SDK localhost and OTLP wire tests are the integration regression gate. No live Cohere verification is claimed. SDK 7.0.0 has no
chatStream; stream coverage uses 8.3.0.Release and docs
Release-please owns package versioning; no versions or changelog entries were hand-bumped. Package README changes ship with this fix. No separate docs-site PR is opened against an unreleased package change. This PR does not merge, tag or publish a release.
🤖 Generated with Claude Code