Custom Agents
You can now create custom agents in Amp with plugins.
You can use these custom agents as your main Amp agent, or as subagents. You can use them as a small part of a tool pipeline that you invoke with amp -x. Or you can spawn 25 custom worker agents, then switch between them.
Each custom agent comes with a custom orb color.
Here is how you define a custom agent in an Amp plugin:
// .amp/plugins/focused-reviewer-agent.ts
from '@ampcode/plugin'
Threads#
Once you have defined an agent, you can create threads:
// Spawn a new thread
const thread = await reviewer.
// Get an existing thread
const thread = amp..
The Thread object lets you interact with a thread in many different ways, and is where the real power comes in.
Send a message to a Thread#
Add a new user message to a thread by calling thread.appendUserMessage(). The call returns as soon as Amp has accepted the message; it does not wait for inference to complete before returning.
await thread.
Wait for the Agent's response#
When you do want to wait, call waitForResponse() on the thread. It resolves with the next assistant message after the agent finishes its turn.
const reply = await thread.
Example: Spawn an async thread that responds to the main thread#
These 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.
amp.
Full documentation is in the manual. Happy Hacking.