@@ -171,6 +171,26 @@ func traceRunWithTokens(id, traceID, threadID, startTime string, totalTokens int
171171 return run
172172}
173173
174+ func requireSelectContains (t * testing.T , body map [string ]any , expected ... string ) {
175+ t .Helper ()
176+
177+ selects , ok := body ["select" ].([]any )
178+ if ! ok {
179+ t .Fatalf ("expected select array in request, got %#v" , body ["select" ])
180+ }
181+ seen := make (map [string ]bool , len (selects ))
182+ for _ , sel := range selects {
183+ if s , ok := sel .(string ); ok {
184+ seen [s ] = true
185+ }
186+ }
187+ for _ , field := range expected {
188+ if ! seen [field ] {
189+ t .Fatalf ("expected select to include %q, got %#v" , field , selects )
190+ }
191+ }
192+ }
193+
174194func TestTraceListCmd_OnePerThreadFlagDefault (t * testing.T ) {
175195 cmd := newTraceListCmd ()
176196 f := cmd .Flags ().Lookup ("one-per-thread" )
@@ -291,6 +311,31 @@ func TestTraceListCmd_OnePerThreadAppliesMinTokensBeforeDedupe(t *testing.T) {
291311 }
292312}
293313
314+ func TestTraceListCmd_OnePerThreadSelectsThreadIDWithoutIncludeFlags (t * testing.T ) {
315+ var requests []map [string ]any
316+ ts := newTraceListPagingServer (t , []traceListPage {{
317+ runs : []map [string ]any {
318+ traceRun ("run-a" , "trace-a" , "thread-a" , "2026-01-01T00:00:00Z" ),
319+ },
320+ }}, & requests )
321+
322+ _ = runTraceListJSON (t , ts .URL , "--one-per-thread" , "--limit" , "1" )
323+
324+ if len (requests ) != 1 {
325+ t .Fatalf ("expected 1 run query request, got %d" , len (requests ))
326+ }
327+ requireSelectContains (t , requests [0 ],
328+ "id" ,
329+ "trace_id" ,
330+ "name" ,
331+ "run_type" ,
332+ "parent_run_id" ,
333+ "start_time" ,
334+ "end_time" ,
335+ "thread_id" ,
336+ )
337+ }
338+
294339func TestTraceListCmd_OnePerThreadIncludeIOSelectsThreadID (t * testing.T ) {
295340 var requests []map [string ]any
296341 ts := newTraceListPagingServer (t , []traceListPage {{
@@ -304,16 +349,7 @@ func TestTraceListCmd_OnePerThreadIncludeIOSelectsThreadID(t *testing.T) {
304349 if len (requests ) != 1 {
305350 t .Fatalf ("expected 1 run query request, got %d" , len (requests ))
306351 }
307- selects , ok := requests [0 ]["select" ].([]any )
308- if ! ok {
309- t .Fatalf ("expected select array in request, got %#v" , requests [0 ]["select" ])
310- }
311- for _ , sel := range selects {
312- if sel == "thread_id" {
313- return
314- }
315- }
316- t .Fatalf ("expected select to include thread_id, got %#v" , selects )
352+ requireSelectContains (t , requests [0 ], "thread_id" , "inputs" , "outputs" , "error" )
317353}
318354
319355// ==================== trace get flags ====================
0 commit comments