feat: tag new agents with origin:lettabot (#405)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Sarah Wooders
2026-02-25 18:22:14 -08:00
committed by GitHub
parent e96ddc1db1
commit 673cb5100e
3 changed files with 54 additions and 1 deletions

View File

@@ -950,6 +950,7 @@ export class LettaBot implements AgentSession {
const newAgentId = await createAgent({
systemPrompt: SYSTEM_PROMPT,
memory: loadMemoryBlocks(this.config.agentName),
tags: ['origin:lettabot'],
...(this.config.memfs !== undefined ? { memfs: this.config.memfs } : {}),
});
const currentBaseUrl = process.env.LETTA_BASE_URL || 'https://api.letta.com';

View File

@@ -20,7 +20,22 @@ vi.mock('../tools/letta-api.js', () => ({
getLatestRunError: vi.fn().mockResolvedValue(null),
}));
import { createSession, resumeSession } from '@letta-ai/letta-code-sdk';
vi.mock('../skills/loader.js', () => ({
installSkillsToAgent: vi.fn(),
withAgentSkillsOnPath: vi.fn((_id: string, fn: () => unknown) => fn()),
getAgentSkillExecutableDirs: vi.fn().mockReturnValue([]),
isVoiceMemoConfigured: vi.fn().mockReturnValue(false),
}));
vi.mock('./memory.js', () => ({
loadMemoryBlocks: vi.fn().mockReturnValue([]),
}));
vi.mock('./system-prompt.js', () => ({
SYSTEM_PROMPT: 'test system prompt',
}));
import { createAgent, createSession, resumeSession } from '@letta-ai/letta-code-sdk';
import { getLatestRunError } from '../tools/letta-api.js';
import { LettaBot } from './bot.js';
@@ -448,4 +463,40 @@ describe('SDK session contract', () => {
'Agent run failed: timeout'
);
});
it('passes tags: [origin:lettabot] to createAgent when creating a new agent', async () => {
delete process.env.LETTA_AGENT_ID;
vi.mocked(createAgent).mockResolvedValue('agent-new-tagged');
const mockSession = {
initialize: vi.fn(async () => undefined),
send: vi.fn(async (_message: unknown) => undefined),
stream: vi.fn(() =>
(async function* () {
yield { type: 'assistant', content: 'hello' };
yield { type: 'result', success: true };
})()
),
close: vi.fn(() => undefined),
agentId: 'agent-new-tagged',
conversationId: 'conversation-new-tagged',
};
vi.mocked(createSession).mockReturnValue(mockSession as never);
const bot = new LettaBot({
workingDir: join(dataDir, 'working'),
allowedTools: [],
});
await bot.sendToAgent('first message');
expect(vi.mocked(createAgent)).toHaveBeenCalledTimes(1);
expect(vi.mocked(createAgent)).toHaveBeenCalledWith(
expect.objectContaining({
tags: ['origin:lettabot'],
})
);
});
});

View File

@@ -1538,6 +1538,7 @@ export async function onboard(options?: { nonInteractive?: boolean }): Promise<v
const agentId = await createAgent({
systemPrompt: SYSTEM_PROMPT,
memory: loadMemoryBlocks(config.agentName || 'LettaBot'),
tags: ['origin:lettabot'],
...(config.model ? { model: config.model } : {}),
});