Allow callers to set the thread source for sampling (#56364)

## What changed

Add optional `threadSource` to `thread/sample` requests and apply it to the ephemeral fork. Keep `thread_sample` as the default when omitted.

## Testing

Extend sampling tests to assert that turn metadata includes the supplied thread source and retains the default when no source is provided.

GitOrigin-RevId: 8ea941c932267e3bcb9e6b086764ac2795d6edef
This commit is contained in:
Keyan Zhang
2026-10-23 06:07:10 +00:00
committed by copyberry
parent 30587d7885
commit a96fa4f220
4 changed files with 13 additions and 1 deletions
+6 -1
View File
@@ -213,7 +213,12 @@ impl SampleTask {
model.supports_reasoning_effort_updates && options.config.model_provider.is_openai()
});
options.session_source = Some(SessionSource::Custom("thread_sample".to_string()));
options.thread_source = Some(ThreadSource::Feature("thread_sample".to_string()));
options.thread_source = Some(
params
.thread_source
.map(Into::into)
.unwrap_or_else(|| ThreadSource::Feature("thread_sample".to_string())),
);
options.parent_trace = trace.clone();
if cancellation.is_cancelled() {
return Err(internal_error("sample canceled"));