-
Notifications
You must be signed in to change notification settings - Fork 55
feat: Propagate trace context for subagent trace viewing HUD-591 #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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".
35c5745 to
ac6b1c0
Compare
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.
ac6b1c0 to
0936178
Compare
There was a problem hiding this 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".
| try: | ||
| result = await client.call_tool(name=name, arguments=args, meta=meta) | ||
| except TypeError: | ||
| # Fallback for clients that don't accept meta | ||
| try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Note
Ensures trace context flows across MCP boundaries and results are consistent for downstream handling.
_hud_trace_idviametawhen callingcall_toolinfastmcp.py,mcp_use.py, andenvironment/connection.py, with graceful fallbacks ifmetais unsupported_env_call_toolextracts trace frommetaor arguments and appliesset_trace_contextto scope executionset_trace_contexthelper tohud.eval.contextand corresponding testsmcp.types.CallToolResultinConnector.call_toolclient.call_toolWritten by Cursor Bugbot for commit c734a58. This will update automatically on new commits. Configure here.