Skip to content

Add parallel_agent_group telemetry for tracking parallel agent execution - #289

Closed
ryantzr1 wants to merge 3 commits into
mainfrom
feature/parallel-agent-group-telemetry
Closed

ryantzr1 wants to merge 3 commits into
mainfrom
feature/parallel-agent-group-telemetry

Conversation

@ryantzr1

@ryantzr1 ryantzr1 commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Introduces a new span category 'parallel-agent-group' that enables the HUD platform to render parallel agent execution as a visual card with real-time progress tracking.

New features:

  • ParallelAgentGroup class for managing parallel agent status
  • parallel_agent_group() async context manager for easy integration
  • Automatic span emission on status updates (running/completed/failed)
  • Exports from hud.telemetry and hud packages

Note

Enables UI-visible tracking of multiple agents running in parallel with progress updates and final status.

  • Introduces ParallelAgentGroup, ParallelAgentInfo, and async parallel_agent_group(...) to manage agent statuses and emit category: parallel-agent-group spans via queue_span
  • Spans include normalized trace_id, TraceStep attributes, per-agent status, and set status_code to ERROR on failures; initial updates and final summary are automatically emitted
  • Public exports added in hud.telemetry and top-level hud (__all__ updates)
  • Adds tests covering serialization, status transitions, span emission, context manager behavior, defaults, and exception handling

Written by Cursor Bugbot for commit 621c026. This will update automatically on new commits. Configure here.

Introduces a new span category 'parallel-agent-group' that enables the
HUD platform to render parallel agent execution as a visual card with
real-time progress tracking.

New features:
- ParallelAgentGroup class for managing parallel agent status
- parallel_agent_group() async context manager for easy integration
- Automatic span emission on status updates (running/completed/failed)
- Exports from hud.telemetry and hud packages
ryantzr1

This comment was marked as resolved.

ryantzr1

This comment was marked as duplicate.

@ryantzr1
ryantzr1 marked this pull request as ready for review January 19, 2026 04:44
@ryantzr1

Copy link
Copy Markdown
Contributor Author

not ready for review, just using this to test bugbot

@ryantzr1
ryantzr1 marked this pull request as draft January 19, 2026 04:54
ryantzr1

This comment was marked as duplicate.

ryantzr1

This comment was marked as duplicate.

ryantzr1

This comment was marked as duplicate.

ryantzr1

This comment was marked as duplicate.

ryantzr1

This comment was marked as duplicate.

ryantzr1

This comment was marked as duplicate.

ryantzr1

This comment was marked as duplicate.

ryantzr1

This comment was marked as duplicate.

- Add trace_subagent parameter to AgentTool for separate traces
- Include trace_id in tool result metadata for subagent calls
- Update documentation with trace_subagent usage examples
- Refactor test code to use modern Python with statement syntax

@ryantzr1 ryantzr1 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HUD Bugbot Review

Found a critical indentation error in agent.py that will prevent the code from running.

Comment thread hud/tools/agent.py
@@ -218,6 +231,15 @@ async def _run_subagent() -> ToolResult:

result = await agent.run(ctx)
content = result.content if hasattr(result, "content") and result.content else ""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation breaks return statement
High Severity

Line 233 has incorrect indentation. The line starting with content = result.content should be indented to align with the code block inside the async with statement, but appears to have only one space of indentation in the diff. This will cause a Python IndentationError and prevent the code from running.

Suggestion: Fix the indentation to properly align with the surrounding code block. The line should be indented to match the previous line (agent = self._agent_cls.create(**self._agent_params)) and the following return statement.

@ryantzr1 ryantzr1 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HUD Bugbot Review

Found critical indentation error in agent.py that will break execution flow, plus a logic issue with trace_id generation.

Comment thread hud/tools/agent.py
return ToolResult(content=[TextContent(type="text", text=content)])

return await _run_subagent()
return ToolResult(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation causes syntax/logic error
High Severity

The return ToolResult(...) statement starting at line 234 is incorrectly indented. It appears to be inside the else block (line 233) when it should be at the same indentation level as the if self._model: block (line 228). This will cause the return statement to only execute when self._model is falsy, which breaks the normal execution flow when self._model is truthy.

Suggestion: Dedent lines 234-237 to align with line 228:

                result = await agent.run(ctx)
                content = result.content if hasattr(result, "content") and result.content else ""
            return ToolResult(
                    content=[TextContent(type="text", text=content)],
                    meta={"trace_id": trace_id} if trace_id else None,
                )

Comment thread hud/tools/agent.py

# Wrap execution with instrumentation to mark as subagent
# Platform uses category="subagent" to detect and render subagent tool calls
@instrument(category="subagent", name=self.name)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant condition when creating trace_id
Medium Severity

The condition elif self._trace or self._trace_subagent: on line 215 is redundant because should_trace (calculated on line 205) already evaluates the same conditions. When use_parent_trace is False and we reach line 215, we should generate a new trace_id only if should_trace is True. The current logic could generate a trace_id even when should_trace=False in certain edge cases (e.g., when both _trace and _trace_subagent are False but we're not using parent trace).

Suggestion: Replace the condition with:

elif should_trace:
    trace_id = str(uuid.uuid4())

@ryantzr1 ryantzr1 closed this Jan 20, 2026
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