Day 3 — Building Your First Agent: Turning Gemini into a Task Planner

Welcome to Day 3 of the Task Helper Agent (Gemini Edition) series!
Now that your project is connected to Google AI Studio and you’ve successfully made your first Gemini API call, it’s time to build your first real agentic behaviour: turning a user goal into a structured plan.

Today, we’ll:

  • Design a clean system-style prompt
  • Implement your first agent method: plan_task()
  • Generate a real task plan from Gemini
  • Test everything through main.py
  • Add your first real example output

Let’s get started.


Goal for the Reader

Help Gemini turn a user goal into a structured, step-by-step plan.

Example:

  • Input: “Learn Python in 2 weeks”
  • Output: A clear, actionable list of steps

This becomes the foundation of your agentic workflow.


1. Explain What the AI Task Helper Will Do (v1)

Before building advanced reasoning or memory, we begin with a simple version:

V1 Agent Behaviour

  • Takes a user goal (e.g., “Learn Python in 2 weeks”)
  • Clarifies it in one sentence
  • Produces ~5–10 clear, numbered tasks
  • Keeps things simple, direct, and beginner-friendly

No planning loops. No multi-step reasoning yet.
Just clean structured output.

This is your agent’s “first brain.”


2. Designing the Prompt

Prompt engineering is a core part of agent design.

For Version 1, we want to give Gemini:

  • A system-style instruction
  • A fixed response structure
  • Simple constraints
  • Output that’s easy for users to read, and for you to extend later

We instruct the model to:

  • Produce numbered steps
  • Keep action items short
  • Respect any timeline mentioned
  • Provide a 1-sentence goal summary

This becomes the base prompt used by your plan_task() method.


3. Implement plan_task() in TaskHelperAgent

Open:

src/agent.py

Replace its content with this full Day 3 version:

from textwrap import dedent
from llm_client import generate_text


class TaskHelperAgent:
    """
    V1: Simple planning agent.
    No memory yet, no advanced reasoning, just structured planning.
    """

    def __init__(self):
        pass

    def plan_task(self, user_goal: str) -> str:
        """
        Ask Gemini to create a structured plan for the user's goal.
        """
        prompt = dedent(f"""
        You are an AI task planning assistant.

        The user will give you a goal. Your job:
        1. Clarify the goal briefly in one sentence.
        2. Break it into 5–10 clear, numbered steps.
        3. Keep the language simple and actionable.
        4. If there's a time frame in the goal, respect it.

        User goal:
        "{user_goal}"

        Now respond using this structure:

        Goal:
        - <one sentence>

        Plan:
        1. ...
        2. ...
        3. ...
        """).strip()

        return generate_text(prompt)

What this achieves:

  • It wraps all instructions into a single, clean prompt
  • It keeps output consistent for all future uses
  • It prepares the agent for more advanced features on Days 4–7

You’re officially building your first agentic behaviour.


4. Update main.py to Use Real Planning

Open:

src/main.py

Update it to:

from agent import TaskHelperAgent


def main():
    agent = TaskHelperAgent()
    example_goal = "Learn basic Python in 2 weeks"
    plan = agent.plan_task(example_goal)
    print("=== AI Task Helper Agent ===")
    print(plan)


if __name__ == "__main__":
    main()

Now your main script triggers the real planning agent instead of a stub.


5. Run & Show Example Output

Run it:

python src/main.py

You should see something like:

=== AI Task Helper Agent ===
Goal:
- Learn the fundamentals of Python programming within a two-week period.

Plan:
1. Install Python and set up a basic development environment.
2. Learn core syntax: variables, loops, conditionals, data types.
3. Practice small exercises daily (15–30 minutes).
4. Learn functions and modules.
5. Build a small project at the end of week one.
6. Explore lists, dictionaries, and common built-in methods.
7. Complete one or two beginner challenges each day.
8. Build a final mini-project to summarize everything.

This is your first working agent!
It takes a user goal → returns a structured plan.

What’s Next? (Day 4 Preview)

Tomorrow we’ll take this even further by:

  • Adding multi-step reasoning
  • Breaking tasks into phases
  • Making the agent smarter and more agentic
  • Implementing a two-step planning pipeline

This transforms your simple planner into a real agent.

Good foundational links

Leave a Comment

Your email address will not be published. Required fields are marked *