Skip to content

Conversation

@ryantzr1
Copy link
Contributor

@ryantzr1 ryantzr1 commented Jan 14, 2026

Note

Ensures trace context flows across MCP boundaries and results are consistent for downstream handling.

  • Injects _hud_trace_id via meta when calling call_tool in fastmcp.py, mcp_use.py, and environment/connection.py, with graceful fallbacks if meta is unsupported
  • Server handler _env_call_tool extracts trace from meta or arguments and applies set_trace_context to scope execution
  • Adds set_trace_context helper to hud.eval.context and corresponding tests
  • Normalizes varied client tool call results to mcp.types.CallToolResult in Connector.call_tool
  • Minor refactors (local var usage) and test updates to use client.call_tool

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

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd08f6ccab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ryantzr1 ryantzr1 marked this pull request as draft January 14, 2026 10:21
@ryantzr1 ryantzr1 force-pushed the feat/multi-agent-trace-context-propagation branch from 35c5745 to ac6b1c0 Compare January 14, 2026 10:31
@ryantzr1 ryantzr1 marked this pull request as ready for review January 14, 2026 10:33
@ryantzr1 ryantzr1 changed the title Feat/multi agent trace context propagation Feat/multi agent trace context propagation HUD-591 Jan 14, 2026
@ryantzr1 ryantzr1 marked this pull request as draft January 14, 2026 10:44
Add distributed tracing support across MCP boundaries so telemetry
spans are connected end-to-end between agents and environments.

Changes:
- Add set_trace_context() to temporarily restore trace context from
  incoming MCP requests
- Inject trace ID via MCP meta parameter in FastMCP, mcp-use, and
  Connector clients when calling tools
- Extract and restore trace context in Environment._env_call_tool()
  when receiving tool calls
- Include graceful fallbacks for MCP clients that don't support meta
- Only pass meta when trace context exists to avoid breaking test mocks

This enables full visibility in the HUD dashboard for multi-agent and
remote environment workflows.
@ryantzr1 ryantzr1 force-pushed the feat/multi-agent-trace-context-propagation branch from ac6b1c0 to 0936178 Compare January 21, 2026 06:32
@ryantzr1 ryantzr1 marked this pull request as ready for review January 21, 2026 06:34
@ryantzr1 ryantzr1 changed the title Feat/multi agent trace context propagation HUD-591 feat: Propagate trace context for subagent trace viewing HUD-591 Jan 21, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0936178edf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 205 to 209
try:
result = await client.call_tool(name=name, arguments=args, meta=meta)
except TypeError:
# Fallback for clients that don't accept meta
try:

Choose a reason for hiding this comment

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

P2 Badge Avoid retrying tool calls on arbitrary TypeError

The new except TypeError fallback treats any TypeError from client.call_tool as “meta not supported” and immediately reissues the tool call. If a tool itself raises TypeError (e.g., wrong argument types or internal bug), this path will execute the tool twice and only surface the second failure/result, which is risky for side‑effecting tools (writes, API calls). Consider narrowing the exception handling to unexpected‑keyword errors (e.g., inspect the signature or match the error message) before retrying without meta.

Useful? React with 👍 / 👎.

- Remove cast("Any", ...) escape hatches for better type safety
- Only catch TypeError for "unexpected keyword argument" to avoid
  masking real errors and double-executing side-effecting tools
@lorenss-m lorenss-m merged commit 4082bed into main Jan 22, 2026
9 checks passed
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.

3 participants