Budibase/budibase · error

Agent not found

Error message

Agent not found

What it means

getAgentOrThrow is the store's internal lookup helper: it finds an agent by _id in local state and throws if absent, guaranteeing subsequent operations have a valid agent. Callers (delete, update operations, toggles) all funnel through it.

Source

Thrown at packages/builder/src/stores/portal/agents.ts:126

      agents: [],
      tools: [],
      toolsLoading: false,
      toolsLoaded: false,
      toolsLoadFailed: false,
      agentsLoaded: false,
      knowledgeByOperation: {},
      knowledgeUploadByOperation: {},
      knowledgeLoadingByOperation: {},
      knowledgeConfiguration: undefined,
    })
  }

  private getAgentOrThrow = (agentId: string) => {
    const agent = get(this.store).agents.find(
      candidate => candidate._id === agentId
    )
    if (!agent) {
      throw new Error("Agent not found")
    }
    return agent
  }

  private updateOperation = async (
    agentId: string,
    operationId: string,
    updater: (operation: AgentOperation) => AgentOperation
  ) => {
    const operation = this.getAgentOperation(agentId, operationId)
    if (!operation) {
      throw new Error("Operation not found")
    }
    const updated = updater(operation)
    return await this.updateAgentOperation(agentId, operationId, {
      name: updated.name,
      live: updated.live,
      promptInstructions: updated.promptInstructions,

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Fetch/refresh the agents list before performing the operation
  2. Verify the agentId is valid and the agent still exists
  3. Handle concurrent deletion gracefully — re-fetch and update the UI
  4. Confirm you're not passing a different id type/format than stored _id

Example fix

// before
agents.delete(agentId)
// after
const exists = get(agents).agents.some(a => a._id === agentId)
if (exists) await agents.delete(agentId)
Defensive patterns

Strategy: try-catch

Validate before calling

const agent = get(agents).agents.find(a => a._id === agentId)
if (!agent) {
  await agents.fetch()
  return
}

Try / catch

try {
  await agents.delete(agentId)
} catch (e) {
  if (e.message === "Agent not found") {
    await agents.fetch() // resync; agent likely deleted elsewhere
  } else throw e
}

Prevention

When it happens

Trigger: Any AgentsStore public operation (delete, updateAgentOperation, toggling live status) with an agentId that does not exist in the local store list.

Common situations: Agent deleted in another tab/session while the UI still holds its id; passing an id from a stale list; calling operations before the agents list has been fetched; wrong id variable used.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/bda85afcd91f4559. Report an issue: GitHub.