Article: The Self-Building Agent: A LangChain4j Experiment A LangChain4j experiment directed an LLM-backed code assistant to use the framework's documentation to design and implement a multi-agent coding system that could write, test, and debug code. The self-built agent fixed real bugs and passed tests, while a comparison of agentic AI patterns found the more rigid workflow pattern executes three times faster than the autonomous supervisor pattern. The experiment also demonstrated that the same agent design failed with an older, cheaper model due to a tool-calling loop but succeeded with a newer model. Key Takeaways - We directed an LLM-backed code assistant to use the LangChain4j documentation and API to design and implement a multi-agent coding system of its own. - The self-built coding agent then fixed real bugs, passed tests, and exposed its own execution flow through LangChain4j. - We compared two key agentic AI patterns and found that the more rigid workflow pattern executes three times faster than the more autonomous supervisor pattern by eliminating LLM-induced coordination overhead. - Using the newly introduced MonitoredAgent interface, it is possible to get a clear report of the agent invocations and the system topology of an agentic system implementation. - In the experiment, the same agent design failed with an older, cheaper model by entering a tool-calling loop, but completed the bug-fix task successfully with a newer model. We decided to try a bit of a meta-experiment: We handed a code assistant the LangChain4j documentation and asked it to build a version of itself. Specifically, we wanted it to design a multi-agent system that could write, test, and debug code just like a human engineer, or a code assistant itself, would. The fact that an LLM could build a version of itself from the documentation suggests two things about LangChain4j. First, the API was legible enough for the model to use directly. Second, the framework provided enough orchestration for the generated system to run end to end on a real debugging task. This project also gave us a chance to stress-test LangChain4j's new monitoring tools. When you let an AI build another AI, you really need to see what happens under the hood. This article explains how the experiment went and looks at the resulting project, which is available in this repository https://github.com/mariofusco/langchain4j-agentic-coder . "Vibe Coding" an Agentic System To let the code assistant build a first agentic coder of its own, we wrote the following prompt: Study the API and capabilities of the LangChain4j agentic framework from its documentation and source code, and design an agentic coder based on it that is a clone of yourself. After a few minutes of thinking and working with this prompt, the assistant decided LangChain4j’s supervisor pattern https://docs.langchain4j.dev/tutorials/agents supervisor-design-and-customization was the best fit for the task. It came up with an initial architecture: public interface SupervisorCoderSystem { @SupervisorAgent description = """ A multi-agent coding assistant that can explore codebases, plan implementations, write/edit code, and run builds/tests. It orchestrates specialized sub-agents to fulfill coding requests. """, subAgents = { ExplorerAgent.class, PlannerAgent.class, ImplementerAgent.class, ExecutorAgent.class, } @Override String code @K UserRequest.class String request, @K WorkingDirectory.class String workingDirectory ; @SupervisorRequest static String request @K UserRequest.class String userRequest, @K WorkingDirectory.class String workingDirectory { return "Using '" + workingDirectory + "' as your working directory, fulfill the following user request: " + userRequest; } } The code assistant also designed and developed four subagents used by the supervisor, along with their system and user messages. These agents explored the existing code, created a plan for the actions to take, implemented those actions following the plan, and put the generated code to work by compiling and executing it. The code assistant then implemented and correctly provided the necessary tools for each agent: a file system explorer for the explorer agent, a code editor for the implementer agent, and a way to run code for the executor agent. The results were impressive for a first iteration. If you have worked with a code assistant before, you know this is more or less the pattern you will see "professional" assistants use in the real world: They generally perform the same four actions that are modeled by the four agents generated during our experiment. The assistant then orchestrates these actions in a supervisor-like way to achieve the task at hand, again like our implementation. The coding assistant’s ability to design and implement such a system suggests it has knowledge of its own internal workings, at least at a high level, and can translate that understanding into a concrete design for an agentic system. Putting the Agentic Coder to Work To test the agentic coder designed by the code assistant, we asked it to write some buggy code and then use the newly created system to fix it. The code assistant generated the following Calculator class with four slightly buggy methods: / A simple calculator that performs basic arithmetic operations on lists of numbers. / public class Calculator { / Returns the sum of all numbers in the list. / public int sum List