paperclipai/paperclip · error · Error
Failed to create agent token
Error message
Failed to create agent token
What it means
The agent API key creation call in connectWizard returned a falsy result, so the wizard cannot complete the agent profile; a sentinel null-guard on the API response.
Solutions
- Verify board credentials and server reachability, then retry.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at cli/src/commands/client/connect.ts:132 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18).
Data as JSON: /api/errors/b41b9133ea0ea8a8.
Report an issue: GitHub.
Appendix: source
Thrown at cli/src/commands/client/connect.ts:132
profile: profileName,
persona: "board",
apiBase,
companyId: company?.id ?? null,
key: publicKeyResult(key),
exports: buildExports({ apiBase, companyId: company?.id, agentId: undefined, envName: apiKeyEnvVarName, token: key.token }),
};
}
const company = await chooseCompany(companies, opts.companyId ?? resolvedProfile.profile.companyId, {
optional: false,
});
if (!company) throw new Error("Company is required for agent profiles");
const agents = (await boardApi.get<Agent[]>(apiPath`/api/companies/${company.id}/agents`)) ?? [];
if (agents.length === 0) throw new Error(`Company '${company.name}' has no agents to connect.`);
const agent = await chooseAgent(agents, resolvedProfile.profile.agentId);
const tokenName = opts.tokenName?.trim() || `cli-agent-${new Date().toISOString()}`;
const key = await boardApi.post<CreatedAgentKey>(apiPath`/api/agents/${agent.id}/keys`, createAgentKeySchema.parse({ name: tokenName }));
if (!key) throw new Error("Failed to create agent token");
upsertProfile(profileName, {
apiBase,
companyId: company.id,
persona: "agent",
agentId: agent.id,
agentName: agent.name,
apiKeyEnvVarName,
tokenName: key.name,
tokenId: key.id,
tokenCreatedAt: key.createdAt,
}, opts.context);
setCurrentProfile(profileName, opts.context);
p.outro(pc.green(`Connected profile '${profileName}' as ${agent.name}.`));
return {
ok: true,
profile: profileName,
persona: "agent",
apiBase,View on GitHub (pinned to 120ae5428f)