fix: create new conversation for per-channel mode instead of resuming default (#503)
Co-authored-by: Letta Code <noreply@letta.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -499,7 +499,7 @@ describe('SDK session contract', () => {
|
||||
let createdSessions = 0;
|
||||
let startedSends = 0;
|
||||
|
||||
vi.mocked(resumeSession).mockImplementation((_id, opts) => {
|
||||
vi.mocked(createSession).mockImplementation((_id, opts) => {
|
||||
const sessionName = createdSessions++ === 0 ? 'chat-a' : 'chat-b';
|
||||
return {
|
||||
initialize: vi.fn(async () => undefined),
|
||||
@@ -655,7 +655,7 @@ describe('SDK session contract', () => {
|
||||
agentId: 'agent-contract-test',
|
||||
conversationId: 'conv-new',
|
||||
};
|
||||
vi.mocked(resumeSession).mockReturnValue(createdSession as never);
|
||||
vi.mocked(createSession).mockReturnValue(createdSession as never);
|
||||
|
||||
const activeSession = {
|
||||
close: vi.fn(() => undefined),
|
||||
|
||||
@@ -255,12 +255,16 @@ export class SessionManager {
|
||||
}
|
||||
session = resumeSession(convId, opts);
|
||||
} else if (this.store.agentId) {
|
||||
// Agent exists but no conversation stored -- resume the default conversation
|
||||
// Agent exists but no conversation stored for this key.
|
||||
// 'shared' is the single shared conversation — resume it like the default.
|
||||
// Channel-specific keys (per-channel/per-chat mode) need a fresh conversation.
|
||||
process.env.LETTA_AGENT_ID = this.store.agentId;
|
||||
installSkillsToAgent(this.store.agentId, this.config.skills);
|
||||
sessionAgentId = this.store.agentId;
|
||||
prependSkillDirsToPath(sessionAgentId); // must be before resumeSession spawns subprocess
|
||||
session = resumeSession(this.store.agentId, opts);
|
||||
prependSkillDirsToPath(sessionAgentId); // must be before resumeSession/createSession spawns subprocess
|
||||
session = key === 'shared'
|
||||
? resumeSession(this.store.agentId, opts)
|
||||
: createSession(this.store.agentId, opts);
|
||||
} else {
|
||||
// Create new agent -- persist immediately so we don't orphan it on later failures
|
||||
log.info('Creating new agent');
|
||||
|
||||
Reference in New Issue
Block a user