Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Building a Real Multi-Step AI Agent with Gemini Function Calling (Not Just a Chatbot)

Описание и применение

Создание многократного агента на Gemini с функцией вызова инструментов, ограничением шагов и возможностью потоковой передачи результатов.

Задача

Create an AI agent that can iteratively call tools and decide when to answer, rather than a single-shot chatbot.

Результат

A reusable starter kit demonstrates a multi‑step AI agent with tool calling, step limits, and optional streaming.

Рабочий процесс

  • Define tool schemas (e.g., calculator)
  • Implement runAgentLoop that calls model.generateContent with tools
  • If result has no functionCalls, return final text
  • For each functionCall, execute runTool and append result to messages
  • Repeat until final answer or MAX_STEPS reached
  • Optionally stream each step via Server‑Sent Events

Доказательства

Most "AI chat" tutorials stop at single-shot request/response. You send a message, the model replies, done.

Источник

Without a cap, a confused model could theoretically call tools in a loop forever. MAX_STEPS is a safety valve, not an optimization — it guarantees the request always terminates.

Источник

Rather than making the user wait for the whole loop to finish, you can stream each step as it happens using Server‑Sent Events — the user sees "calling calculator... got 564... calling get_current_time..." live, instead of a blank spinner.

Источник

  • Дата записи: 2026-10-01T21:55:51.682Z