Automating the creation of tools that LLM agents can use is a critical bottleneck in building agentic systems. Doc2Agent generates executable Python tools from unstructured REST API documentation, while LRASGen generates OpenAPI specifications directly from source code. Together, they address the full API lifecycle – from code to spec to agent-usable tool.
Doc2Agent (2025) tackles the challenge of converting messy, incomplete API documentation into validated, executable Python functions that agents can invoke. The pipeline is fully automated with LLM-driven generation and live validation.
Pipeline Stages:
LRASGen (LLM-based RESTful API Specification Generation, 2025) addresses the upstream problem: many APIs lack proper specifications entirely. It uses LLMs to analyze source code and generate OpenAPI Specification (OAS) documents.
Key Capabilities:
When combined, these approaches form an end-to-end automated pipeline:
$$\text{Source Code} \xrightarrow{\text{LRASGen}} \text{OpenAPI Spec} \xrightarrow{\text{Doc2Agent}} \text{Agent Tools}$$
This eliminates manual specification writing and manual tool coding, enabling agents to interact with any API given only its codebase.
class APIToolGenerator: def __init__(self, llm, test_client): self.llm = llm self.test_client = test_client self.max_retries = 3 def generate_from_docs(self, api_docs: str) -> list: endpoints = self.llm.extract_endpoints(api_docs) tools = [] for endpoint in endpoints: tool_code = self.llm.generate_tool_function(endpoint) validated = self.validate_and_refine(tool_code, endpoint) if validated: tools.append(validated) return tools def validate_and_refine(self, tool_code, endpoint): for attempt in range(self.max_retries): result = self.test_client.execute(tool_code, endpoint.test_params) if result.status_code in (200, 201): return tool_code diagnosis = self.llm.diagnose_failure(tool_code, result) tool_code = self.llm.refine_tool(tool_code, diagnosis) return None def generate_from_code(self, source_code: str) -> str: spec = self.llm.generate_openapi_spec(source_code) docs = self.render_spec_as_docs(spec) return self.generate_from_docs(docs)
| Aspect | Doc2Agent | LRASGen |
|---|---|---|
| Input | Unstructured API docs | Source code |
| Output | Python agent tools | OpenAPI (JSON/YAML) specs |
| Key Technique | LLM generation + code agent refinement | LLM code understanding + text generation |
| Validation | Live API calls | Schema conformance checking |
| Handles Incomplete Input | Yes (messy docs) | Yes (partial code, missing annotations) |
These approaches fundamentally change how agent tool ecosystems scale: