{"slug": "custom-agents", "title": "Custom Agents", "summary": "Amp announced a new feature allowing users to create custom agents via plugins, which can serve as main agents, subagents, or worker agents with custom orb colors. The Plugin API provides primitives for defining agents, registering tools, and managing threads, enabling complex workflows like spawning background review agents.", "body_md": "You can now create custom agents in Amp with plugins.\n\nYou can use these custom agents as your main Amp agent, or as subagents. You can\nuse them as a small part of a tool pipeline that you invoke with `amp -x`\n\n. Or\nyou can spawn 25 custom worker agents, then switch between them.\n\nEach custom agent comes with a custom orb color.\n\nHere is how you define a custom agent in an Amp plugin:\n\n``` python\n// .amp/plugins/focused-reviewer-agent.ts\nimport type { PluginAPI } from '@ampcode/plugin'\n\nexport default function (amp: PluginAPI) {\n\t// Create the agent\n\tconst reviewer = amp.createAgent({\n\t\tname: 'focused-reviewer',\n\t\tmodel: 'openai/gpt-5.5',\n\t\tinstructions: [\n\t\t\t'You are a focused code-review subagent.',\n\t\t\t'Inspect only the files and concerns named by the caller.',\n\t\t\t'Return concise findings with severity, evidence, and suggested fixes.',\n\t\t].join(' '),\n\t\ttools: 'all',\n\t\tdisplay: { label: 'reviewer', color: '#d97706' },\n\t})\n\n\t// Register a tool. This agent acts as a subagent\n\tamp.registerTool({\n\t\tname: 'focused_review',\n\t\tdescription: 'Run a focused code-review subagent.',\n\t\tinputSchema: {\n\t\t\ttype: 'object',\n\t\t\tproperties: {\n\t\t\t\trequest: { type: 'string' },\n\t\t\t},\n\t\t\trequired: ['request'],\n\t\t},\n\n\t\tasync execute(input, ctx) {\n\t\t\t// Run a one-shot agent turn\n\t\t\tconst result = await reviewer.run(input, {\n\t\t\t\tparentThreadID: ctx.thread.id,\n\t\t\t})\n\t\t\treturn result.text\n\t\t},\n\t})\n\n\t// Or register the agent as a selectable main thread mode\n\tamp.registerAgentMode({\n\t\tkey: 'focused-reviewer',\n\t\tdescription: 'Code Review Expert',\n\t\tagent: reviewer.definition,\n\t})\n}\n```\n\nOnce you have defined an agent, you can create threads:\n\n``` js\n// Spawn a new thread\nconst thread = await reviewer.createThread({\n\t// Tell the UI switch to this thread\n\tshow: true,\n})\n\n// Get an existing thread\nconst thread = amp.threads.get(input.threadID)\n```\n\nThe `Thread`\n\nobject lets you interact with a thread in many different ways, and\nis where the real power comes in.\n\nAdd a new user message to a thread by calling `thread.appendUserMessage()`\n\n. The\ncall returns as soon as Amp has accepted the message; it does not wait for\ninference to complete before returning.\n\n```\nawait thread.appendUserMessage({\n\ttype: 'user-message',\n\tcontent: 'Review the auth changes in this branch.',\n})\n```\n\nWhen you do want to wait, call `waitForResponse()`\n\non the thread. It resolves\nwith the next assistant message after the agent finishes its turn.\n\n``` js\nconst reply = await thread.waitForResponse()\n```\n\nThese are just a few primitives provided by the Plugin API. Together, they compose into unique workflows. An example used on the Amp team: spawn an agent in an asynchronous thread, and give it the tools it needs to respond to the parent when it needs to.\n\n```\namp.registerTool({\n\tname: 'start_async_review',\n\tdescription: 'Start a review in a background thread.',\n\tinputSchema: { type: 'object', properties: {} },\n\tasync execute(_input, ctx) {\n\t\tconst thread = await reviewer.createThread({\n\t\t\tparentThreadID: ctx.thread.id,\n\t\t})\n\n\t\tawait thread.appendUserMessage({\n\t\t\ttype: 'user-message',\n\t\t\tcontent: [\n\t\t\t\t'Review the auth changes in this branch.',\n\t\t\t\t`When you are done, call send_to_thread with threadID ${ctx.thread.id}`,\n\t\t\t\t'and include your review in the message.',\n\t\t\t].join(' '),\n\t\t})\n\n\t\treturn `Started background review in ${thread.id}.`\n\t},\n})\n```\n\nFull documentation is [in the manual](https://ampcode.com/manual/plugin-api). Happy Hacking.", "url": "https://wpnews.pro/news/custom-agents", "canonical_source": "https://ampcode.com/news/custom-agents", "published_at": "2026-06-19 00:00:00+00:00", "updated_at": "2026-06-30 16:31:45.222098+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Amp", "Plugin API", "GPT-5.5"], "alternates": {"html": "https://wpnews.pro/news/custom-agents", "markdown": "https://wpnews.pro/news/custom-agents.md", "text": "https://wpnews.pro/news/custom-agents.txt", "jsonld": "https://wpnews.pro/news/custom-agents.jsonld"}}