Skip to content

Commit c29dde7

Browse files
committed
fix(logs): keep a withheld direct path unknown instead of falling back under output
1 parent f6f257f commit c29dde7

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎apps/sim/lib/mothership/agent-cli/engines.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const PARTLY_WITHHELD_RUNS = {
185185
{
186186
name: 'Router',
187187
status: 'success',
188-
output: { route: 'priority' },
188+
output: { route: 'priority', thinking: 'not the omitted span thinking' },
189189
contentWithheld: true,
190190
},
191191
],
@@ -242,6 +242,11 @@ describe('logs query on a marked span whose read field is intact', () => {
242242
expect(thinking.rows[0].note).toMatch(/value unknown/)
243243
expect(thinking.contentWithheld).toBe(2)
244244

245+
const shadowed = await logsQueryPartlyWithheld({ field: 'thinking', where: 'route=priority' })
246+
expect(shadowed.rows[0]).toMatchObject({ runId: 'run-1', value: null })
247+
expect(shadowed.rows[0].note).toMatch(/value unknown/)
248+
expect(shadowed.fieldResolvedUnder).toBeUndefined()
249+
245250
const toolInput = await logsQueryPartlyWithheld({ field: 'toolCalls.0.input.query' })
246251
expect(toolInput.rows[1].note).toMatch(/value unknown/)
247252
const toolMissing = await logsQueryPartlyWithheld({ field: 'toolCalls.3.input.query' })

‎apps/sim/lib/mothership/agent-cli/engines/query.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,23 @@ function isWithheldPath(span: QueryTraceSpan, path: string): boolean {
149149
return false
150150
}
151151

152-
/** The path as given first; under `output.` when the head is not a span-level key. */
152+
/**
153+
* The path as given first; under `output.` when the head is not a span-level key. A
154+
* direct path through a withheld content field (`thinking`) stays unknown rather than
155+
* falling back to a same-named key under output.
156+
*/
153157
function resolveSpanPathWithFallback(span: QueryTraceSpan, path: string): ResolvedSpanPath {
154158
const direct = resolveSpanPath(span, path)
155159
if (direct !== undefined) return { value: direct, path }
160+
if (isWithheldPath(span, path)) return { value: undefined, path, withheld: true }
156161
const head = path.split('.')[0] ?? ''
157-
const unresolved = (candidates: string[]): ResolvedSpanPath =>
158-
candidates.some((candidate) => isWithheldPath(span, candidate))
159-
? { value: undefined, path, withheld: true }
160-
: { value: undefined, path }
161-
if (SPAN_LEVEL_KEYS.has(head)) return unresolved([path])
162+
if (SPAN_LEVEL_KEYS.has(head)) return { value: undefined, path }
162163
const underOutput = `output.${path}`
163164
const value = resolveSpanPath(span, underOutput)
164-
if (value === undefined) return unresolved([path, underOutput])
165-
return { value, path: underOutput, resolvedUnder: 'output' }
165+
if (value !== undefined) return { value, path: underOutput, resolvedUnder: 'output' }
166+
return isWithheldPath(span, underOutput)
167+
? { value: undefined, path, withheld: true }
168+
: { value: undefined, path }
166169
}
167170

168171
function clipValue(value: unknown): unknown {

0 commit comments

Comments
 (0)