nanocoai/nanoclaw · error · Error

--from is required

Error message

--from is required

What it means

Thrown by `ncl policies set` when the --from flag is missing. The policy gates agent-to-agent messages, so the source agent group id is required to key the message_policies row.

Source

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

    { name: 'to_agent_group_id', type: 'string', description: 'Target agent group. References agent_groups.id.' },
    {
      name: 'approver',
      type: 'string',
      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');

View on GitHub (pinned to 294ef2aee8)

Solutions

  1. Pass --from with a valid agent group id: `ncl policies set --from <src> --to <dst> --approver <uid>`
  2. Get ids from `ncl groups list`

Example fix

// before
ncl policies set --to grp-b --approver telegram:owner
// after
ncl policies set --from grp-a --to grp-b --approver telegram:owner
Defensive patterns

Strategy: validation

Validate before calling

if (!from) throw new Error('--from required');

Prevention

When it happens

Trigger: Running `ncl policies set --to <gid> --approver <uid>` without --from; wrong flag alias in a script.

Common situations: Operator forgets the policy is directional (from → to) and supplies only one side; empty shell variable in automation.

Related errors


AI-assisted analysis of nanocoai/nanoclaw@294ef2aee8 (2026-08-28). Data as JSON: /api/errors/c6dcd6f226f82d15. Report an issue: GitHub.