Software factory / Custom agents
Custom agents
The built-in agents do not do one job that your project needs. For example, you want each new bug report labeled, or each pull request that changes the public API to get a note about the docs.
2 min read
A custom agent does that job. You write it with TanStack AI: a defineAgent with your own instructions, tools and MCP servers. The forge runs its code in a sandbox for each issue or pull request, calls the model for it, and gives it the forge's tools.
You need admin access to the repository to add or change custom agents.
Start with Write your first custom agent. Then pick what your agent needs:
| You want to | Read |
|---|---|
| Keep the factory file in git, and import your own packages | Keep custom agents in the repository |
| Fix a factory file that has errors | Fix an error in the factory file |
| Give the agent an MCP server or an API key | MCP servers and secrets |
| Let the agent push a fix or open a pull request | Agents that change code |
| Look up a field, a tool or a limit | Custom agents reference |
How the forge keeps the sandbox safe
- The sandbox has no model key and no token. The forge calls the model with the key, for the agent.
- The agent calls the forge's tools through
forgeTools. The forge runs each call with the limits of the built-in agents, as the same bot. - A secret is a placeholder that starts with
tss_ph_. The forge swaps it for the value only in requests to the hosts of the secret. - The agent reaches only the forge, and the hosts in its
egresson port 443.
For each rule, see The sandbox.
When custom agents run
- Custom agents run only while at least one built-in agent is on. If every built-in agent is off, turn one on first: see Turn on the agents.
- If a factory file has an error, no custom agent runs. The built-in agents still run.
- A custom agent does not run on content that screening holds, or for a banned author.