Beyond Python: Designing AI-First Programming Languages for Agents
AI agents write Python just fine. The trouble is that Python will let them do anything.
AI agents increasingly get work done by writing and running code. A model plans a task, writes Python or TypeScript, calls tools, hands work to other agents and reads back the results.
Those languages were built for human programmers, and they assume whoever writes the code can be trusted. Any line can read a file, call an API, drop a table or send an email, with the full power of whatever credentials the process holds. With a human author, experience and code review keep that power in check.
Agents remove both. They write thousands of short programs a day, run each one once, and often nobody reviews them. They also read untrusted content, such as web pages, emails and GitHub issues, which can carry instructions planted by an attacker. So an agent’s code can delete data, leak secrets or run up costs, and often the only thing in the way is a prompt asking it not to.
Models already write these languages well, so the problem I keep running into isn’t the syntax. It’s that the languages can’t express what matters most for agents:
- what a program is allowed to do
- how much it may spend
- what side effects it will have
- how it works with other agents
Without those, an agent’s safety rules live in its prompt, and a prompt is a request, not a rule. This post starts with what that has already cost real teams, then looks at why models are good at today’s languages, where those languages fall short, and what an AI-first language could do better while staying fast and safe. The short version: keep the syntax familiar, and put the new ideas in the rules and the runtime.
This is already happening
These risks aren’t hypothetical. Since 2025, agents have done real damage, and the pattern is the same each time: the agent had more power than its task needed, and nothing but instructions stood in its way.
- Replit, July 2025. During a declared code freeze, Replit’s AI agent deleted SaaStr’s production database, which held records on about 1,200 executives and 1,200 companies. According to SaaStr’s founder, it also created fake records. The freeze was an instruction to the agent, not a rule the system enforced. (The Register)
- GitHub MCP server, May 2025. Invariant Labs showed that a malicious issue on a public repository could hijack an agent using GitHub’s official MCP server and make it leak data from the user’s private repositories. No bug in the server was needed. The agent simply had access to both. (Invariant Labs)
- Microsoft 365 Copilot “EchoLeak”, June 2025. A single crafted email could make Copilot send confidential data to an attacker, without the victim even opening it. Microsoft rated it critical (CVE-2025-32711) and fixed it on the server side. (The Hacker News)
- PocketOS, April 2026. A Cursor agent running Claude Opus 4.6 hit a credential problem in staging and, on its own, deleted a storage volume on Railway in about nine seconds. The production database and its backups were on that volume. The data was later recovered, and Railway changed its API to delay deletes. (Tom’s Hardware)
Each one is a gap in the list above: what the agent was allowed to do, and what side effects it could have. The Replit agent should never have had write access to production during a freeze. The PocketOS agent should have held only a narrowly scoped credential, and a destructive command should have needed approval. The GitHub and Copilot agents should not have been able to move text from an untrusted source into an action that sends private data out. Better prompts and more careful models help, but they can’t promise any of this. A language and its runtime can.
Why models are fluent in today’s languages
If today’s languages are part of the problem, why not give agents a brand-new one? Because any fix has to keep what models are already good at, and that is a lot.
Models write good Python because they have seen so much of it. Four things explain that:
- Lots of examples. There are billions of lines of public code in Python, JavaScript, Java, Go and SQL.
- Code with explanations. Comments, docs, commit messages and Q&A threads teach models what code is for, not just how it looks.
- Strict rules. Programming languages follow precise grammars, which are easier to learn than human language. In popular languages, syntax errors from modern models are now rare.
- Automatic checking. During training, compilers and tests tell the model whether its code works. Languages with good tooling likely get more of this training.
So a model is best at languages that are common, well explained and easy to check. A new language starts with none of these advantages. Research backs this up: in the CodeAct study of 17 models, agents that wrote Python generally did as well as or better than agents using JSON tool calls, with up to 20% higher success and up to 30% fewer steps.
Writing valid code is largely solved. Writing safe, correct code is not. None of the incidents above was a syntax error. The code ran exactly as written. Models still produce code that runs but does the wrong thing, touches things it shouldn’t, or fails halfway and leaves a mess. The cause is what the languages let it do, and what they can’t express.
Where today’s languages fall short for agents
Because today’s languages assume a trusted author, every program gets full access by default, and the only way to know what it does is to read it. The table below breaks that down. The first few rows are the root causes behind incidents like the ones above, and the last column is what agents need instead.
| Problem | What goes wrong | What agents need |
|---|---|---|
| Unlimited access | Any line can read files, call the network or run commands. One malicious web page (a prompt injection) can trick an agent into leaking data. | Code can only use the tools it was explicitly given. |
| Hidden side effects | A function’s signature doesn’t say it sends email or deletes data. Reviewers have to read every line. | Side effects declared up front and checked. |
| No spending limits | Loops, retries and model calls can run up cost and time. | Limits on tokens, money and time, built in. |
| Hard to review | You can’t reliably tell what general code will do without running it. Reviewers approve almost blind. | A plan you can read before it runs: which tools, how often, with what data. |
| Orchestration added on | Starting agents, messaging and timeouts live in frameworks, each with its own rules. | Agents and messages as part of the language. |
| Fragile long runs | A crash at step 30 of 40 loses progress. A retry may repeat a payment. | Runs that save progress, resume, and never repeat a side effect. |
| Loose data | Model and tool output arrives as plain text or loose JSON and breaks later steps. | Checked data types at every boundary. |
| Unhelpful errors | Stack traces are written for humans with a debugger. | Errors the model can read and fix. |
None of these is about syntax. Each is a missing guarantee. Some tools help: Deno and WebAssembly can restrict what a whole program may access, but not per function or per agent. Frameworks like LangGraph and Temporal cover other gaps, but only if the code follows their rules, and nothing forces it to.
Seven principles for an AI-first language
An AI-first language should look familiar to models and behave like a secure, reviewable workflow engine. None of these principles is new on its own; the new part is combining them for code that models write. The example in the next section shows them working together.
1. Familiar syntax
Look like Python or TypeScript, so models write it well from a short guide. Add a new keyword only when it buys a guarantee.
2. No access by default
A program starts with no access. Tools, files, websites and other agents are handed to it explicitly, like keys to specific doors. When it starts a helper agent, it can hand over fewer keys, never more. Under this rule, the PocketOS agent could only have used the credential its task was given.
3. Side effects in the signature
Each tool declares what it does: reads data, writes data, sends messages, spends money. The checker can then answer questions like “can this ever send an email?” without running the code.
4. Built-in budgets
A block of code can carry limits such as 50,000 tokens, $2 and 5 minutes. The runtime enforces them, and helper agents share their parent’s budget.
5. Reviewable before it runs
Loops are bounded and there is no eval, so every program finishes. The checker can then work out a plan: which tools, at most how many calls, at most what cost. A person or a company policy approves that plan. A code freeze like Replit’s becomes a policy the runtime enforces, not a line in a prompt. Anything more general runs in a sandbox.
6. Checked data at every boundary
Output from models, tools and other agents must match a declared type. Text from untrusted sources, like web pages, is labelled, and the label follows it everywhere. Labelled text can’t trigger a sensitive action, like sending email, without an explicit check. Private data can be labelled too, so it can’t leak out through a URL or a message. This is the rule the GitHub MCP and EchoLeak attacks got around.
7. Safe parallel work and long runs
Running tasks in parallel, starting agents and handling failures are built in. Every side effect is logged, so a run can pause for approval, survive a crash, resume where it stopped, and never repeat a payment.
Two smaller rules help models too: errors come back as data the model can act on, and the whole language guide is short enough to fit in a prompt.
What it could look like
Here is a made-up example to show the idea. It researches a topic with helper agents running in parallel, drafts a summary, waits for a person to approve it, then emails a team. It reads like Python. The new keywords (tool, agent, flow, within budget, parallel for, approve) are explained in the comments.
# Tools say what they return and what they do
tool web.search(query: str, limit: int) -> list[Source] does: read web
tool web.fetch(url: Url) -> Page does: read web # output labelled untrusted
tool mail.send(to: Email, body: Approved[Brief]) -> Receipt does: send
# A helper agent can only read the one URL it is given
agent Researcher(url: Url, web: Web.only(url)) -> Finding:
page = web.fetch(url)
return model.extract(Finding, from=page) # output must match the Finding type
flow weekly_brief(topic: str, team: Email,
web: Web.readonly, mail: Mail.to(team)) -> Receipt:
within budget(tokens=200_000, usd=3, time=10m):
sources = web.search(topic, limit=8)
findings = parallel for s in sources: # up to 8 helpers at once
spawn Researcher(url=s.url, web=web.only(s.url))
on failure: skip # one failed helper doesn't stop the rest
draft = model.write(Brief, from=findings) # still labelled untrusted
approved = approve(draft) by human # pauses until a person approves
return mail.send(team, approved) # only approved text can be sent
Before anything runs, the checker produces a plan a person can approve in seconds:
Plan: weekly_brief
Tools web.search 1x, web.fetch up to 8x, mail.send 1x (only to: team)
Agents up to 8 Researchers, each limited to one URL
Actions reads web, sends email
Budget max 200k tokens, $3, 10 minutes (helpers included)
Approvals 1 human approval before mail.send
Data web text reaches mail.send only after approval
Agents talk through typed channels instead of free text. A message in the wrong shape is rejected:
channel reviews: Channel[Review]
agent Critic(inbox: Receive[Draft], out: Send[Review]):
for draft in inbox.take(3): # reviews at most 3 drafts
out.send(model.judge(Review, draft)) # must be a valid Review
You could write the same workflow in Python in about the same length. The difference: in Python, none of that plan can be worked out ahead of time. Any line could call requests.post or os.system, and the budget, the recipient limit and the approval step only hold if every line respects them.
Performance and safety
Safety comes from two layers: checking the program before it runs, and enforcing access while it runs. Speed comes from the same checking, because a runtime that knows the whole plan can schedule it well.
Errors from the checker go back to the model so it can fix them. Only the runtime touches tools, other agents and the log, and only with the access the program was given.
Performance
- Automatic parallelism. The runtime sees which calls don’t depend on each other and runs them at the same time. Agents mostly wait on models and tools, so this matters more than raw speed.
- One program, not many round trips. The model writes the whole workflow once. Tool results stay in the runtime instead of flowing back through the model. Anthropic reported that this approach cut one example from about 150,000 tokens to about 2,000 (Code execution with MCP).
- Caching. Read-only calls can be cached safely, because their signatures say they change nothing.
- Compiled. The core compiles to fast bytecode or WebAssembly, and heavy data work calls native libraries.
- Light logging. Only side effects are logged, not every step, so saving progress is cheap.
Safety
- Access checked at runtime. Even if the checker were skipped, the runtime refuses any call the program has no access for.
- Limits on prompt injection. Untrusted text can’t trigger a sensitive action without a check, and an injected instruction can’t add new tools or actions. It can still distort content, or misuse actions the program is allowed to take, so reviews and policies still matter. Google DeepMind’s CaMeL tested a version of this idea: it completed 77% of tasks on a prompt-injection benchmark with provable security, compared with 84% for an unprotected agent.
- Sandbox for general code. Code outside the safe core runs isolated, with only the access it was given.
- Helpers get less, never more. An agent can only pass down part of its own access.
- Company rules on every run. Teams write rules like “no email without human approval” or “under $5 per run”, and the runtime applies them to every program.
Working with today’s tools
An AI-first language should build on the tools and protocols teams already use, and prove itself with tests before anyone builds a full compiler.
| Existing tool | How the language uses it |
|---|---|
| MCP (Model Context Protocol) | Tool definitions are imported from MCP servers. MCP’s read-only and destructive flags are only hints, so operators confirm what each tool really does. |
| A2A (Agent2Agent protocol) | Messages to agents built with other frameworks go over A2A. |
| Python and TypeScript apps | Embed the runtime as a library and call workflows like functions. |
| LangGraph, Temporal | Their ideas (workflow graphs, resumable runs) become language features, or workflows compile to them. |
| DSPy, BAML | Plug in behind the model calls for typed output and prompt tuning. |
Testing the idea before building it
A small experiment can test the idea:
- Write a two-page guide and a simple interpreter.
- Collect 30 to 50 agent tasks, including tool use, multi-agent work and prompt-injection attacks.
- Have current models solve each task in the new language and in Python with a popular framework.
- Compare success rate, tokens used, attacks blocked and how long a person takes to review each program.
If the new language isn’t clearly safer and easier to review, without losing much success, change the design before building more.
Guarantees, not syntax
An AI-first language is worth building for its guarantees, not its syntax. None of the incidents in this post came from badly written code. They came from code that was allowed to do too much. Models already write today’s languages well, and new syntax would throw that away. What’s missing is a way to state what a program may do, what it may spend, what it will change and how agents work together, in a form a machine can check and a person can approve.
Keep the syntax familiar. Add limited access, declared side effects, budgets, checked data, safe parallel work and resumable runs. Then agents can take on bigger, riskier work, and people can trust it without reading every line. As agents become more autonomous, trust is the bottleneck, and the language is one of the best places to build it.
Sources
- The Register, Replit deleted SaaStr’s production database during a code freeze, July 2025
- Invariant Labs, GitHub MCP exploited: accessing private repositories via MCP, May 2025
- The Hacker News, Zero-click AI vulnerability exposes Microsoft 365 Copilot data (EchoLeak), June 2025
- Tom’s Hardware, Claude-powered AI coding agent deletes entire company database in 9 seconds, April 2026
- Wang et al., Executable Code Actions Elicit Better LLM Agents (CodeAct), ICML 2024
- Anthropic, Code execution with MCP: building more efficient agents
- Debenedetti et al., Defeating Prompt Injections by Design (CaMeL)
- Linux Foundation, Agent2Agent protocol project launch
- MCP blog, Tool annotations