How I built a smart agent with just one function — and why it matters

Leader posted Originally published at medium.com 3 min read

Do you know, you can take a regular Python function — like one that generates a random ID — and turn it into something an AI agent can use. Like, you type “Give me a new ID,” and boom — it runs your code and gives you the result.

No magic. No huge models. Just Python + Microsoft’s Agent Framework. And it’s awesome.
![][1]

What Is an AI Agent?
Let’s break it down. An AI agent is like a smart assistant that can:

Understand what you say (natural language)
Decide what to do (reasoning)
Call tools or functions (action)
Give you a response (output)
It’s not just a chatbot. It’s more like a mini brain that can run your code, fetch data, and even talk to other agents if you want.

What Is the Microsoft Agent Framework?
The Microsoft Agent Framework is an open source, that helps you build these smart agents. It’s designed to be:

Logic-first: You don’t need a huge language model to get started.
Modular: You can plug in tools, APIs, and workflows.
Fast: It runs locally and responds quickly.
Developer-friendly: You write Python, not prompts.
It’s perfect for people who want to build agents that actually do things — not just chat.

What’s a Tool?
In this framework, a tool is just a Python function that the agent can call. You wrap your function using something called FunctionTool, and the agent knows how to use it.

So instead of typing generate_guid() in your terminal, you can just say:

“Hey agent, give me a new GUID.”

And it runs your function and gives you the result. That’s the part that blew my mind

️ How to do this?
Here’s how I did it.

Step 1: Write the Function

def generate_guid(): 
               import uuid 
               return str(uuid.uuid4())

This function creates a random GUID (Globally Unique Identifier). It’s like a super long ID that no one else has.

Step 2: Wrap It as a Tool

AzureOpenAIChatClient(
    endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
    deployment_name = os.getenv("AZURE_AI_DEPLOYMENT_NAME"),
    api_key = os.getenv("AZURE_OPENAI_API_KEY"),
    api_version = os.getenv("AZURE_OPENAI_API_VERSION")
).create_agent(
    instructions="INSTRUCTIONS",
    name="AGENT_NAME",
    tools=[tools.generate_guid]
)

This tells the agent: “Here’s a tool you can use.”

And boom — it works! The agent reads your message, figures out which tool to call, and runs your function.

Why This Is So Cool
You don’t need a huge AI model to do smart stuff.
You can use your own Python code.
It’s fast and easy to test.
You can build agents that actually do things — not just chat.

Let’s Talk Theory: Why Agentic Systems Matter
Agentic systems are the future of AI. Instead of just generating text, agents can:

  • Reason over tasks
  • Call external tools
  • Maintain memory
  • Make decisions

This is a big shift from traditional chatbots. It’s like going from a calculator to a personal assistant that can code, fetch data, and automate stuff.

Microsoft’s Agent Framework is part of this movement. It gives you the building blocks to create agents that are:

  • Deterministic: You know exactly what they’ll do.
  • Composable: You can add or remove tools easily.
  • Scalable: You can build bigger systems over time.

How Is This Different from AutoGen and Semantic Kernel?
Let’s compare:

  • AutoGen*
    AutoGen is great for multi-agent reasoning. You can have agents talk to each other and solve complex problems. But it’s very LLM-heavy and harder to set up.

  • Semantic Kernel*
    Semantic Kernel is more like a planner. It’s good for organizing tasks and using plugins. But it’s more abstract and less direct when it comes to tool wrapping.

  • Microsoft Agent Framework*
    This one is perfect for beginners and pros who want control. You write Python functions, wrap them as tools, and build agents that run your logic.

What Can You Build?
You can wrap any of these as tools and let your agent call them. It’s like building your own Jarvis from Iron Man

Best Practices I Learned
Keep your functions clean and simple.
Use type hints so the agent knows what to expect.
Add good descriptions to your tools.
Test each tool before adding it to the agent.
Use AgentThread to simulate conversations.

Final Thoughts
Isn’t it wild?

If you’re into coding, automation, or AI, you should totally try this. Microsoft Agent Framework makes it super easy, and you don’t need to be an expert.

So yeah — turn your Python functions into tools, build smart agents, and have fun doing it.

Want More?
I’m working on a video where I show this step-by-step. Subscribe to my channel and drop a comment if you want me to build a more complex system next!
Video link: https://youtu.be/TUjSONHV6xY?si=tOdFAYJYHzuar_Rm

Thanks for reading!
[1]: https://coderlegion.com/?qa=blob&qa_blobid=7737465330093435870

If you read this far, tweet to the author to show them you care. Tweet a Thanks

1 Comment

0 votes

More Posts

This writeup will show you, how I built smart agents using Microsoft Agent Framework without LLM

Shweta Lodha - Oct 14

How I Built PromptBank: The AI-Powered Bank That Lets You Yell at Your Money (And It Listens)

Fred - Oct 17

Building Intelligent Workflows Without LLMs: With Microsoft Agent Framework

Shweta Lodha - Oct 16

AI Agents might kill Ads - And no One's talking about it

Payezhi Chegattil Abhishek - Aug 13

Why You Can’t Build a Real SaaS Just by “Vibe Coding”

Sourav Bandyopadhyay - Jul 3
chevron_left