feat: update gui custom agent fields#108
Conversation
xTRam1
left a comment
There was a problem hiding this comment.
I rechecked the SDK PR head. It has not changed since the last round, so the public response-contract gap is still present.
xTRam1
left a comment
There was a problem hiding this comment.
The AgentResponse.workflow_trace contract gap is fixed now. I found one follow-up issue in the new propagation behavior before I can stamp the SDK PR: the trace event emission needs to be made mutually exclusive with backend parent/child stitching so nested calls do not show the same child twice.
| else None | ||
| ) | ||
| workflow_trace = response_content.get("workflowTrace") | ||
| if workflow_trace is not None: |
There was a problem hiding this comment.
[P1] This now preserves workflowTrace on AgentResponse, which fixes the public SDK contract. The remaining problem is that this also emits a subWorkflow trace event unconditionally. For nested window.agent() calls, dispatch_request() already emits a subAgentCall event with the child request_id, and the backend stitcher uses that request id to replace the SDK event with the child remote-dispatch row's workflowTrace. If we also emit subWorkflow here, the parent Python trace can contain both the original subAgentCall and this subWorkflow; the backend currently replaces only the first matching node, so the other one can remain and render the same child twice.
Please make this mutually exclusive with the parent-request stitching path, or remove the trace emission here and only expose the field on AgentResponse. For example:
workflow_trace = response_content.get("workflowTrace")
parent_request_id = self._current_parent_request_id()
# Preserve the response contract for direct callers, but avoid adding a second
# child node when the backend will stitch the child request into the parent row.
if workflow_trace is not None and parent_request_id is None:
_trace.emit_sub_workflow(workflow_trace=workflow_trace)
return AgentResponse(
...,
action_trace=action_trace,
workflow_trace=workflow_trace,
)I would also add a regression test for the nested case: set an injected parent request id, return a response with workflowTrace, and assert we do not emit an extra subWorkflow event on top of the existing subAgentCall/SQL-stitching path. The direct no-parent case Sebastian tested should still keep AgentResponse.workflow_trace populated.
xTRam1
left a comment
There was a problem hiding this comment.
Approving. The original SDK response-contract blocker is fixed: AgentResponse now exposes workflow_trace, and both pyodide and non-pyodide window.agent() populate it. The remaining comment about avoiding duplicate subWorkflow emission in nested runs is a small contained follow-up, but please address it before merging so the observability view does not risk rendering the same child workflow twice.
xTRam1
left a comment
There was a problem hiding this comment.
Approving the latest head as well. The response-contract blocker is fixed, and the follow-up deduplication issue is now handled by only emitting the SDK subWorkflow event for direct/no-parent calls while preserving AgentResponse.workflow_trace for all callers.
Children field for custom agent runs to allow for nested GUI traces.