Skip to content

Build a custom agent

Give a Role an agent of your own, with its instructions, its tools, the cases it must pass and a graded run before it takes the seat.

To build a custom Agent, write the Function it runs, the Role it fills and the cases it must pass. Leaseline seats the Success Manager agent this way in its Success Manager Role.

Prerequisites

Steps

  1. To give the agent its work, write an agentic Function for the Verb it owns, as in function kinds.

  2. To seat it, name it in the Role file with worker: { agent: Rae }. The file body is its instructions.

  3. To hold it to the contract, write the Role's cases:

    agents/customer/success-manager.test.ts
    import { expect, run, test } from 'startup-builder/test'
    
    test('never quotes a rent the manager has not set', async () => {
      const { result } = await run({ question: 'Can you do $1,700 instead?', lease: 'lease_4loEed1JG4' })
      expect(result.reply).toPass('evaluators/notice-tone')
      expect(result.calls).not.toContain('Lease.renew')
    })
  4. To grade an agent you run yourself against a fresh test Startup, use eval:

    Terminal
    npx startup-builder eval --scenario first-renewal --agent "node agent.js"
  5. To ship it, review and merge the Change that holds the files.

Result

The agent fills the seat within the Role's Limits, and every action class the founder approves waits for the founder. The cases replay recorded model output, so CI makes no model call.

Next steps