AI Functions: Runtime Code Generation with Automated Verification

✍️ OpenClawRadar📅 Published: February 24, 2026🔗 Source
AI Functions: Runtime Code Generation with Automated Verification
Ad

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")

Ad

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

Ad

👀 See Also