Skip to content

Comments

Add custom agent example using HUD Gateway for inference#223

Merged
Parth220 merged 3 commits intomainfrom
j/custom-agent-example
Nov 29, 2025
Merged

Add custom agent example using HUD Gateway for inference#223
Parth220 merged 3 commits intomainfrom
j/custom-agent-example

Conversation

@jdchawla29
Copy link
Collaborator

@jdchawla29 jdchawla29 commented Nov 29, 2025

Note

Adds a new custom MCPAgent example using HUD Gateway with tracing and updates gateway docs to link and describe it.

  • Examples:
    • New script: examples/05_custom_agent.py
      • Implements MyAgent (MCPAgent) using HUD Gateway via OpenAI-compatible client
      • Instruments get_response with @instrument for tracing and usage logging
      • Supports tool/function calling and formats content/tool results
      • Runnable demo with MCP config and task execution
  • Docs:
    • Gateway docs (docs/gateway/index.mdx): Add “Building Custom Agents with Tracing” section linking to the new example, highlighting @instrument, MCPAgent usage, automatic token/latency tracking, and HUD Dashboard for traces.

Written by Cursor Bugbot for commit 5536010. 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.

ℹ️ 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 63 to 66
async def get_system_messages(self) -> list[types.ContentBlock]:
"""Return system prompt as content blocks."""
system_text = self.system_prompt or "You are a helpful assistant."
return [types.TextContent(type="text", text=system_text)]

Choose a reason for hiding this comment

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

P1 Badge Build system messages in OpenAI chat format

In examples/05_custom_agent.py lines 63-66, get_system_messages returns mcp.types.TextContent objects. _run_context passes these messages directly into AsyncOpenAI.chat.completions.create, which expects dictionaries with role/content. Supplying ContentBlock instances will raise OpenAI client validation/type errors before any inference runs, so the example crashes immediately. Construct system messages as OpenAI-style dicts (as in other OpenAI agents) instead of MCP content blocks.

Useful? React with 👍 / 👎.

Copy link
Contributor

@Parth220 Parth220 left a comment

Choose a reason for hiding this comment

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

We should update the docs to reference this file for hud gateway

@Parth220 Parth220 merged commit c9cf371 into main Nov 29, 2025
11 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.

2 participants