<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/what-if-an-agent-could-refactor-your-agent--cwukdrewh" -->

---
title: What if an agent could refactor your agent? | daily.dev
description: A walkthrough shows using GitHub Copilot's coding agent, grounded on Microsoft Foundry skills, to audit and refactor an existing cupcake-ordering agent...
canonical: https://daily.dev/posts/what-if-an-agent-could-refactor-your-agent--cwukdrewh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: What if an agent could refactor your agent? | daily.dev
og:description: A walkthrough shows using GitHub Copilot's coding agent, grounded on Microsoft Foundry skills, to audit and refactor an existing cupcake-ordering agent...
og:url: https://daily.dev/posts/what-if-an-agent-could-refactor-your-agent--cwukdrewh
og:image: https://api.daily.dev/og/posts/CWUkdrewh.png
og:image:alt: What if an agent could refactor your agent?
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# What if an agent could refactor your agent?

**[Microsoft Developer](https://daily.dev/sources/microsoftdeveloper)** · 5 min read · 0 upvotes · 0 comments

## Summary

A walkthrough shows using GitHub Copilot's coding agent, grounded on Microsoft Foundry skills, to audit and refactor an existing cupcake-ordering agent project. Copilot flags issues like outdated SDK usage, direct MCP server connections instead of using the Foundry toolbox, and missing observability. It then updates config files (azure.yaml, .env, main.py) to add OpenTelemetry tracing and switch to the toolbox pattern, and the updated agent is tested locally via the Foundry inspector.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=X-uQwleiUwA>

## Questions this post answers

### How can I check if my AI agent code follows Microsoft Foundry best practices?

Ground GitHub Copilot's coding agent with the Microsoft Foundry Toolkit extension and ask it directly whether the agent follows correct patterns. In one walkthrough, Copilot flagged an outdated SDK version, a direct MCP server connection that should instead go through the Foundry toolbox, and missing observability configuration.

_Developers auditing agent code for best practices can find similar walkthroughs on daily.dev._

### What is the difference between connecting directly to an MCP server versus using the Foundry toolbox in an agent project?

Connecting directly to an MCP server bypasses recommended patterns, while using the Foundry toolbox is the recommended approach for Microsoft Foundry-based agents. Switching from a direct MCP connection to the toolbox required updating azure.yaml, the .env file, and main.py to remove direct server references and route through the toolbox instead.

_Teams choosing between MCP integration approaches can track patterns like this on daily.dev._

## Similar posts on daily.dev

- [Build Your Own Custom Agents](https://daily.dev/posts/build-your-own-custom-agents-lscjdejoj) · Visual Studio Blog · 12 upvotes · 0 comments
- [Building AI agents with the GitHub Copilot SDK](https://daily.dev/posts/building-ai-agents-with-the-github-copilot-sdk-tauv44gc4) · InfoWorld · 1 upvotes · 0 comments

---

Tags: [#github](https://daily.dev/tags/github), [#ai-agents](https://daily.dev/tags/ai-agents), [#azure](https://daily.dev/tags/azure), [#observability](https://daily.dev/tags/observability), [#mcp](https://daily.dev/tags/mcp)

[View this post on daily.dev](https://daily.dev/posts/what-if-an-agent-could-refactor-your-agent--cwukdrewh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"What if an agent could refactor your agent?","url":"https://daily.dev/posts/what-if-an-agent-could-refactor-your-agent--cwukdrewh","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/what-if-an-agent-could-refactor-your-agent--cwukdrewh"},"datePublished":"2026-09-15T14:43:09.947Z","dateModified":"2026-09-15T14:43:30.257Z","description":"A walkthrough shows using GitHub Copilot's coding agent, grounded on Microsoft Foundry skills, to audit and refactor an existing cupcake-ordering agent...","image":"https://i.ytimg.com/vi/X-uQwleiUwA/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/X-uQwleiUwA/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Microsoft Developer","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Microsoft Developer","logo":"https://media.daily.dev/image/upload/s--xZzU3zUq--/f_auto/v1746714872/logos/microsoftdeveloper","url":"https://daily.dev/sources/microsoftdeveloper"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/what-if-an-agent-could-refactor-your-agent--cwukdrewh","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"github,ai-agents,azure,observability,mcp","timeRequired":"PT5M","video":{"@type":"VideoObject","name":"What if an agent could refactor your agent?","description":"A walkthrough shows using GitHub Copilot's coding agent, grounded on Microsoft Foundry skills, to audit and refactor an existing cupcake-ordering agent...","thumbnailUrl":"https://i.ytimg.com/vi/X-uQwleiUwA/sddefault.jpg","uploadDate":"2026-09-15T14:43:09.947Z","duration":"PT5M","url":"https://api.daily.dev/r/CWUkdrewh","embedUrl":"https://www.youtube.com/embed/X-uQwleiUwA"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Microsoft Developer","item":"https://daily.dev/sources/microsoftdeveloper"},{"@type":"ListItem","position":3,"name":"What if an agent could refactor your agent?"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/what-if-an-agent-could-refactor-your-agent--cwukdrewh#faq","mainEntity":[{"@type":"Question","name":"How can I check if my AI agent code follows Microsoft Foundry best practices?","acceptedAnswer":{"@type":"Answer","text":"Ground GitHub Copilot's coding agent with the Microsoft Foundry Toolkit extension and ask it directly whether the agent follows correct patterns. In one walkthrough, Copilot flagged an outdated SDK version, a direct MCP server connection that should instead go through the Foundry toolbox, and missing observability configuration. Developers auditing agent code for best practices can find similar walkthroughs on daily.dev."}},{"@type":"Question","name":"What is the difference between connecting directly to an MCP server versus using the Foundry toolbox in an agent project?","acceptedAnswer":{"@type":"Answer","text":"Connecting directly to an MCP server bypasses recommended patterns, while using the Foundry toolbox is the recommended approach for Microsoft Foundry-based agents. Switching from a direct MCP connection to the toolbox required updating azure.yaml, the .env file, and main.py to remove direct server references and route through the toolbox instead. Teams choosing between MCP integration approaches can track patterns like this on daily.dev."}}]}
```

