The post has been translated automatically. Original language: Russian
When developing and testing autonomous multi-agent systems, you face the main problem: AI agents start to loop endlessly, feed each other incorrect JSON schemas and instantly burn the API balance.
When there is an array of heterogeneous tasks in the backlog, classic approaches like Scrum or Kanban for scripts do not work. We need strict system protocols.
At VELARA, we solved this problem at the architectural level by implementing the Stafford Beer model of a viable system (VSM) from cybernetics into the routing logic. This approach formed the basis of our internal PFAF (Protocol-First Autonomous Flow) methodology.
What is the essence of the methodology?
PFAF shifts the focus from the "intelligence" of individual agents to the rigid protocols of their interaction. Instead of relying on the neural network's ability to correctly understand the context, the system is controlled by an end-to-end hierarchy of control. Agents do not communicate chaotically — each step, data transfer format, and financial limit are strictly regulated by the top-level architecture. If one element violates the protocol, the system isolates it before the chain reaction begins.
The structure of the framework by levels:
Level 4 (Intelligence / Intelligence): Data acquisition and OSINT modules that filter out external noise.
Level 3 (Control / CFO Agent): The "Financial" safety agent. He calculates the cost of tokens in real time. If the system starts to loop, the CFO immediately revokes the token budget of the entire session, protecting the developer's personal balance from a sudden zero.
Level 2 (Coordination): A router that intercepts payloads and runs them through hard JSON validators.
Level 1 (Operations): Isolated workforces (code writing, design, analytics).
The results of the stress test on 100 difficult tasks:
•Success rate: 100% backlog completion.
•Nuances: 22% of tasks went into internal retry due to broken JSON tags, but they successfully self-corrected.
•Local crutches: Frontend errors on Streamlit were closed via unsafe_allow_html=True, and LLM hallucinations with function calls were stopped by the hard hardcode of available tools in core/tools.py .
Stack: Self-hosted infrastructure on Ubuntu VPS in Docker, SQLite, Claude API (for logic) + Groq (for quick tasks).
Question to the Astana Hub community: How do you solve the problem of token tracking and semantic memory pruning when testing and scaling agent subsystems? Let's discuss it in the comments.
Rustam Eyyubov
Founder of VELARA — Autonomous AI Company
При разработке и тестировании автономных мультиагентных систем сталкиваешься с главной проблемой: AI-агенты начинают бесконечно зацикливаться, скармливать друг другу некорректные JSON-схемы и моментально сжигать баланс API.
Когда в бэклоге висит массив разнородных задач, классические подходы вроде Scrum или Kanban для скриптов не работают. Нужны жесткие системные протоколы.
Мы в VELARA решили эту проблему на уровне архитектуры, внедрив в логику роутинга модель жизнеспособной системы (VSM) Стаффорда Бира из кибернетики. Этот подход лег в основу нашей внутренней методологии PFAF (Protocol-First Autonomous Flow).
В чём суть методологии?
PFAF переносит фокус с «интеллекта» отдельных агентов на жесткие протоколы их взаимодействия. Вместо того чтобы полагаться на способность нейросети правильно понять контекст, система управляется сквозной иерархией контроля. Агенты не общаются хаотично — каждый шаг, формат передачи данных и финансовый лимит на выполнение жестко регламентированы архитектурой верхнего уровня. Если один элемент нарушает протокол, система изолирует его до того, как начнется цепная реакция.
Структура фреймворка по уровням:
Уровень 4 (Интеллект / Разведка): Модули сбора данных и OSINT, которые фильтруют внешний шум.
Уровень 3 (Контроль / CFO Agent): «Финансовый» агент-предохранитель. Он считает затраты на токены в реальном времени. Если система начинает зацикливаться — CFO моментально отзывает токен-бюджет всей сессии, защищая личный баланс разработчика от внезапного нуля.
Уровень 2 (Координация): Роутер, который перехватывает пейлоады и прогоняет их через жесткие JSON-валидаторы.
Уровень 1 (Операции): Изолированные подворкфлоу (написание кода, дизайн, аналитика).
Результаты стресс-теста на 100 сложных задачах:
•Успешность: 100% выполнение бэклога.
•Нюансы: 22% задач уходили во внутренний ретрай из-за битых JSON-тегов, но успешно самокорректировались.
•Локальные костыли: Ошибки фронтенда на Streamlit закрыли через unsafe_allow_html=True, а галлюцинации LLM с вызовами функций купировали жестким хардкодом доступных инструментов в core/tools.py.
Стек: Self-hosted инфраструктура на Ubuntu VPS в Docker, SQLite, Claude API (для логики) + Groq (для быстрых тасков).
Вопрос к комьюнити Astana Hub: Как вы решаете проблему трекинга токенов и очистки семантической памяти (memory pruning) при тестировании и масштабировании агентских подсистем? Давайте обсудим в комментариях.
Рустам Эюбов
Основатель VELARA — Autonomous AI Company