AI Functions: Runtime Code Generation with Automated Verification

AI Functions is a new project from Strands Labs built on the Strands Agents SDK that enables runtime AI code generation with continuous automated verification. Instead of just generating text for humans to integrate, it produces code that runs inside your application at call time, returning native Python objects like DataFrames, Pydantic models, or database connections.
How AI Functions Work
The core abstraction is the @ai_function decorator. You write a Python function with a natural language specification in the docstring instead of implementation code. When the function is called, the decorator intercepts the call, constructs a prompt from the docstring (substituting arguments), sends it to an LLM, executes the generated code in your Python process, and returns the result as a native object.
Here's the basic example from the source:
from ai_functions import ai_function
@ai_function
def translate_text(text: str, lang: str) -> str:
"""
Translate the text below to the following language: {lang}.
{text}
"""
result = translate_text("The quarterly results exceeded expectations.", lang="French")
Key Differentiator: Automated Verification
The critical feature is post-conditions – plain Python assertions that define what correct output looks like. These execute on every function call, not just before deployment. If verification fails, the system automatically retries with the error as feedback. The human never inspects the generated code; the post-conditions handle verification every time.
Software 3.1 Concept
The article positions this as "Software 3.1" – an evolution from Andrej Karpathy's framework where Software 3.0 is "human prompts, LLM generates, human verifies." AI Functions represent "human specifies, LLM generates and executes, machine verifies – at runtime." The execution model differs fundamentally: the LLM isn't producing text for human integration but code that runs directly in your application.
This changes three aspects simultaneously: where AI fits in your software (runtime instead of just development time), what it produces (live objects you can call methods on instead of serialized text), and how you trust it (continuous automated verification instead of one-time human review).
📖 Read the full source: HN AI Agents
👀 See Also

Indie Developer Unveils 'Ideanator' CLI Tool for Structuring Vague Ideas with Local LLMs
Ideanator is a CLI tool designed by a self-taught 19-year-old developer using local LLMs like Ollama/MLX. It structures vague ideas into well-defined concepts, completely offline.

Claude Code Best Practice Repo Hits 50k Stars, Built Entirely with AI Agents
A GitHub repository packed with Claude best practices, 100% developed and maintained by autonomous Claude code workflows, crossed 50,000 stars — making it Pakistan's most-starred repo in 2026.

Auto-co: A 50-Line Bash Script That Turns Claude Code Into Autonomous AI Companies
Auto-co is a 50-line bash script that wraps the Claude Code CLI in a loop, allowing it to run autonomously with 14 AI agents playing roles like CEO, engineer, and critic. It has built four products from scratch, including FormReply and Changelog.dev, at a total cost of $268 across 270+ cycles.

Phaselock: An AI Agent Control System Inspired by Parenting Techniques
Phaselock is an open-source Agent Skill that implements four control mechanisms for AI coding agents: explicit gates before action, immediate feedback on mistakes, constrained choices, and mechanical rule enforcement. It works with Claude Code, Cursor, Windsurf, and any tool supporting hooks.