<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mustafa Necati Özdoğan on Medium]]></title>
        <description><![CDATA[Stories by Mustafa Necati Özdoğan on Medium]]></description>
        <link>https://medium.com/@mustafanecatiozdogan?source=rss-8b99e803eb04------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*m1xplvdr7TMDrj38h5EkcA.png</url>
            <title>Stories by Mustafa Necati Özdoğan on Medium</title>
            <link>https://medium.com/@mustafanecatiozdogan?source=rss-8b99e803eb04------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:41:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mustafanecatiozdogan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Code Generation to Controlled Execution: Building an AI Coding Agent with AutoGen and Docker]]></title>
            <link>https://medium.com/@mustafanecatiozdogan/from-code-generation-to-controlled-execution-building-an-ai-coding-agent-with-autogen-and-docker-799d53e3e011?source=rss-8b99e803eb04------2</link>
            <guid isPermaLink="false">https://medium.com/p/799d53e3e011</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[autogen]]></category>
            <dc:creator><![CDATA[Mustafa Necati Özdoğan]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 14:58:24 GMT</pubDate>
            <atom:updated>2026-10-22T12:20:37.448Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mbdQoAl-pZE9EN4YRYoWKg.png" /><figcaption>AI-generated Python code, human approval and Docker-isolated execution — an iterative workflow built with AutoGen.</figcaption></figure><p><em>How I built a human-in-the-loop multi-agent workflow that generates Python code, requests approval, executes it in Docker and uses execution feedback to correct failures.</em></p><h3>Introduction</h3><p>Large language models can generate Python code from natural-language instructions in seconds. But generating code is only one part of the problem.</p><p>What happens when the generated code is incorrect? Should it execute automatically? How can a user review the code before execution? And how can an agentic workflow recover from failures without entering an endless correction loop?</p><p>These questions motivated my project, <strong>AI Python Code Builder &amp; Executor</strong>, built with Microsoft AutoGen, Python and Docker.</p><p>The goal was to explore a controlled, iterative workflow that combines AI-generated code with human oversight, containerized execution and feedback-driven correction.</p><p><strong>The central idea is simple:</strong></p><blockquote><em>Generate → Review → Execute → Fix → Review → Execute</em></blockquote><h3>1. Designing the Workflow</h3><p>I wanted to keep the architecture small and give each component a clear responsibility.</p><p>The workflow consists of four main elements:</p><ul><li><strong>AssistantAgent:</strong> Generates Python code and produces corrections when execution fails.</li><li><strong>Human approval:</strong> Allows the user to approve or reject each execution.</li><li><strong>CodeExecutorAgent:</strong> Coordinates approval and code execution.</li><li><strong>DockerCommandLineCodeExecutor:</strong> Runs approved code inside a Docker container.</li></ul><p>The agents are orchestrated using AutoGen’s RoundRobinGroupChat.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*l1JPWgheuhgLYTnbK6Uxvg.png" /></figure><p>The architecture separates code generation from code execution. The assistant focuses on reasoning and correction, while the executor handles the execution workflow.</p><p>This separation also makes the system easier to understand and extend without introducing additional agents unnecessarily.</p><h3>2. Human-in-the-Loop: Approval Before Execution</h3><p>One of the most important design decisions was to require explicit human approval before running generated code.</p><p>The CodeExecutorAgent supports an approval_func, which I use to request approval from the user.</p><pre>executor = CodeExecutorAgent(<br>    name=&quot;executor&quot;,<br>    code_executor=code_executor,<br>    approval_func=approval_func,<br>)</pre><p>The approval function displays a code preview and asks the user to approve or reject execution.</p><pre>============================================================<br> CODE EXECUTION APPROVAL<br>============================================================<br><br>Generated Python code:<br>------------------------------------------------------------<br>number = 10<br>def factorial(n):<br>    if n == 0:<br>        return 1<br>    return n * factorial(n - 1)<br>print(factorial(number))<br>------------------------------------------------------------<br>Execute this code?<br>[y] Yes, execute<br>[n] No, rejectp</pre><p>If the user approves, execution proceeds. If the user rejects it, the workflow terminates without executing the code.</p><p>Importantly, every corrected version must receive fresh approval. Approval of an earlier version does not authorize execution of a later one.</p><h3>Why approval_func Instead of UserProxyAgent?</h3><p>AutoGen provides different ways to incorporate human participation into agent workflows.</p><p>A UserProxyAgent can be useful when a human needs to participate in the conversation, answer questions, or provide additional information.</p><p>In this project, however, the human has a narrower responsibility: <strong>deciding whether generated code may execute.</strong></p><p>Using approval_func keeps that responsibility explicit without introducing another conversational participant solely for execution approval.</p><p>This is an example of a broader engineering principle: <strong>choose the smallest abstraction that satisfies the actual requirement.</strong></p><h3>3. Executing Code with Docker</h3><p>Running AI-generated code directly in the application’s Python process would tightly couple code execution to the host environment.</p><p>Instead, I use AutoGen’s DockerCommandLineCodeExecutor.</p><pre>code_executor = DockerCommandLineCodeExecutor(<br>    work_dir=CODE_WORK_DIR,<br>)</pre><p>The executor is started before the team runs and stopped afterward. This lifecycle management is important because the application should clean up its execution resources when the workflow finishes.</p><p>Docker provides an additional <strong>isolation boundary</strong> between the generated program and the application’s host Python process.</p><p>However, <strong>Docker should not be treated as an absolute security guarantee</strong>. The actual security level depends on container configuration, permissions, resource limits, networking and other runtime controls.</p><p>This project is a development and learning project, not a hardened sandbox for executing arbitrary hostile code.</p><p>A production-grade implementation would require further controls, potentially including CPU and memory limits, execution timeouts, network restrictions, read-only filesystems, non-root execution and additional sandboxing.</p><h3>4. Why the Executor Does Not Need a Model Client</h3><p>Another deliberate decision was to create the CodeExecutorAgent without a model client.</p><pre>executor = CodeExecutorAgent(<br>    name=&quot;executor&quot;,<br>    code_executor=code_executor,<br>    approval_func=approval_func,<br>)</pre><p>The responsibilities are separated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*zhmPa3rRi96sTIxDvQ-UzQ.png" /></figure><p>The assistant is responsible for LLM-based reasoning. The executor is responsible for coordinating execution.</p><p>Giving both components a model client would introduce an additional reasoning capability that this workflow does not need.</p><p>This decision keeps the architecture focused and makes the roles of the agents easier to reason about.</p><h3>5. Feedback-Driven Correction</h3><p>Code generation is rarely perfect on the first attempt. A program may contain a missing variable, an incorrect expression, or another runtime error.</p><p>The workflow uses execution feedback to support iterative correction.</p><p>For example, suppose the assistant generates code that references an undefined variable. The execution result is returned to the assistant, which can generate a corrected version.</p><p>Not every execution error should trigger another code-generation attempt. Ordinary execution failures can be sent back to the assistant for correction, but a missing or unloadable dependency is handled separately. In that case, the workflow stops and reports the dependency problem instead of repeatedly regenerating code that still depends on an unavailable package. Dependencies are not installed automatically; the Docker environment must be configured before retrying.</p><p>The user must then approve the corrected code before it executes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*a5u3SjmujQqXFvwVnVfhuA.png" /></figure><p>This feedback loop turns a simple code-generation example into a more useful agentic workflow.</p><p>It also introduces an important constraint: the system must know when to stop.</p><h3>6. Controlling the Workflow with Termination Conditions</h3><p>An iterative agent can repeatedly generate and execute corrections if <strong>failures are not bounded</strong>.</p><p>To avoid an unbounded correction loop, the project combines success detection, user-rejection handling, dependency-error detection and a maximum failed-execution count. The workflow also enforces an overall conversation limit through MAX_TURNS.</p><pre>successful_execution = FunctionalTermination(<br>    is_executor_result_successful<br>)<br>rejection_termination = FunctionalTermination(<br>    is_executor_result_rejected<br>)<br>dependency_termination = FunctionalTermination(<br>    is_executor_result_dependency_error<br>)<br>max_failures_termination = MaxExecutionFailuresTermination(<br>    max_failed_executions=MAX_FAILED_EXECUTIONS<br>)<br>termination = (<br>    successful_execution<br>    | rejection_termination<br>    | dependency_termination<br>    | max_failures_termination<br>)</pre><p>The project also uses MAX_TURNS as an overall conversation limit.</p><p>These controls serve different purposes:</p><ul><li><strong>Successful execution:</strong> Ends the workflow when the execution result is considered successful.</li><li><strong>User rejection:</strong> Stops when the user declines execution.</li><li><strong>Maximum failed executions:</strong> Prevents endless retries after repeated failures.</li><li><strong>Maximum turns:</strong> Places an additional bound on the overall agent conversation.</li></ul><p>The maximum failure count is configurable. Its default value is three.</p><h3>An Implementation Trade-Off in AutoGen 0.7.5</h3><p>In this implementation, the CodeExecutorAgent runs without a model client. The workflow therefore handles the executor&#39;s TextMessage output rather than relying on CodeExecutionEvent.result.exit_code.</p><p>A small adapter interprets the executor message and classifies it into one of four statuses: successful, failed, rejected or dependency error. This distinction allows the workflow to stop when a required dependency is missing or cannot be loaded, rather than treating every execution problem as an ordinary failure and attempting another correction.</p><p>This is a lightweight approach, but it has a limitation: interpreting execution status from message text is less robust than consuming a structured execution result. <strong>Changes in output formatting or previously unhandled error types can lead to incorrect classification.</strong></p><p>A future iteration could use structured execution events or a custom executor interface to distinguish program errors from timeouts, resource exhaustion and container failures more reliably.</p><p>This trade-off illustrates why agentic systems need more than a model and a tool call. Their orchestration logic must also account for failure handling and lifecycle management.</p><h3>7. Configuration and Testing</h3><p>The project uses environment-based configuration for values such as:</p><ul><li>OPENAI_API_KEY</li><li>OPENAI_MODEL</li><li>CODE_WORK_DIR</li><li>CODE_PREVIEW_MAX_LINES</li><li>MAX_FAILED_EXECUTIONS</li><li>MAX_TURNS</li></ul><p>Keeping these values configurable avoids hardcoding environment-specific settings into the application.</p><p>The project includes unit tests for executor result classification and the custom termination logic. These tests cover successful execution, ordinary failures, user rejection, dependency errors, failure limits and reset behavior.</p><p>Testing these cases is important because incorrect status classification can cause unnecessary retries or terminate the workflow at the wrong time. The tests focus on the classification and termination components; they are not a full end-to-end test of the OpenAI model, Docker runtime and interactive approval workflow.</p><p>For agentic applications, testing should cover not only the happy path but also rejection, repeated failures, reset behavior and unexpected execution results.</p><h3>8. Lessons Learned</h3><p>Building this project reinforced several engineering principles for me.</p><p><strong>1. Code generation and code execution are different responsibilities.</strong><br>A model producing plausible code does not mean that the code is correct or safe to execute.</p><p><strong>2. Human approval should be part of the workflow design.</strong><br>It should not be an afterthought added after automatic execution has already been implemented.</p><p><strong>3. Agentic workflows need explicit stopping conditions.</strong><br>Retries can improve results, but they must be bounded.</p><p><strong>4. Tool outputs need reliable interpretation.</strong><br>A workflow is only as reliable as the logic that interprets execution results and decides what happens next.</p><p><strong>5. Isolation and approval address different risks.</strong><br>Human approval provides a decision point; Docker provides an execution boundary. Neither replaces the need for appropriate security controls.</p><p><strong>6. Simple architectures can be effective.</strong><br>Using a small number of components with clear responsibilities made this project easier to reason about than adding more agents without a concrete need.</p><h3>9. Limitations and Future Improvements</h3><p>The current implementation focuses on a single Python code-generation and execution workflow. Several improvements could make it more robust:</p><ul><li>Use structured execution results instead of relying on message-text interpretation.</li><li>Improve the code-review experience for large generated programs so users can inspect the complete code before approving execution.</li><li>Add execution history and richer diagnostic information.</li><li>Support additional programming languages.</li><li>Add stronger sandboxing and resource controls.</li><li>Evaluate generated code quality before execution.</li></ul><p>These are not just feature additions. They would improve the reliability, observability and security of the workflow.</p><h3>Conclusion</h3><p>This project started with a simple question: what does it take to move from AI-generated code to controlled code execution?</p><p>The answer involves more than prompting an LLM. It requires explicit responsibilities, human approval, an execution environment, feedback handling and termination conditions.</p><p>By combining Microsoft AutoGen with Docker, I built a small workflow that explores these ideas in practice.</p><p>The project also reminded me that an agentic system is not defined only by how intelligently its model generates an answer. Its engineering quality depends on how it uses tools, handles failures, respects human decisions and knows when to stop.</p><p><strong>The next step is to make the workflow more observable, validate execution results more reliably and strengthen the execution boundary.</strong></p><p>You can explore the implementation here:</p><p><a href="https://github.com/mustafaOzdogan/ai-python-code-builder-executor"><strong>AI Python Code Builder &amp; Executor — GitHub Repository</strong></a></p><p><em>If you’re building agentic workflows, I’d be interested in hearing how you’re approaching human approval, execution isolation and failure handling in your own projects.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=799d53e3e011" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Multi-Agent Image Generation and Validation Workflow with AutoGen]]></title>
            <link>https://medium.com/@mustafanecatiozdogan/building-a-multi-agent-image-generation-and-validation-workflow-with-autogen-6c7873801545?source=rss-8b99e803eb04------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c7873801545</guid>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mustafa Necati Özdoğan]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 11:06:46 GMT</pubDate>
            <atom:updated>2026-09-27T20:08:19.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YIF-Go_rmm3vfZLL42Wf2w.png" /><figcaption>What If AI Could Review Its Own Images?</figcaption></figure><p><em>How I built an agentic workflow that generates images, validates them against user requirements, and iteratively refines failed results.</em></p><p>Generating an image with an AI model is relatively straightforward.</p><p>The more interesting engineering problem starts after the image has been generated:</p><p><strong>How do we know whether the result actually satisfies the user’s requirements?</strong></p><p>This question led me to build a small multi-agent system using <strong>Microsoft AutoGen’s </strong><strong>SelectorGroupChat</strong>.</p><p>The project generates an image, validates it against the original user requirements, and — if validation fails — uses the feedback to trigger another generation cycle.</p><p>The goal is not simply to generate an image.</p><p>The goal is to build a <strong>feedback-driven agentic workflow</strong>.</p><h3>The Problem</h3><p>Consider a simple request:</p><blockquote><em>Create a picture of a cat with exactly 3 ears.</em></blockquote><p>An image generation model may produce a cat, but it doesn’t necessarily guarantee that every explicit requirement will be satisfied.</p><p>For example, the first generated image could contain:</p><blockquote><em>A cat with 4 ears.</em></blockquote><p>A traditional image generation workflow would simply return that image to the user.</p><p>But an agentic workflow can do something different:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*LvS4_GAwQUFM5LBq4yXQzg.png" /></figure><p>This creates a closed feedback loop between generation and validation.</p><h3>Architecture</h3><p>The workflow consists of three main components:</p><ul><li>ImageGeneratorAgent</li><li>ImageValidatorAgent</li><li>SelectorGroupChat</li></ul><p>There are also two tools responsible for image generation and validation.</p><p>The overall architecture looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*5lB6m1sZaUhOJ4XJwoPqtw.png" /></figure><p>The SelectorGroupChat dynamically determines which agent should act next based on the current state of the conversation.</p><h3>1. ImageGeneratorAgent</h3><p>The first agent is responsible for generating the image.</p><p>It receives the user’s original requirements and calls the image generation tool.</p><p>The important part is that the generator also receives correction feedback when a previous validation fails.</p><p>For example:</p><pre>User Requirement: Create a picture of a cat with exactly 3 ears.</pre><p>The generator produces the first image.</p><p>If the validator later reports:</p><pre>OBSERVATION: The cat has four ears instead of three.<br>CORRECTION:  Generate the cat with exactly three ears.</pre><p>the generator can use this feedback during the next generation cycle.</p><p>The project currently uses gpt-image-1-mini for image generation.</p><h3>2. ImageValidatorAgent</h3><p>The second agent is responsible for answering a different question:</p><blockquote><em>Does the generated image satisfy the original requirements?</em></blockquote><p>This distinction is important.</p><p>The validator is not simply checking whether an image exists.</p><p>It receives both:</p><ol><li>The original user requirements</li><li>The generated image</li></ol><p>and passes them to the validation tool.</p><p>The validation result follows a simple contract.</p><p>For a successful validation:</p><pre>VALIDATION: PASS</pre><p>For a failed validation:</p><pre>VALIDATION :  FAIL<br>OBSERVATION:  &lt;what is wrong&gt;<br>CORRECTION :  &lt;what should be changed&gt;</pre><p>This makes the validation result useful not only as a boolean decision, but also as feedback for the next generation cycle.</p><h3>3. SelectorGroupChat</h3><p>This is where the agentic part becomes more interesting.</p><p>Instead of hard-coding a simple sequence such as:</p><pre>generator()<br>validator()<br>generator()<br>validator()</pre><p>the workflow uses AutoGen’s SelectorGroupChat to determine which agent should act next.</p><p>The selector follows rules similar to:</p><pre>New Request<br>     ↓<br>Generator<br>     ↓<br>Validator<br>     ↓<br>   PASS ──────► END<br>     │<br>    FAIL<br>     ↓<br>Generator<br>     ↓<br>Validator<br>     ↓<br>   PASS ──────► END</pre><p>The next agent therefore depends on the result of the previous step.</p><p>This allows the workflow to continue iterating only when the validation result requires another generation.</p><h3>An Example: The Four-Eared Cat</h3><p>Let’s look at the complete workflow.</p><p>The user starts with:</p><pre>Create a picture of a cat with exactly 3 ears.</pre><h3>First generation</h3><p>The ImageGeneratorAgent generates an image.</p><p>Suppose the result contains four ears.</p><pre>Generated Image<br>       ↓<br>Cat with 4 ears</pre><p>The validator receives the image together with the original requirement.</p><p>It returns:</p><pre>VALIDATION: FAIL</pre><pre>OBSERVATION: The cat has four ears instead of three.<br>CORRECTION : Generate the cat with exactly three ears.</pre><p>The selector detects the failed validation and selects the generator again.</p><h3>Second generation</h3><p>The generator uses the correction feedback:</p><pre>Generate the cat with exactly three ears.</pre><p>A new image is generated.</p><p>This time:</p><pre>Generated Image<br>       ↓<br>Cat with 3 ears</pre><p>The validator runs again:</p><pre>VALIDATION: PASS</pre><p>The workflow terminates.</p><p>The important point is that the system did not blindly accept the first generated image.</p><p>It used <strong>validation feedback to determine whether another generation was necessary</strong>.</p><h3>Why Use Multiple Agents?</h3><p>A single agent could theoretically handle the entire process.</p><p>However, separating responsibilities makes the workflow easier to reason about.</p><p>The responsibilities are clearly divided:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*fze2kDuZOKi_fwsFGNenag.png" /></figure><p>This separation also makes it easier to extend the system later with additional specialized agents.</p><h3>The Feedback Loop</h3><p>The core idea of the project can be summarized as:</p><pre>        ┌──────────────┐<br>        │   Generate   │<br>        └──────┬───────┘<br>               │<br>               ▼<br>        ┌──────────────┐<br>        │   Validate   │<br>        └──────┬───────┘<br>               │<br>          ┌────┴────┐<br>          │         │<br>        PASS       FAIL<br>          │         │<br>          ▼         ▼<br>         END    Feedback<br>                    │<br>                    ▼<br>                Generate</pre><p>This pattern is not limited to image generation.</p><p>The same architecture can be applied to other agentic workflows where an output needs to be evaluated before it is accepted.</p><p>For example:</p><ul><li>Code generation → code review → correction</li><li>Document generation → requirement validation → revision</li><li>SQL generation → query validation → correction</li><li>API generation → test execution → fixing</li><li>Content generation → quality evaluation → refinement</li></ul><p>The common pattern is:</p><pre>Generate → Evaluate → Feedback → Refine</pre><h3>Structured Validation</h3><p>One design decision I found particularly useful was keeping the validation output structured.</p><p>Instead of returning a long natural-language response, the validation tool produces a predictable format:</p><pre>VALIDATION : FAIL<br>OBSERVATION: ...<br>CORRECTION : ...</pre><p>This gives the workflow clear signals for routing.</p><p>For example:</p><pre>VALIDATION: PASS</pre><p>can terminate the workflow.</p><p>While:</p><pre>VALIDATION: FAIL</pre><p>means that the generator should receive correction feedback.</p><p>This is a simple mechanism, but it makes the interaction between agents much easier to control.</p><h3>Project Structure</h3><p>The repository is intentionally kept relatively small:</p><pre>.<br>├── README.md<br>├── config/<br>│   └── selector_group_chat.json<br>├── tools/<br>│   ├── generate_image.py<br>│   └── validate_image.py<br>├── examples/<br>│   ├── basic_generation.md<br>│   ├── validation_pass.md<br>│   └── iterative_refinement.md<br>├── images/<br>│   └── .gitkeep<br>├── requirements.txt<br>└── .env.example</pre><p>The selector_group_chat.json file contains the AutoGen SelectorGroupChat configuration, including the agents, tools, selector prompt, and termination conditions.</p><h3>Technology Stack</h3><p>The project currently uses:</p><ul><li>Python</li><li>Microsoft AutoGen</li><li>SelectorGroupChat</li><li>gpt-4o-mini for agent reasoning</li><li>gpt-image-1-mini for image generation</li><li>gpt-4.1-mini for image analysis</li></ul><p>The generated images are passed into the validation workflow through the image path produced by the generation tool.</p><h3>What I Learned</h3><p>Building this project highlighted an important distinction between <strong>AI generation</strong> and <strong>AI-driven workflows</strong>.</p><p>Calling an image generation API is only one step.</p><p>The more interesting engineering problems appear around it:</p><ul><li>How should agents divide responsibilities?</li><li>How should one agent communicate results to another?</li><li>How should failures be represented?</li><li>How should correction feedback be passed back to the generator?</li><li>When should the workflow terminate?</li><li>How can we prevent unnecessary iterations?</li><li>How should we handle cases where the validator itself is uncertain?</li></ul><p>These questions are what turn a simple model call into an agentic system.</p><h3>Limitations</h3><p>This project is intentionally a small proof of concept, so there are several areas that can be improved.</p><p>The validation process is model-based and therefore may not perfectly detect every visual discrepancy.</p><p>The current workflow also depends on the generated image being accessible through the path returned by the image generation tool.</p><p>Another important consideration is controlling the number of refinement cycles. Without an appropriate termination strategy, an agentic workflow can potentially continue iterating unnecessarily.</p><h3>What’s Next?</h3><p>There are several directions I would like to explore next:</p><ul><li><strong>Multiple Candidates</strong>: Instead of generating one image at a time, the system could generate multiple candidates and compare them.</li><li><strong>Quality Scoring:</strong> Requirement validation and visual quality could be separated:</li></ul><pre>Requirement Validation<br>        +<br>Visual Quality Score<br>        ↓<br>Final Selection</pre><ul><li><strong>Human Approval</strong>: A human could be added to the loop before the final image is accepted.</li><li><strong>Specialized Validators:</strong> Different validators could evaluate different aspects:</li></ul><pre>Requirement Validator<br>        │<br>        ├── Composition Validator<br>        ├── Object Validator<br>        ├── Text Validator<br>        └── Quality Validator</pre><ul><li><strong>Persistent History:</strong> The system could store generation and validation history so that previous attempts can be analyzed later.</li></ul><p>These are natural extensions of the current feedback-driven architecture.</p><h3>Conclusion</h3><p>This project started with a simple question:</p><blockquote><em>What if an AI-generated image could evaluate itself against the requirements before being accepted?</em></blockquote><p>The resulting architecture became a small multi-agent workflow:</p><pre>User<br> ↓<br>Generator Agent<br> ↓<br>Generated Image<br> ↓→<br>Validator Agent<br> ↓<br>Decision Step → PASS → Finish<br> ↓<br>FAIL<br> ↓<br>Correction Feedback<br> ↓<br>Generator Agent<br> ↓<br>New Image<br> ↓<br>Validate Again</pre><p>The interesting part is not just generating the image.</p><p>It is creating a system that can <strong>generate, evaluate, learn from the evaluation, and refine the result</strong>.</p><p>That feedback loop is one of the patterns I find particularly interesting when building agentic AI systems.</p><p><strong>Source code:</strong><br><a href="https://github.com/mustafaOzdogan/imageGenerationReviewMultiAgent">https://github.com/mustafaOzdogan/imageGenerationReviewMultiAgent</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c7873801545" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>