nanocoai/nanoclaw · error · Error

source agent group not found: ${from}

Error message

source agent group not found: ${from}

What it means

Thrown by `ncl policies set` when getAgentGroup(from) returns null — the source agent group id passed via --from does not exist in the agent_groups table. The handler validates both endpoints before writing the policy row.

Source

Thrown at src/cli/resources/policies.ts:36

      description: 'User-id who approves each gated message (required). Only this user (or an owner) can approve.',
    },
    { name: 'created_at', type: 'string', description: 'Auto-set.' },
  ],
  operations: { list: 'open' },
  customOperations: {
    set: {
      access: 'approval',
      description:
        'Require approval for messages from one agent to another. Use --from <agent-group-id> --to <agent-group-id> --approver <user-id>. Only the named approver (or an owner) can approve.',
      handler: async (args) => {
        const from = args.from as string;
        const to = args.to as string;
        const approver = args.approver as string;
        if (!from) throw new Error('--from is required');
        if (!to) throw new Error('--to is required');
        if (!approver) throw new Error('--approver is required');
        if (from === to) throw new Error('--from and --to must differ (self-messages are never gated)');
        if (!(await getAgentGroup(from))) throw new Error(`source agent group not found: ${from}`);
        if (!(await getAgentGroup(to))) throw new Error(`target agent group not found: ${to}`);

        await setMessagePolicy(from, to, approver, new Date().toISOString());
        return { from_agent_group_id: from, to_agent_group_id: to, approver };
      },
    },
    remove: {
      access: 'approval',
      description: 'Remove an approval policy (back to free flow). Use --from <agent-group-id> --to <agent-group-id>.',
      handler: async (args) => {
        const from = args.from as string;
        const to = args.to as string;
        if (!from) throw new Error('--from is required');
        if (!to) throw new Error('--to is required');
        if (!(await removeMessagePolicy(from, to))) throw new Error('policy not found');
        return { removed: { from_agent_group_id: from, to_agent_group_id: to } };
      },
    },

View on GitHub (pinned to 294ef2aee8)

Solutions

  1. Run `ncl groups list` and copy the exact --from id
  2. If the group was deleted, recreate it or drop the policy intent
Defensive patterns

Strategy: validation

Validate before calling

const groups = await listAgentGroups(); if (!groups.some(g => g.id === from)) throw new Error(`unknown source group ${from}`);

Prevention

When it happens

Trigger: Typo in the --from id; the source group was deleted; the id is a folder name rather than the DB group id.

Common situations: Confusing the groups/<folder> directory name with the DB id; stale scripts referencing removed groups.

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 nanocoai/nanoclaw@294ef2aee8 (2026-08-28). Data as JSON: /api/errors/a6f97ae256e5effc. Report an issue: GitHub.