Python Automation

How to Build AI Agents in Python: The Andrade Gutierrez + BotCity Case

With more than 230 automations already running in production, Andrade Gutierrez needed to go beyond mechanical execution and add intelligence capable of learning from exceptions and generating instant insights—all while maintaining governance control.

To achieve this, the Hyperautomation CoE used the BotCity platform to build and orchestrate AI Agents that enhanced these automations. One of these automations, focused on the CoE’s own governance, analyzes code and produces documentation. The result: 250 SDDs generated in just 15 seconds each—something that previously took an average of 2 hours.

According to Pieter Voloshyn, Andrade Gutierrez’s IT Manager and project lead, “APA doesn’t replace RPA; it expands and complements it. It’s a new paradigm to rethink how we automate knowledge and decision-making.”

RPA vs. APA: A New Generation of Automation

Even with a robust RPA environment, Andrade Gutierrez needed automations that could learn and adapt to the company’s daily business changes. By creating AI Agents in Python with the BotCity platform, the automations could:

  • Adapt in real time: each agent evaluates context on the spot; when a rule changes, the workflow adjusts without requiring extensive code rewriting.

  • Process unstructured data sources: LLMs are excellent at handling unstructured inputs like PDFs, images, and emails.

  • Deliver faster: from ideation to validation, a functional agent can be prototyped in just a few hours compared to days with traditional RPA.

  • Handle exceptions: using LLMs and Python validations broadened automation coverage, reducing failures that once required human intervention.

How an AI Agent in Python Works

The foundation of APA lies in AI Agents, which are autonomous software components capable of analyzing the environment, making strategic decisions to achieve goals, and executing the necessary actions—all with a high degree of independence and adaptability.

To understand how they operate in practice, the basic architecture of an AI Agent, inspired by concepts presented by Erimateia Lima, includes:

  • Reasoning Engine (LLMs): Large Language Models (LLMs) such as OpenAI, Anthropic, and Gemini AI are responsible for developing the reasoning strategy, taking actions, and making observations.

  • Planning: Based on prompts (like the system prompt) and strategies such as Chain of Thought (CoT) and Reasoning & Action (ReAct), which guide the agent’s behavior.

  • Memory: Short-term (current interaction) and long-term (useful information stored, for example, in vector databases).

  • Tools (Functions/Capabilities): Allow the agent to interact with the external environment, such as databases, BPMS systems, RPAs, APIs, and complex scripts.

  • Knowledge Base (Context Augmentation/RAG): Uses vector databases for content indexing, enabling the agent to access relevant information such as legal or supply chain standards for complex analysis.

  • Guardrails (Protective Barriers): Imposing limits and content filtering to ensure the agent operates within safe and ethical parameters, avoiding inappropriate responses.

The cycle of an agent, based on the ReAct concept, involves: Thinking (defining the objective), Acting (executing a task with the available tools), and Observing (analyzing the result and comparing it to the objective, adjusting reasoning if necessary).

Multi-Agent Architecture Applied at Andrade Gutierrez

To address the challenges of complex processes, Andrade Gutierrez leveraged BotCity to implement multi-agent architectures. This means that, instead of relying on a single automation, multiple AI agents work together toward a larger goal.

How does this work in practice at Andrade Gutierrez?
A real example is the creation of SDDs (Solution Design Documents). Instead of a single overloaded agent, BotCity enabled Andrade Gutierrez to build a multi-agent system for this task.

This intelligent system can delegate tasks to specialized agents, such as:

  • An agent for “inspect_code”

  • Another for “describe_automation”

  • A third for “describe_components”

  • And so on, with agents for “describe_requirements”, “design_flow”, “generate_executive_summary”, and “generate_sdd”

Each of these specialized agents has its own “brain” (LLM reasoning engine), “hands” (tools to interact with source code), memory (to handle documentation context), knowledge (about SDD standards), and guardrails (to ensure document quality).

This allowed Andrade Gutierrez to automate processes that were once unthinkable, delivering speed, accuracy, and governance. This multi-agent model was only possible because BotCity’s technical infrastructure provided:

  • Native Python execution: Ideal for any agent-defined logic, integrating with LLMs (including local ones!), APIs, and complex scripts.

  • No reliance on rigid structures: Full freedom for modeling and orchestration.

  • Compatibility with multiple frameworks: Easily integrates with LangGraph, CrewAI, PydanticAI, OpenAI SDK, Semantic Kernel.

  • Execution across multiple environments: Supports local, server, cloud, VMs, and containers.

  • Interoperability with diverse systems: Connects to SAP, Web, Windows, APIs, databases, files, and over 500,000 open-source libraries.

Real Use Cases at Andrade Gutierrez

Case #1: Creating SDDs (Solution Design Documents)

  • Goal: Automate the creation of SDDs based on automation source code.

  • How it was done: Agents created with LangGraph. The process involves inspect_code, describe_automation, describe_components, describe_requirements, design_flow, generate_executive_summary, and generate_sdd.

  • Result:

    • Average time reduced from 2 hours to just 15 seconds.

    • Over 250 documents generated automatically.

Case #2: SAP HCM Integration Analysis

  • Goal: Map SQL integrations with the payroll system for SAP HCM pre-migration.

  • How it was done: Agents created with LangGraph. The flow includes inspect_code, extract_sql_commands, describe_sql_commands, and generate_report.

  • Result:

    • Entire analysis completed in ~10 minutes—a task that was previously manual and time-consuming.

Future Projects with APA at Andrade Gutierrez

Andrade Gutierrez is already expanding the use of intelligent agents into new automation fronts, all using frameworks such as LangGraph, PydanticAI, and CrewAI integrated with the BotCity platform.

Additionally, automations that already leveraged Generative AI will be enhanced with agent-based capabilities.

1. Telecom Invoice Processing

    • The current automation will be enhanced with agents that validate business rules and generate automatic feedback on inconsistencies in data extraction.

    • This increases reliability and reduces human rework.

    • Main flow: open_invoice → extract_data → validate_data

      2. Identifying the Responsible Party for Digitally Signed Documents

      • Agents will interpret the metadata of signed documents to accurately identify the legal responsible party for each signature.

      • The agent’s logic ensures contextual and robust validation.

      • Main flow: open_document → extract_responsible_party → validate_data

Conclusion

Andrade Gutierrez’s experience shows that by adopting BotCity, technical teams can quickly create and deploy AI agents written in Python, while maintaining full control over versioning, auditing, and permissions—all within the same platform that orchestrates existing automations.

This model accelerates value delivery, reduces operational failures, and ensures governance is embedded from the very first commit through large-scale monitoring.

To learn more about this use case, get in touch with our team of experts!

Leave a Reply

Discover more from Blog BotCity - Content for Automation and Governance

Subscribe now to keep reading and get access to the full archive.

Continue reading