Skip to content

feat(weave): propagate Custom Runtime conversation context - #7696

Draft
mattliu-mygit wants to merge 1 commit into
masterfrom
agent/custom-runtime-conversation-id
Draft

feat(weave): propagate Custom Runtime conversation context#7696
mattliu-mygit wants to merge 1 commit into
masterfrom
agent/custom-runtime-conversation-id

Conversation

@mattliu-mygit

Copy link
Copy Markdown
Contributor

Description

Supersedes #7688 with the first, independently mergeable slice: conversation context propagation only.

Custom Runtimes can emit their own internal spans, but previously they did not receive the conversation ID used by the Playground request. Those spans therefore could not reliably join the same chronological conversation.

This PR:

  • generates or reuses a conversation ID before an explicit Custom Runtime request is dispatched
  • injects it into the reserved X-Weave-Conversation-Id runtime header, overriding any configured header with that name
  • returns the ID in non-streaming responses and through the existing streaming _meta channel
  • exposes the returned ID on the Python Playground completion/stream so it can be reused on later turns, including after switching providers or runtimes
  • covers the synchronous, asynchronous, ClickHouse, and in-memory completion paths

This deliberately preserves existing tracing behavior. Both track_llm_call=true and track_llm_call=false continue to mean what they mean today; this PR does not choose a new Custom Runtime logging default or add UI policy.

Testing

  • 146 passed across:
    • tests/trace/test_chat_completions.py
    • tests/trace_server/test_llm_completion.py
    • tests/trace_server/test_clickhouse_trace_server_batched.py
    • tests/trace_server/test_async_clickhouse_trace_server.py
    • tests/trace_server/test_custom_provider.py
  • Ruff format/check on all changed files
  • ty check

The focused coverage includes generated and reused IDs, streaming and non-streaming responses, configured-header override, header-safe encoding, tracked and untracked requests, and provider switching.

@mattliu-mygit mattliu-mygit changed the title feat(trace-server): propagate Custom Runtime conversation context feat(weave): propagate Custom Runtime conversation context Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.53846% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
weave/trace_server/in_memory_trace_server.py 0.00% 4 Missing ⚠️
weave/chat/stream.py 81.81% 1 Missing and 1 partial ⚠️
...ve/trace_server/clickhouse_trace_server_batched.py 95.65% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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