<?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 Soufiane Amini on Medium]]></title>
        <description><![CDATA[Stories by Soufiane Amini on Medium]]></description>
        <link>https://medium.com/@soufianeamini2002?source=rss-1beb0bd77da4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*niYcV6Iy_bTiJUb3</url>
            <title>Stories by Soufiane Amini on Medium</title>
            <link>https://medium.com/@soufianeamini2002?source=rss-1beb0bd77da4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 14:20:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@soufianeamini2002/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[Create an Agent That Generates Agent Spec: Turning Business Requirements into Open Agent Spec…]]></title>
            <link>https://medium.com/oracledevs/create-an-agent-that-generates-agent-spec-turning-business-requirements-into-open-agent-spec-7a94254df3bc?source=rss-1beb0bd77da4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a94254df3bc</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Soufiane Amini]]></dc:creator>
            <pubDate>Wed, 18 Feb 2026 16:27:31 GMT</pubDate>
            <atom:updated>2026-02-18T16:27:31.252Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create an Agent That Generates Agent Spec: Turning Business Requirements into Open Agent Spec Configs</h3><h4><em>Translating plain English into portable agent and workflow configurations for WayFlow or LangGraph</em></h4><p><em>In this tutorial, we will create an assistant that generates Agent Spec configurations using Agent Spec, allowing you to transform business requirements expressed using natural language into streamlined processes that you can deploy with any agent runtime.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MecG4-QALzL0WKsEKUmwVg.jpeg" /></figure><h4>Key Takeaways</h4><ul><li>You can turn a plain-English business brief into an agent or workflow configuration that runs as a reproducible end-to-end process.</li><li>Agent Spec keeps what you build portable, so the same agent and flow can move across compatible runtimes.</li><li>An llms.txt file gives the model the “house style” and APIs up front, so outputs are faster, more consistent, and require less repetitive prompting.</li></ul><h3>Introduction</h3><p>The rise of no-code AI tools is transforming how people build and automate complex workflows — no engineering background required. Today’s large language models (LLMs), and the platforms they power, enable anyone to design reproducible, end-to-end pipelines using simple natural language instructions. From data processing to decision automation, AI agents are lowering the barrier to innovation. This guide explores how non-technical users can harness these tools to turn ideas into reliable, repeatable systems with ease.</p><p>This tutorial is aimed at people that are not on the technical side of the spectrum, yet need to fulfill a need that may require the usage of Agents in the process. We will leverage the proposed standard named <a href="https://llmstxt.org/">llms.txt</a>, in order to give context to the LLM in order for it to know how to use a specific framework, along with Agent Spec.</p><p>Using an agent with an llms.txt is a simpler way of creating Agent Spec configuration that bypasses the context reading performed by Codex/Claude Code/OpenCode that’s done each time the CLI is ran, and allows us to directly generate multiple configurations with the right context of the library.</p><p>You’ll also learn how to export and reuse your agent across multiple compatible agentic frameworks, preserving flexibility for future applications.</p><h3>Why Agent Spec?</h3><p>Agent Spec is a <strong>framework-agnostic declarative specification </strong>designed to make AI agents and workflows portable, reusable, and executable across any compatible framework.</p><p>Agent Spec addresses the ongoing challenge of fragmentation in AI agent development, where different frameworks like AutoGen, LangGraph, and CrewAI lack a shared foundation, hindering portability and reuse.</p><p>Agent Spec enables developers to define AI agents and workflows that can be easily run, maintained, and adapted across various platforms and runtimes without rewriting code. This standardization benefits enterprises by streamlining scalability, reducing platform lock-in, simplifying maintenance, and enabling seamless collaboration both internally and with external partners.</p><blockquote><em>You can find more about the Agent Spec motivation and vision at </em><a href="https://oracle.github.io/agent-spec/agentspec/intro_and_motivation.html"><em>https://oracle.github.io/agent-spec/agentspec/intro_and_motivation.html</em></a></blockquote><blockquote><em>Also, you can read the full Agent Spec documentation at </em><a href="https://oracle.github.io/agent-spec/"><em>https://oracle.github.io/agent-spec/</em></a></blockquote><p>We will use WayFlow (see <a href="https://github.com/oracle/wayflow)">https://github.com/oracle/wayflow)</a> and LangGraph (see <a href="https://github.com/langchain-ai/langgraph)">https://github.com/langchain-ai/langgraph)</a> as the runtimes in this tutorial.</p><h3>Tutorial Overview: What we’ll build</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*G8W6HrkqhIB4fSFJ8k3lIQ.png" /><figcaption>Agent Spec Generation assistant diagram</figcaption></figure><p>In this tutorial, we’re going to build an Agent Spec Generation assistant. We’ll also showcase how to build a more complex, bonus assistant that can help with creating the first assistant, in cases where an llms.txt file for a specific framework is not available.</p><h3>Agent Spec configuration generation assistant</h3><p>The assistant we’ll build is going to be an assistant that takes the generated llms.txt file from the pyagentspec codebase, and be fed that file as context in the system prompt. We will also give it a tool that validates the generated configuration.</p><p>Let’s get started!</p><h4>Prerequisite — setting up the environment</h4><p>First, create and activate a virtual environment</p><pre># Create and activate <br>python -m venv venv-agentspec<br>source venv-agentspec/bin/activate # On Windows: venv-agentspec\Scripts\activate</pre><p>Next, install PyAgentSpec and WayFlow:</p><pre>pip install &quot;git+https://github.com/oracle/agent-spec.git#subdirectory=pyagentspec&quot; wayflowcore</pre><h4>Step 1: Create an LlmConfiguration</h4><pre>llm_config = OpenAiCompatibleConfig(<br>    name=&quot;gpt-oss-120b&quot;,<br>    url=get_base_url(),<br>    model_id=&quot;openai/gpt-oss-120b&quot;,<br>)</pre><h4>Step 2: Define our system prompt</h4><pre>from pathlib import Path<br>AGENT_SPEC_CODE_GENERATION_PROMPT = &quot;&quot;&quot;<br># ROLE<br><br>You are an expert at generating Agent Spec configurations.<br>You will be given the context of the Agent Spec python framework,<br>and your task is to generate python code that fulfills the requirements<br>of the user prompt.<br><br># Agent Spec: Complete Guide for LLM-Assisted Configuration Creation<br><br>## Introduction<br><br>Agent Spec is a portable, platform-agnostic configuration language for<br> defining agentic systems. It supports creating standalone agents and<br>structured workflows (flows) composed of connected nodes.<br>The Python pyagentspec SDK allows programmatic creation of components that<br>can be serialized to JSON/YAML.<br><br>Key components:<br>- **Agent**: Conversational LLM-powered assistants with tools<br>- **Flow**: Structured workflows with nodes and edges<br>- **Tool**: Functions available to agents (server/client/remote)<br>- **Property**: Input/output schemas with JSON Schema validation<br>- **Node**: Flow building blocks (StartNode, EndNode, LlmNode, AgentNode,<br> ToolNode, BranchingNode, etc.)<br>- **Edge**: Control flow and data flow connections between nodes<br><br>## Full API Reference<br><br>{{llms_context}}<br><br>## Common Patterns<br><br>- **Tool-augmented Agents**: Combine agents with ServerTools for<br> autonomous capabilities<br>- **LLM Chains**: Use LlmNode sequences for multi-step reasoning<br>- **Conditional Workflows**: BranchingNode + different paths for<br> decision trees<br>- **Agent Coordination**: Multiple AgentNodes in a flow for specialized tasks<br>- **Nested Flows**: FlowNode for hierarchical workflow organization<br><br>## Best Practices<br>1. **Property Inference**: Let pyagentspec infer inputs/outputs when<br> possible from templates and agent definitions<br>2. **Branching**: Always include a &quot;default&quot; branch in BranchingNode mappings<br>3. **Human-in-the-Loop**: Set `human_in_the_loop=True` when agents need user<br> approval for actions<br>4. **Serialization**: JSON is preferred to YAML when exporting a pyagentspec<br> assistant, using the AgentSpecSerializer class<br><br>## Generated code structure<br><br>The code that you generate should be concise, avoid comments as much<br> as possible, and avoid verbosely explaining the generated code.<br>If there&#39;s a section of the code that needs more explaining,<br>you can instead define functions that are well named,<br>containing docstrings that explain what the function creates.<br><br>## Important additions to the generated code<br>At the end of the generated code you should:<br>- Add a main function that serializes the code into JSON/YAML<br><br>- Pay attention to imports, if you have a file named:<br> pyagentspec/tools/servertool.py, you should at the very least<br> import the ServerTool class this way:<br> `from pyagentspec.tools.servertool import ServerTool`,<br> unless there is an example that showcases a better way to import the class.<br> DO NOT import everything with a plain `from pyagentspec`.<br><br>- Add the following function to allow the user to validate the generated<br> configuration:<br>&lt;validation_function&gt;<br>from pydantic import BaseModel, model_validator<br>from pyagentspec.validation_helpers import PyAgentSpecErrorDetails<br><br><br>class Json(BaseModel):<br>    value: str<br><br>    @model_validator(mode=&quot;after&quot;)<br>    def _validate_json(self) -&gt; &quot;Json&quot;:<br>        import json<br><br>        json.loads(self.value)<br>        return self<br><br><br>class Yaml(BaseModel):<br>    value: str<br><br>    @model_validator(mode=&quot;after&quot;)<br>    def _validate_yaml(self) -&gt; &quot;Yaml&quot;:<br>        import yaml<br><br>        yaml.safe_load(self.value)<br>        return self<br><br><br>def validate_agent_spec_configuration(config: Json | Yaml) -&gt; list[PyAgentSpecErrorDetails]:<br>    from pyagentspec.serialization import AgentSpecDeserializer, AgentSpecSerializer<br><br>    serializer = AgentSpecSerializer()<br>    deserializer = AgentSpecDeserializer()<br><br>    match config:<br>        case Json(value=value):<br>            component = deserializer.from_json(value)<br>        case Yaml(value=value):<br>            component = deserializer.from_yaml(value)<br>    dictionary = serializer.to_dict(component)<br>    _, errors = deserializer.from_partial_dict(dictionary)<br>    return errors<br>&lt;/validation_function&gt;<br><br>This guide provides the foundation for creating any Agent Spec<br>configuration using the pyagentspec SDK.<br>&quot;&quot;&quot;</pre><h4>Step 3: Create the Agent</h4><pre>agent = Agent(<br>    name=&quot;Agent Spec Codegen&quot;,<br>    llm_config=llm_config,<br>    system_prompt=AGENT_SPEC_CODE_GENERATION_PROMPT,<br>)</pre><h4>Step 4: Export the configuration into JSON</h4><pre>from pyagentspec import AgentSpecSerializer<br>from pathlib import Path<br><br>serializer = AgentSpecSerializer()<br>json_configuration = serializer.to_json(agent)<br>Path(&quot;agent_spec_generation_assistant.json&quot;).write_text(json_configuration)</pre><h4>Step 5: Run the Agent in WayFlow/LangGraph</h4><p>We’re going to use the agent that we just created in order to generate Agent Spec Configurations for various scenarios:</p><ul><li>Scenario 1: An assistant is needed to inform employees of their available PTO time.</li><li>Scenario 2: An assistant is needed to perform a simple profile information change.</li><li>Scenario 3: A flow that contains two agents, the first one generates code, the second one reviews and either returns the code if valid or improves on it.</li></ul><pre>from pathlib import Path<br>from pyagentspec.adapters.wayflowcore import AgentSpecLoader<br># llms.txt downloaded from the documentation, or generated from the bonus assistant<br>llms_context = Path(&quot;llms.txt&quot;).read_text()<br>agent_configuration = Path(&quot;agent_spec_generation_assistant.json&quot;).read_text()<br><br>scenarios = [<br>    &quot;Build a simple Agent that informs employees of their available PTO time.\<br> The assistant has 1 tool `get_pto(employee: str) -&gt; str` that it can use.&quot;,<br>    &quot;Build a simple Flow that runs a tool and calls a LLM&quot;,<br>    &quot;Build a Flow that given a user query to generate code,\<br> first generates the code with an LLM, then evaluates its quality with\<br> another LLM, and either returns the code directly if passing or improves\<br> the code (1 pass only, no looping)&quot;,<br>]<br><br>def run_agent_with_wayflow(scenario: str, scenario_number: int) -&gt; None:<br>    from wayflowcore import Agent as WayFlowAgent<br>    from wayflowcore.agentspec import AgentSpecLoader<br><br>    loader = AgentSpecLoader()<br>    wayflow_agent = cast(WayFlowAgent, loader.load_json(agent_configuration))<br>    conversation = wayflow_agent.start_conversation({<br>        &quot;llms_context&quot;: llms_context,<br>    })<br>    conversation.append_user_message(scenario)<br>    conversation.execute()<br>    message = conversation.get_last_message()<br>    if message:<br>        generated_code = str(message.content).replace(&quot;```python&quot;, &quot;&quot;).replace(&quot;\n```&quot;, &quot;&quot;)<br>        Path(f&quot;scenario_{scenario_number}_code.py&quot;).write_text(generated_code)<br><br><br>def run_agent_with_langgraph(scenario: str, scenario_number: int) -&gt; None:<br>    from langchain_core.messages import AIMessage<br>    from pyagentspec.adapters.langgraph import AgentSpecLoader as LangGraphAgentSpecLoader<br><br>    loader = LangGraphAgentSpecLoader()<br>    langgraph_agent = loader.load_json(agent_configuration)<br>    result = langgraph_agent.invoke({<br>        &quot;llms_context&quot;: llms_context,<br>        &quot;messages&quot;: [{<br>            &quot;role&quot;: &quot;user&quot;,<br>            &quot;content&quot;: scenario,<br>        }],<br>        &quot;remaining_steps&quot;: 1000,<br>    })<br>    message: AIMessage = result[&quot;messages&quot;][-1]<br>    if message:<br>        generated_code = str(message.content).replace(&quot;```python&quot;, &quot;&quot;).replace(&quot;\n```&quot;, &quot;&quot;)<br>        Path(f&quot;scenario_{scenario_number}_code.py&quot;).write_text(generated_code)<br><br><br>if __name__ == &quot;__main__&quot;:<br>    for scenario_number, scenario in enumerate(queries):<br>        # Run with WayFlow as the runtime<br>        # run_agent_with_wayflow(scenario, scenario_number)<br><br>        # Run with LangGraph as the runtime<br>        run_agent_with_langgraph(scenario, scenario_number)</pre><p>Running the above script, we get the following code for the third scenario:</p><pre>from __future__ import annotations<br><br>from pyagentspec.flows.edges.controlflowedge import ControlFlowEdge<br>from pyagentspec.flows.edges.dataflowedge import DataFlowEdge<br>from pyagentspec.flows.flow import Flow<br>from pyagentspec.flows.nodes.branchingnode import BranchingNode<br>from pyagentspec.flows.nodes.endnode import EndNode<br>from pyagentspec.flows.nodes.llmnode import LlmNode<br>from pyagentspec.flows.nodes.startnode import StartNode<br>from pyagentspec.llms.llmgenerationconfig import LlmGenerationConfig<br>from pyagentspec.llms.openaiconfig import OpenAiConfig<br>from pyagentspec.property import StringProperty<br><br><br>def build_codegen_quality_gate_flow() -&gt; Flow:<br>    llm_generate = OpenAiConfig(<br>        name=&quot;codegen-llm&quot;,<br>        model_id=&quot;gpt-4.1-mini&quot;,<br>        default_generation_parameters=LlmGenerationConfig(temperature=0.2, max_tokens=1800),<br>    )<br>    llm_judge = OpenAiConfig(<br>        name=&quot;judge-llm&quot;,<br>        model_id=&quot;gpt-4.1-mini&quot;,<br>        default_generation_parameters=LlmGenerationConfig(temperature=0.0, max_tokens=400),<br>    )<br>    llm_improve = OpenAiConfig(<br>        name=&quot;improve-llm&quot;,<br>        model_id=&quot;gpt-4.1-mini&quot;,<br>        default_generation_parameters=LlmGenerationConfig(temperature=0.2, max_tokens=2200),<br>    )<br><br>    user_query = StringProperty(<br>        title=&quot;user_query&quot;,<br>        description=&quot;User request describing what code to generate.&quot;,<br>    )<br>    generated_code = StringProperty(<br>        title=&quot;generated_code&quot;,<br>        description=&quot;Code produced by the generator LLM.&quot;,<br>    )<br>    quality_verdict = StringProperty(<br>        title=&quot;quality_verdict&quot;,<br>        description=&#39;Quality verdict; must be exactly &quot;PASS&quot; or &quot;FAIL&quot;.&#39;,<br>        json_schema={&quot;enum&quot;: [&quot;PASS&quot;, &quot;FAIL&quot;], &quot;type&quot;: &quot;string&quot;, &quot;title&quot;: &quot;quality_verdict&quot;},<br>    )<br>    final_code = StringProperty(<br>        title=&quot;final_code&quot;,<br>        description=&quot;Final code returned by the flow (either generated or improved).&quot;,<br>    )<br><br>    start = StartNode(name=&quot;start&quot;, inputs=[user_query])<br><br>    gen = LlmNode(<br>        name=&quot;generate_code&quot;,<br>        llm_config=llm_generate,<br>        prompt_template=(<br>            &quot;Generate code for the following request.\n&quot;<br>            &quot;Return ONLY the code (no backticks, no explanation).\n\n&quot;<br>            &quot;Request:\n{{user_query}}&quot;<br>        ),<br>        inputs=[user_query],<br>        outputs=[generated_code],<br>    )<br><br>    judge = LlmNode(<br>        name=&quot;evaluate_quality&quot;,<br>        llm_config=llm_judge,<br>        prompt_template=(<br>            &quot;You are a strict code reviewer.\n&quot;<br>            &quot;Evaluate the code against the request.\n&quot;<br>            &quot;Reply with exactly one token: PASS or FAIL.\n\n&quot;<br>            &quot;Request:\n{{user_query}}\n\n&quot;<br>            &quot;Code:\n{{generated_code}}&quot;<br>        ),<br>        inputs=[user_query, generated_code],<br>        outputs=[quality_verdict],<br>    )<br><br>    gate = BranchingNode(<br>        name=&quot;quality_gate&quot;,<br>        mapping={&quot;PASS&quot;: &quot;PASS&quot;},<br>        inputs=[quality_verdict],<br>    )<br><br>    pass_end = EndNode(name=&quot;pass_end&quot;, branch_name=&quot;PASS&quot;, outputs=[final_code])<br>    fail_improve = LlmNode(<br>        name=&quot;improve_code_once&quot;,<br>        llm_config=llm_improve,<br>        prompt_template=(<br>            &quot;Improve the given code to better satisfy the request.\n&quot;<br>            &quot;Fix bugs, missing requirements, and style issues.\n&quot;<br>            &quot;Return ONLY the improved code (no backticks, no explanation).\n\n&quot;<br>            &quot;Request:\n{{user_query}}\n\n&quot;<br>            &quot;Original code:\n{{generated_code}}&quot;<br>        ),<br>        inputs=[user_query, generated_code],<br>        outputs=[final_code],<br>    )<br>    improved_end = EndNode(<br>        name=&quot;improved_end&quot;,<br>        branch_name=BranchingNode.DEFAULT_BRANCH,<br>        outputs=[final_code],<br>    )<br><br>    return Flow(<br>        name=&quot;code_generation_quality_gate_flow&quot;,<br>        start_node=start,<br>        nodes=[start, gen, judge, gate, fail_improve, pass_end, improved_end],<br>        control_flow_connections=[<br>            ControlFlowEdge(name=&quot;c1_start_to_gen&quot;, from_node=start, to_node=gen),<br>            ControlFlowEdge(name=&quot;c2_gen_to_judge&quot;, from_node=gen, to_node=judge),<br>            ControlFlowEdge(name=&quot;c3_judge_to_gate&quot;, from_node=judge, to_node=gate),<br>            ControlFlowEdge(<br>                name=&quot;c4_gate_to_pass_end&quot;,<br>                from_node=gate,<br>                from_branch=&quot;PASS&quot;,<br>                to_node=pass_end,<br>            ),<br>            ControlFlowEdge(<br>                name=&quot;c5_gate_to_improve&quot;,<br>                from_node=gate,<br>                from_branch=BranchingNode.DEFAULT_BRANCH,<br>                to_node=fail_improve,<br>            ),<br>            ControlFlowEdge(name=&quot;c6_improve_to_end&quot;, from_node=fail_improve, to_node=improved_end),<br>        ],<br>        data_flow_connections=[<br>            DataFlowEdge(<br>                name=&quot;d1_query_to_gen&quot;,<br>                source_node=start,<br>                source_output=&quot;user_query&quot;,<br>                destination_node=gen,<br>                destination_input=&quot;user_query&quot;,<br>            ),<br>            DataFlowEdge(<br>                name=&quot;d2_query_to_judge&quot;,<br>                source_node=start,<br>                source_output=&quot;user_query&quot;,<br>                destination_node=judge,<br>                destination_input=&quot;user_query&quot;,<br>            ),<br>            DataFlowEdge(<br>                name=&quot;d3_code_to_judge&quot;,<br>                source_node=gen,<br>                source_output=&quot;generated_code&quot;,<br>                destination_node=judge,<br>                destination_input=&quot;generated_code&quot;,<br>            ),<br>            DataFlowEdge(<br>                name=&quot;d4_verdict_to_gate&quot;,<br>                source_node=judge,<br>                source_output=&quot;quality_verdict&quot;,<br>                destination_node=gate,<br>                destination_input=&quot;quality_verdict&quot;,<br>            ),<br>            DataFlowEdge(<br>                name=&quot;d5_generated_to_pass_end&quot;,<br>                source_node=gen,<br>                source_output=&quot;generated_code&quot;,<br>                destination_node=pass_end,<br>                destination_input=&quot;final_code&quot;,<br>            ),<br>            DataFlowEdge(<br>                name=&quot;d6_query_to_improve&quot;,<br>                source_node=start,<br>                source_output=&quot;user_query&quot;,<br>                destination_node=fail_improve,<br>                destination_input=&quot;user_query&quot;,<br>            ),<br>            DataFlowEdge(<br>                name=&quot;d7_generated_to_improve&quot;,<br>                source_node=gen,<br>                source_output=&quot;generated_code&quot;,<br>                destination_node=fail_improve,<br>                destination_input=&quot;generated_code&quot;,<br>            ),<br>            DataFlowEdge(<br>                name=&quot;d8_improved_to_end&quot;,<br>                source_node=fail_improve,<br>                source_output=&quot;final_code&quot;,<br>                destination_node=improved_end,<br>                destination_input=&quot;final_code&quot;,<br>            ),<br>        ],<br>    )<br><br><br>def main() -&gt; None:<br>    from pyagentspec.serialization.serializer import AgentSpecSerializer<br><br>    flow = build_codegen_quality_gate_flow()<br>    serializer = AgentSpecSerializer()<br>    print(serializer.to_json(flow))<br><br><br>from pydantic import BaseModel, model_validator<br><br>from pyagentspec.validation_helpers import PyAgentSpecErrorDetails<br><br><br>class Json(BaseModel):<br>    value: str<br><br>    @model_validator(mode=&quot;after&quot;)<br>    def _validate_json(self) -&gt; &quot;Json&quot;:<br>        import json<br><br>        json.loads(self.value)<br>        return self<br><br><br>class Yaml(BaseModel):<br>    value: str<br><br>    @model_validator(mode=&quot;after&quot;)<br>    def _validate_yaml(self) -&gt; &quot;Yaml&quot;:<br>        import yaml<br><br>        yaml.safe_load(self.value)<br>        return self<br><br><br>def validate_agent_spec_configuration(config: Json | Yaml) -&gt; list[PyAgentSpecErrorDetails]:<br>    from pyagentspec.serialization import AgentSpecDeserializer, AgentSpecSerializer<br><br>    serializer = AgentSpecSerializer()<br>    deserializer = AgentSpecDeserializer()<br><br>    match config:<br>        case Json(value=value):<br>            component = deserializer.from_json(value)<br>        case Yaml(value=value):<br>            component = deserializer.from_yaml(value)<br>    dictionary = serializer.to_dict(component)<br>    _, errors = deserializer.from_partial_dict(dictionary)<br>    return errors<br><br><br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>The generated configuration can then be loaded in any runtime of your choice, tested and deployed.</p><h3>Bonus assistant: llms.txt generator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*qmQnIC9wcJfv-pq1vjiV2g.png" /></figure><p>The bonus assistant we’re going to build is an assistant that is going to be tasked with generating an llms.txt file from any (python) codebase. We will split up the task per file, giving access to only the public APIs that those files expose, and generate a compact documentation for it.</p><p>This method allows us to narrow down the scope of the llm, needing very little context (the size of an average python file in a codebase which usually ranges between 200 to 1000 lines of code), and the task can be easily parallelized.</p><h4>Step 1: Defining our llms.txt generator flow</h4><p>The llm.txt generator flow performs the following 3 steps:</p><ul><li>List all the files that contain public APIs for the pyagentspec SDK</li><li>For each file, generate a compact documentation in markdown format</li><li>Finally, concatenate the result of all the generation into a single string</li></ul><p>We’re going to make use of a few AgentSpec nodes, mainly ToolNode, LlmNode, and ParallelMapNode.</p><p>First, we’ll define the properties that will be used in the flow:</p><pre>source_path_prop = StringProperty(title=&quot;source_path&quot;)<br>public_api_paths_prop = ListProperty(title=&quot;public_api_paths&quot;, item_type=StringProperty())<br>file_path_prop = StringProperty(title=&quot;file_path&quot;)<br>file_paths_prop = ListProperty(title=&quot;file_paths&quot;, item_type=file_path_prop)<br>file_content_prop = StringProperty(title=&quot;file_content&quot;)<br>generated_text_prop = StringProperty(title=&quot;generated_text&quot;)<br>collected_file_path_prop = ListProperty(title=&quot;collected_file_path&quot;, item_type=file_path_prop)<br>llms_txt_prop = StringProperty(title=&quot;llms_txt&quot;)<br>collected_generated_text_prop = ListProperty(<br>    title=&quot;collected_generated_text&quot;,<br>    item_type=generated_text_prop,<br>    default=[],<br>)<br>iterated_file_path_prop = UnionProperty(<br>    title=&quot;iterated_file_path&quot;,<br>    any_of=[<br>        file_path_prop,<br>        file_paths_prop,<br>    ],<br>)</pre><p>Next, we’ll define the ToolNode that lists the files that contain the public APIs of the package:</p><pre># ToolNode to list all the public apis in the codebase<br>list_public_apis_tool = ServerTool(<br>    name=&quot;get_path_of_public_apis&quot;,<br>    inputs=[source_path_prop],<br>    outputs=[public_api_paths_prop],<br>)<br><br>list_public_apis_node = ToolNode(<br>    name=&quot;get_public_apis_node&quot;,<br>    tool=list_public_apis_tool,<br>)</pre><p>The ToolNode above will return a list of strings referring to the paths of the public api files.</p><p>Following that, we need to define a subflow that will take a single file as input, and generate a section of the llms.txt:</p><pre># ToolNode to read a file&#39;s contents<br>read_file_tool = ServerTool(<br>    name=&quot;read_file&quot;,<br>    inputs=[file_path_prop],<br>    outputs=[file_content_prop],<br>)<br>read_file_node = ToolNode(name=&quot;read_file_node&quot;, tool=read_file_tool)<br><br>LLM_TXT_GENERATION_PROMPT = &#39;&#39;&#39;<br>Given a file from a codebase, write a compact summary of the public APIs,<br> following the requested format.<br><br>Instructions:<br>- Remove imports<br>- Remove private classes and functions (private = leading with an underscore `_`)<br>- Remove private methods, classvars and attributes of classes<br>- Keep the examples but remove the rest of the docstrings<br>- Simplify classvar docstring when non-informative<br>- Keep only one example from the docstring preferably,<br> the one that would be most general and useful for the LLM<br><br>If there are multiple classes/functions in a given file,<br>include them all (as long as they are public).<br>If you find an attribute that is not meant to be known or used publicly<br>(such as the min version attribute in Component) you can also discard it<br>in your output.<br><br><br>Example:<br>&lt;example&gt;<br>&lt;input_file&gt;<br>&quot;&quot;&quot;This module defines several Agent Spec components.&quot;&quot;&quot;<br><br>from typing import List<br><br>from pydantic import Field, SerializeAsAny<br><br>from pyagentspec.agenticcomponent import AgenticComponent<br>from pyagentspec.llms.llmconfig import LlmConfig<br>from pyagentspec.property import Property<br>from pyagentspec.templating import get_placeholder_properties_from_json_object<br>from pyagentspec.tools.tool import Tool<br>from pyagentspec.tools.toolbox import ToolBox<br>from pyagentspec.versioning import AgentSpecVersionEnum<br><br><br>class Agent(AgenticComponent):<br>    &quot;&quot;&quot;<br>    An agent is a component that can do several rounds of conversation to solve a task.<br><br>    It can be executed by itself, or be executed in a flow using an AgentNode.<br><br><br>    Examples<br>    --------<br>    &gt;&gt;&gt; from pyagentspec.agent import Agent<br>    &gt;&gt;&gt; from pyagentspec.property import Property<br>    &gt;&gt;&gt; expertise_property=Property(<br>    ...     json_schema={&quot;title&quot;: &quot;domain_of_expertise&quot;, &quot;type&quot;: &quot;string&quot;}<br>    ... )<br>    &gt;&gt;&gt; system_prompt = &quot;&quot;&quot;You are an expert in {domain_of_expertise}.<br>    ... Please help the users with their requests.&quot;&quot;&quot;<br>    &gt;&gt;&gt; agent = Agent(<br>    ...     name=&quot;Adaptive expert agent&quot;,<br>    ...     system_prompt=system_prompt,<br>    ...     llm_config=llm_config,<br>    ...     inputs=[expertise_property],<br>    ... )<br><br>    &quot;&quot;&quot;<br><br>    llm_config: SerializeAsAny[LlmConfig]<br>    &quot;&quot;&quot;Configuration of the LLM to use for this Agent&quot;&quot;&quot;<br>    system_prompt: str<br>    &quot;&quot;&quot;Initial system prompt used for the initialization of the agent&#39;s context&quot;&quot;&quot;<br>    tools: List[SerializeAsAny[Tool]] = Field(default_factory=list)<br>    &quot;&quot;&quot;List of tools that the agent can use to fulfil user requests&quot;&quot;&quot;<br>    toolboxes: List[SerializeAsAny[ToolBox]] = Field(default_factory=list)<br>    &quot;&quot;&quot;List of toolboxes that are passed to the agent.&quot;&quot;&quot;<br>    human_in_the_loop: bool = True<br>    &quot;&quot;&quot;Flag that determines if the Agent can request input from the user.&quot;&quot;&quot;<br><br>    def _get_inferred_inputs(self) -&gt; List[Property]:<br>        # Extract all the placeholders in the prompt and make them string inputs by default<br>        return get_placeholder_properties_from_json_object(getattr(self, &quot;system_prompt&quot;, &quot;&quot;))<br><br>    def _get_inferred_outputs(self) -&gt; List[Property]:<br>        return self.outputs or []<br><br>    def _versioned_model_fields_to_exclude(<br>        self, agentspec_version: AgentSpecVersionEnum<br>    ) -&gt; set[str]:<br>        fields_to_exclude = set()<br>        if agentspec_version &lt; AgentSpecVersionEnum.v25_4_2:<br>            fields_to_exclude.add(&quot;toolboxes&quot;)<br>            fields_to_exclude.add(&quot;human_in_the_loop&quot;)<br>        return fields_to_exclude<br><br>    def _infer_min_agentspec_version_from_configuration(self) -&gt; AgentSpecVersionEnum:<br>        parent_min_version = super()._infer_min_agentspec_version_from_configuration()<br>        current_object_min_version = self.min_agentspec_version<br>        if self.toolboxes or not self.human_in_the_loop:<br>            # We first check if the component requires toolboxes)<br>            # If that&#39;s the case, we set the min version to 25.4.2, when toolboxes were introduced<br>            # Similarly, human_in_the_loop was only added in 25.4.2 (human_in_the_loop=True was<br>            # the de-facto default before)<br>            current_object_min_version = AgentSpecVersionEnum.v25_4_2<br>        return max(parent_min_version, current_object_min_version)<br><br>&lt;/input_file&gt;<br><br>The following would be accepted:<br>&lt;answer&gt;<br># pyagentspec.agent.Agent<br>class Agent(AgenticComponent):<br>    # can do several rounds of conversations to solve a task<br>    # can be used in Flow with AgentNode<br>    &quot;&quot;&quot;<br>    Example<br>    --------<br>    &gt;&gt;&gt; from pyagentspec.agent import Agent<br>    &gt;&gt;&gt; from pyagentspec.property import Property<br>    &gt;&gt;&gt; expertise_property=Property(<br>    ...     json_schema={&quot;title&quot;: &quot;domain_of_expertise&quot;, &quot;type&quot;: &quot;string&quot;}<br>    ... )<br>    &gt;&gt;&gt; system_prompt = &quot;&quot;&quot;You are an expert in {domain_of_expertise}.<br>    ... Please help the users with their requests.&quot;&quot;&quot;<br>    &gt;&gt;&gt; agent = Agent(<br>    ...     name=&quot;Adaptive expert agent&quot;,<br>    ...     system_prompt=system_prompt,<br>    ...     llm_config=llm_config,<br>    ...     inputs=[expertise_property],<br>    ... )<br>    &quot;&quot;&quot;<br><br>    llm_config: LlmConfig<br>    system_prompt: str # prompt used for the initialization of the agent&#39;s context<br>    tools: List[Tool] = Field(default_factory=list)<br>    toolboxes: List[ToolBox] = Field(default_factory=list)<br>    human_in_the_loop: bool = True # whether the Agent can request input from the user<br><br>&lt;/answer&gt;<br>&lt;/example&gt;<br><br>---<br><br>Here is the file:<br>&lt;file_path&gt;<br>{{file_path}}<br>&lt;/file_path&gt;<br>&lt;input_file&gt;<br>{{file_content}}<br>&lt;/input_file&gt;<br>&#39;&#39;&#39;<br><br># LLM node to generate compact documentation for one file<br>generate_node = LlmNode(<br>    name=&quot;llms_txt_generator&quot;,<br>    llm_config=OpenAiCompatibleConfig(<br>        name=&quot;gpt-oss-120b&quot;,<br>        url=os.environ[&quot;OSS_API_URL&quot;],<br>        model_id=&quot;openai/gpt-oss-120b&quot;,<br>    ),<br>    prompt_template=LLM_TXT_GENERATION_PROMPT,<br>    inputs=[<br>        file_content_prop,<br>        file_path_prop,<br>    ],<br>    outputs=[generated_text_prop],<br>)</pre><p>We also need to define a ToolNode that is responsible for concatenating the result of the summarization performed on each public API, into one single file.</p><pre>concat_docs_tool = ServerTool(<br>    name=&quot;concat_compact_docs&quot;,<br>    inputs=[collected_file_path_prop, collected_generated_text_prop],<br>    outputs=[llms_txt_prop],<br>)<br>concat_docs_node = ToolNode(<br>    name=&quot;concat_docs_node&quot;,<br>    tool=concat_docs_tool,<br>)</pre><p>Next, we define the sub-flow that is going to be called inside a MapNode, which is a node that can apply a flow to each element of a collection, and can be easily parallelized:</p><pre># Map subflow, to generate a compact documentation using an llm, given a file path<br>builder = FlowBuilder()<br>## Nodes<br>builder.add_node(read_file_node).add_node(generate_node)<br>builder.set_entry_point(read_file_node, [file_path_prop])<br>builder.set_finish_points(generate_node, cast(<br>    list[Property], [generated_text_prop])<br>)<br><br>## Control Flow Edges<br>builder.add_edge(read_file_node, generate_node)<br><br>## Data Flow Edges<br>builder.add_data_edge(&quot;StartNode&quot;, read_file_node, file_path_prop.title)<br>builder.add_data_edge(&quot;StartNode&quot;, generate_node, file_path_prop.title)<br>builder.add_data_edge(read_file_node, generate_node, file_content_prop.title)<br>builder.add_data_edge(generate_node, &quot;EndNode_1&quot;, generated_text_prop.title)<br>map_subflow = builder.build(&quot;GenerateCompactDocSubflow&quot;)</pre><p>Notice that in the sub-flow above, we need to connect the file_path property from the Start Node to both the read_file_node (to read the file contents) and the generate_node (to output the path of the file + the summarized content right below it).</p><p>Next, defining the MapNode is as simple as declaring the inputs (property whose title is prefixed with “iterated_”) and outputs (property whose title is prefixed with “collected_”):</p><pre># Map over all public API paths and collect results<br>map_node = MapNode(<br>    name=&quot;map_public_apis&quot;,<br>    subflow=map_subflow,<br>    inputs=[iterated_file_path_prop],<br>    outputs=[collected_generated_text_prop],<br>)</pre><p>Finally, we define our top level flow that performs all of the mentioned operations, listing the public APIs, generating a compact documentation for each portion of the APIs and then concatenating the result into a single text:</p><pre># Top-level flow: list -&gt; map -&gt; concat<br>builder = FlowBuilder()<br>builder.add_sequence(<br>    [<br>        list_public_apis_node,<br>        map_node,<br>        concat_docs_node,<br>    ]<br>)<br>builder.set_entry_point(list_public_apis_node, [source_path_prop])<br>builder.set_finish_points(concat_docs_node, cast(list[Property], [llms_txt_prop]))<br>builder.add_data_edge(<br>    &quot;StartNode&quot;,<br>    list_public_apis_node,<br>    source_path_prop.title,<br>)<br>builder.add_data_edge(<br>    list_public_apis_node, map_node, (public_api_paths_prop.title, iterated_file_path_prop.title)<br>)<br>builder.add_data_edge(<br>    map_node,<br>    concat_docs_node,<br>    collected_generated_text_prop.title,<br>)<br>builder.add_data_edge(<br>    list_public_apis_node,<br>    concat_docs_node,<br>    (public_api_paths_prop.title, collected_file_path_prop.title),<br>)<br>builder.add_data_edge(concat_docs_node, &quot;EndNode_1&quot;, llms_txt_prop.title)<br>flow = builder.build(&quot;GenerateLLMsTxtFlow&quot;)</pre><h4>Step 2: Defining our basic functions for reading files and fetching paths of public APIs</h4><p>Our Agent Spec configuration for the first flow is complete. However, in order to run it, we need to define the implementation of the various tools that are used inside ToolNodes.</p><p>We have defined three ToolNodes that contain ServerTools. Below are an example implementation that can be used for this use case:</p><pre>def read_file(file_path: str) -&gt; str:<br>    return Path(file_path).read_text()<br><br>def get_path_of_public_apis(root_source_path: str) -&gt; list[str]:<br>    paths: list[str] = []<br>    for root, _, files in os.walk(root_source_path):<br>        root_path = Path(root)<br>        if root_path.name.startswith(&quot;_&quot;):<br>            continue<br>        for file in files:<br>            if file.startswith(&quot;_&quot;) or not file.endswith(&quot;.py&quot;):<br>                continue<br>            paths.append(f&quot;{root}/{file}&quot;)<br>    return paths<br><br>def read_file(file_path: str) -&gt; dict[str, str]:<br>    return {&quot;file_content&quot;: Path(file_path).read_text()}<br><br>def concat_compact_docs(<br>    collected_file_path: list[str],<br>    collected_generated_text: list[str],<br>) -&gt; str:<br>    from textwrap import dedent<br><br>    result = &quot;&quot;<br>    for path, content in zip(collected_file_path, collected_generated_text):<br>        line = path<br>        result += dedent(f&quot;&quot;&quot;<br>{&quot;-&quot; * len(line)}<br>{line}<br>{&quot;-&quot; * len(line)}<br><br>{content}<br>            &quot;&quot;&quot;)<br>    return result</pre><h4>Step 3: Loading our Agent Spec configuration in WayFlow/LangGraph</h4><pre>def _resolve_default_src_path() -&gt; str:<br>    return str((Path(__file__).parent / &quot;../../pyagentspec/src/&quot;).resolve())<br><br><br>def run_and_write_with_wayflow() -&gt; Path:<br>    from wayflowcore.agentspec import AgentSpecLoader<br>    from wayflowcore.executors.executionstatus import FinishedStatus<br>    from wayflowcore.flow import Flow as WayFlowFlow<br><br>    wayflow_loader = AgentSpecLoader(<br>        tool_registry={<br>            &quot;get_path_of_public_apis&quot;: get_path_of_public_apis,<br>            &quot;read_file&quot;: read_file,<br>            &quot;concat_compact_docs&quot;: concat_compact_docs,<br>        }<br>    )<br><br>    wayflow_flow = wayflow_loader.load_component(flow)<br>    if not isinstance(wayflow_flow, WayFlowFlow):<br>        raise RuntimeError(&quot;Failed to load WayFlow flow from Agent Spec configuration&quot;)<br><br>    src = _resolve_default_src_path()<br>    conversation = wayflow_flow.start_conversation({&quot;source_path&quot;: src})<br>    status = wayflow_flow.execute(conversation)<br>    if not isinstance(status, FinishedStatus):<br>        raise RuntimeError(&quot;Flow didn&#39;t finish execution as expected&quot;)<br>    llms_txt = status.output_values[&quot;llms_txt&quot;]<br><br>    out_file = Path(&quot;generated-llms.txt&quot;)<br>    out_file.write_text(llms_txt)<br><br>    return out_file<br><br><br>def run_and_write_with_langgraph() -&gt; Path:<br>    from pyagentspec.adapters.langgraph import AgentSpecLoader<br><br>    langgraph_loader = AgentSpecLoader(<br>        tool_registry={<br>            &quot;get_path_of_public_apis&quot;: get_path_of_public_apis,<br>            &quot;read_file&quot;: read_file,<br>            &quot;concat_compact_docs&quot;: concat_compact_docs,<br>        }<br>    )<br>    langgraph_flow = langgraph_loader.load_component(flow)<br><br>    src = _resolve_default_src_path()<br>    result = langgraph_flow.invoke({&quot;inputs&quot;: {&quot;source_path&quot;: src}})<br>    llms_txt: str = result[&quot;outputs&quot;][&quot;llms_txt&quot;]<br><br>    out_file = Path(&quot;generated-llms.txt&quot;)<br>    out_file.write_text(llms_txt.strip())<br><br>    return out_file<br><br><br>if __name__ == &quot;__main__&quot;:<br>    ##  Run with WayFlow<br>    # out_path = run_and_write_with_wayflow()<br><br>    # Run with LangGraph<br>    out_path = run_and_write_with_langgraph()<br><br>    print(f&quot;Wrote to file: {out_path}&quot;)</pre><h4>Step 4: Exporting the Agent Spec configuration</h4><p>After sufficient testing and validation, you can now export the Agent Spec configuration. This will allow you to take the generated json/yaml configuration, and load it in any Agent Spec compatible framework.</p><pre>from pyagentspec.serialization import AgentSpecSerializer<br><br>serialized_flow = AgentSpecSerializer().to_json(flow)</pre><h3>Going further</h3><p>Going further, keep it simple: pick one small, real task and try your assistant on it. Write a plain‑language goal, run it, then tweak the instructions and try again. Save what works and share it; add one small step at a time — the aim is helpful, not perfect.</p><p>Worth noting that if you use an llms.txt, you can also plug it directly into agentic coding tools (for example Codex, Claude Code, or even OpenClaw) so the agent can immediately “learn” how to generate new agents and run the right commands with far less manual prompting.</p><h3>GitHub Repository</h3><p>You can access all the code used in this article on the Agent Spec Github repository: <a href="https://github.com/oracle/agent-spec/">https://github.com/oracle/agent-spec/</a></p><p>P.S: If you have uv installed, you can easily run the examples with the command uv run . The dependencies will be installed automatically thanks to the inline script metadata inside the scripts.</p><h3>Conclusion</h3><p>In this article we’ve learned how to leverage agents and llms.txt files in order to generate Agent Spec configurations using simple natural language.</p><h3>Frequently Asked Questions (FAQs)</h3><h4>Do I need to be technical to use this approach in Agent Spec?</h4><p>Not really. The whole point is to let non-technical users express needs in natural language, while the assistant produces structured Agent Spec configurations that engineers (or platforms) can execute and validate.</p><h4>What does llms.txt actually do—and why use it here?</h4><p>Think of llms.txt as a compact “reference sheet” you give the model so it knows the framework’s public APIs and patterns up front. That means the agent can generate Agent Spec configurations more consistently, with less repeated context and fewer prompt tweaks.</p><h4>What’s the practical difference between an “agent” and a “flow”?</h4><p>An agent is a conversational worker (often tool-using). A flow is the assembly line: multiple steps (LLMs, tools, branching, parallelism) wired into a repeatable process — great for reliability, governance, and scaling beyond a single chat interaction.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a94254df3bc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/create-an-agent-that-generates-agent-spec-turning-business-requirements-into-open-agent-spec-7a94254df3bc">Create an Agent That Generates Agent Spec: Turning Business Requirements into Open Agent Spec…</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>