{"slug": "serverless-agents", "title": "Serverless Agents", "summary": "OpenComputer released a serverless agent framework that treats agents as functions, deployable in four commands, with the core code being a single JavaScript function that takes input and returns instructions. The framework, available via npm packages @opencomputer/agent and @opencomputer/cli, handles the runtime loop, model calls, tool execution, and deployment, allowing developers to write ordinary code with conditional logic for tools and subagents. The deployment process uses aliases for immutable versions and rollback, and the framework supports multiple models via provider/model strings and custom tools defined with JSON Schema.", "body_md": "*And it's fucking simple.*\n\nSeriously. This is the whole thing:\n\n``` js\nimport { useInput, useModel } from \"@opencomputer/agent\";\n\nexport default function Agent() {\n  const input = useInput();\n  useModel(\"anthropic/claude-sonnet-4.6\");\n\n  return `Be concise and practical. Current request: ${input.text}`;\n}\n```\n\nThat's an agent. Not a diagram of an agent. Not a \"reference architecture.\" An agent. It's deployed to production at the bottom of this page in four commands.\n\n**An agent is a function.** It takes an input and returns instructions. That's it. Something else runs the loop, calls the model, executes the tools, streams the tokens, keeps the conversation around, and versions your deploys. That something else is a runtime. You don't write runtimes. You write functions.\n\nYou have been told that building an agent means:\n\nIt doesn't. All of that is infrastructure pretending to be your product. Your product is the function.\n\nInput comes in. Your function runs. It says \"here's the model, here are the tools, here's what to do.\" The runtime does the rest. Ordinary code, ordinary control flow. Want a tool only when the user asks for research? That's an `if`\n\nstatement:\n\n``` js\nexport default function Agent() {\n  const input = useInput();\n  useModel(\"anthropic/claude-sonnet-4.6\");\n\n  if (input.text?.includes(\"research\")) {\n    useTool(\"web-search\");\n    useSubagent(\"researcher\");\n  }\n\n  return \"Answer directly. Research and verify when you can.\";\n}\n```\n\nNo graph. No YAML. No node types. You already know how to write this. You've been writing it since your first `if`\n\n.\n\nYou edit a file. It's live. That's the whole feedback loop.\n\n```\nnpm run dev\n```\n\nWatches your agent code, syncs every save to a development environment, prints you a URL. Open the playground, talk to your agent, change a line, talk to it again. Session history is kept, every turn is inspectable, and nothing you do in dev touches production. If you've used Vite, you've used this.\n\n```\nnpm run deploy -- --alias production\n```\n\nBuilds an immutable deployment and points `production`\n\nat it. Sessions that are already running keep the code they started with. Roll back by moving the alias. That's the entire deployment story and it fits in one line, which is how you know it's not lying to you.\n\nThere is no server for you to run. There is no server for you to keep running. There is no 3am page because the agent loop OOM'd. Serverless means serverless.\n\nThe model is a string. Change the string.\n\n```\nuseModel(\n  needsDeepReview\n    ? \"anthropic/claude-sonnet-4.6\"\n    : \"anthropic/claude-haiku-4.5\",\n);\n```\n\n`provider/model`\n\n. Pick per request if you want. Pick a cheaper one for the easy path and a smarter one for the hard path. When a better model ships next month, you change a string and redeploy. You never see a provider API key. It never ends up in your repo. Your agent is your code, not your vendor's SDK.\n\nBecause of course they are. JSON Schema in, whatever you want out:\n\n``` js\nimport { defineTool } from \"@opencomputer/agent\";\n\nexport const latestStories = defineTool({\n  name: \"latest_hacker_news_stories\",\n  description: \"Fetch the current top Hacker News stories\",\n  input: { type: \"object\", properties: { limit: { type: \"number\" } } },\n  async run({ input }) {\n    const ids = await fetch(\n      \"https://hacker-news.firebaseio.com/v0/topstories.json\"\n    ).then((r) => r.json());\n    return ids.slice(0, input.limit ?? 10);\n  },\n});\n```\n\nThen `useTool(latestStories)`\n\nin your agent. Need an MCP server? `useMcpServer(...)`\n\n. Need to delegate? `useSubagent(...)`\n\n. Need instructions bundled with files? Put a `SKILL.md`\n\nnext to the agent. Every capability is one line, and it's only attached when your code says so.\n\nFour steps. You own step 2. If your architecture diagram has more boxes than this list has numbers, the boxes are the problem.\n\n```\nnpm create @opencomputer/start@latest my-agent\ncd my-agent && npm install\nnpx --package @opencomputer/cli opencomputer login\nnpm run dev\n```\n\nEdit `opencomputer/agents/hello-world/agent.ts`\n\n. Save. Talk to it. Then:\n\n```\nnpm run deploy -- --alias production\n```\n\nYou now have an agent in production. It took less time than reading this page. Go build the actual thing you wanted to build.\n\n[Read the docs](https://docs.opencomputer.dev/agents/overview) · [Quickstart](https://docs.opencomputer.dev/agents/quickstart) · [OpenComputer](https://opencomputer.dev)\n\nThis page is one HTML file with five lines of CSS, which is four more than it needs. Shamelessly in the spirit of [motherfuckingwebsite.com](https://motherfuckingwebsite.com/). Built on [OpenComputer](https://opencomputer.dev).", "url": "https://wpnews.pro/news/serverless-agents", "canonical_source": "https://serverlessagent.dev", "published_at": "2026-08-17 04:15:56+00:00", "updated_at": "2026-08-17 04:40:41.572614+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools"], "entities": ["OpenComputer", "@opencomputer/agent", "@opencomputer/cli", "Anthropic", "Claude Sonnet 4.6", "Claude Haiku 4.5", "Hacker News"], "alternates": {"html": "https://wpnews.pro/news/serverless-agents", "markdown": "https://wpnews.pro/news/serverless-agents.md", "text": "https://wpnews.pro/news/serverless-agents.txt", "jsonld": "https://wpnews.pro/news/serverless-agents.jsonld"}}