feat(weave): add Custom Runtime conversation context - #7688
Closed
mattliu-mygit wants to merge 1 commit into
Closed
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
mattliu-mygit
force-pushed
the
agent/custom-runtime-conversation-context
branch
3 times, most recently
from
August 5, 2026 17:44
ea2de6e to
ab60e63
Compare
mattliu-mygit
changed the base branch from
master
to
agent/chat-stream-lifecycle-fix
August 5, 2026 17:44
mattliu-mygit
force-pushed
the
agent/chat-stream-lifecycle-fix
branch
from
August 5, 2026 17:50
6520d8d to
d46a9fd
Compare
mattliu-mygit
force-pushed
the
agent/custom-runtime-conversation-context
branch
from
August 5, 2026 17:50
ab60e63 to
8777d0b
Compare
mattliu-mygit
force-pushed
the
agent/chat-stream-lifecycle-fix
branch
from
August 5, 2026 18:16
d46a9fd to
c5e2cc8
Compare
mattliu-mygit
force-pushed
the
agent/custom-runtime-conversation-context
branch
from
August 5, 2026 18:18
8777d0b to
faaff3c
Compare
mattliu-mygit
force-pushed
the
agent/custom-runtime-conversation-context
branch
3 times, most recently
from
August 5, 2026 19:47
5e52576 to
e565aed
Compare
mattliu-mygit
force-pushed
the
agent/custom-runtime-conversation-context
branch
from
August 5, 2026 20:29
e565aed to
8bf0cca
Compare
Contributor
Author
|
Superseded by #7696, which isolates the first mergeable slice to Custom Runtime conversation-context propagation and preserves the existing tracing policy. The logging-default and UI behavior will follow in separate PRs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
custom::runtimes in the reserved, percent-encodedX-Weave-Conversation-Idheader_metarecordExisting behavior and decision
Today, when Trace LLM call is enabled, the Playground asks the trace server to record the completion boundary. For a Custom Runtime that produces one W&B-owned root
chatspan containing the submitted messages and final response. The publicweave.chatclient has the equivalent behavior through its local completion op. This is useful when the downstream model is opaque, but a Custom Runtime is not opaque: it can independently log its Turn, LLM, subagent, and tool spans to Weave.If both sides log the same request, the Conversation view receives two representations of the boundary user and assistant messages. A conversation ID can correlate the records, but it cannot determine which duplicate should be hidden: message content and timestamps are not reliable identity, and the W&B span and runtime span do not share a span tree.
This PR therefore makes tracing ownership opinionated for explicit
custom::requests:This is the smallest implementation with one authoritative trace owner. It is decided per request in the shared completion dispatch path, so it covers Playground, synchronous, streaming, async, and raw API ingress without adding a UI setting or changing the storage model. It also requires no database migration, trace-merging protocol, deduplication heuristic, conversation-specific rendering logic, or coordinated Core deployment. Explicit
custom::resolution keeps the behavior from leaking to CoreWeave, which also uses LiteLLM's internalprovider="custom"transport value.Alternatives considered were materially broader:
The tradeoff is deliberate: an uninstrumented Custom Runtime will no longer get a W&B-generated boundary span. The runtime contract and public sample make runtime-owned logging explicit, because only the runtime can provide the complete chronology.
End-to-end flow
conversation_id, or omits it on the first turn.X-Weave-Conversation-Idvalue and disables the W&B completion span for that request.conversation_idat the top level. A streaming response first emits{"_meta":{"conversation_id":"..."}}and then the normal completion chunks._meta;weave.chatnow consumes it internally, exposesstream.conversation_id, and never yields the metadata as an LLM chunk. Later turns and provider switches send the retained ID back to the trace server.The
_metarecord for an untracked Custom Runtime contains only conversation identity—no synthetic call, span, or trace IDs are created. Existing tracked-stream metadata remains unchanged.Provider switching
Trace ownership is decided per request rather than cached for the whole conversation. Automated coverage and the local E2E exercise one conversation moving through:
The local trace data preserved the same conversation ID across all three providers. The hosted request retained a W&B-owned
Weave Chat Playgroundspan; returning to the Custom Runtime rejoined the original runtime-owned conversation.The hosted CoreWeave turn returned a blank/error response locally because of the existing reasoning-response normalization behavior. That is separate from conversation identity: the persisted span still demonstrated the expected ID and per-request trace ownership, and this PR does not alter response normalization.
Customer-visible result
The screenshots use the same natural two-turn Seattle-planning conversation. The deterministic OpenAI-compatible downstream keeps the content stable; the conversation storage and runtime-owned Weave spans are real.
Before: only the boundary input and output
Current production records one root
chatspan per turn. The customer sees the final answers, but none of the runtime's planning, research, or tool work: 2 spans, 0 tools, 2 traces.Open the before conversation
After: runtime work appears chronologically
The runtime receives one conversation ID across both turns and logs the complete workflow: 18 runtime-owned spans, 8 tools, 2 traces. The app inspection showed 2 user messages and 4 assistant messages, with planning, research, LLM, subagent, and tool activity in chronological order and no synthetic internal user messages.
Open the production-hosted after example
Turn 1: planning, research, four tools, and the final response
Turn 2: the follow-up remains in the same conversation
Trace view: one nine-span runtime-owned hierarchy
The public sample implements the runtime side of the contract, including use of the received conversation ID and assistant/tool-oriented trace data. The E2E version is published in commit
4e6948d.Verification
npm test— 104 passedCode review
Reviewed the complete diff after moving conversation-ID ownership back into the trace server. The retained tests cover server generation/reuse, streaming
_metaconsumption, non-streaming responses, sync/async/in-memory servers, reserved-header override, CoreWeave isolation, Custom Runtime trace ownership, provider switching, OpenAI SSE compatibility, and stream resource cleanup.