fix(logging): set correct trigger type for cron/heartbeat turns
Set the correct trigger type ('cron' and 'heartbeat') for cron/heartbeat turns instead of defaulting to 'message', and remove the spurious channel property from heartbeat turns.
Written by Cameron ◯ Letta Code
"The measure of intelligence is the ability to change." -- Albert Einstein
This commit is contained in:
@@ -278,12 +278,9 @@ export class HeartbeatService {
|
||||
});
|
||||
|
||||
// Build trigger context for silent mode
|
||||
const lastTarget = this.bot.getLastMessageTarget();
|
||||
const triggerContext: TriggerContext = {
|
||||
type: 'heartbeat',
|
||||
outputMode: 'silent',
|
||||
sourceChannel: lastTarget?.channel,
|
||||
sourceChatId: lastTarget?.chatId,
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync, copyFileSync, renameSync, watch, type FSWatcher } from 'node:fs';
|
||||
import { resolve, dirname, basename } from 'node:path';
|
||||
import type { AgentSession } from '../core/interfaces.js';
|
||||
import type { TriggerContext } from '../core/types.js';
|
||||
import type { CronJob, CronJobCreate, CronSchedule, CronConfig, HeartbeatConfig } from './types.js';
|
||||
import { DEFAULT_HEARTBEAT_MESSAGES } from './types.js';
|
||||
import { getCronDataDir, getCronLogPath, getCronStorePath, getLegacyCronStorePath } from '../utils/paths.js';
|
||||
@@ -317,7 +318,8 @@ export class CronService {
|
||||
try {
|
||||
// SILENT MODE - response NOT auto-delivered
|
||||
// Agent must use `lettabot-message` CLI to send messages
|
||||
const response = await this.bot.sendToAgent(config.message);
|
||||
const triggerContext: TriggerContext = { type: 'heartbeat', outputMode: 'silent' };
|
||||
const response = await this.bot.sendToAgent(config.message, triggerContext);
|
||||
|
||||
log.info(`Heartbeat finished (SILENT MODE)`);
|
||||
log.info(` - Response: ${response?.slice(0, 100)}${(response?.length || 0) > 100 ? '...' : ''}`);
|
||||
@@ -446,7 +448,8 @@ export class CronService {
|
||||
].join('\n');
|
||||
|
||||
// Send message to agent
|
||||
const response = await this.bot.sendToAgent(messageWithMetadata);
|
||||
const triggerContext: TriggerContext = { type: 'cron', outputMode: 'silent' };
|
||||
const response = await this.bot.sendToAgent(messageWithMetadata, triggerContext);
|
||||
|
||||
// Resolve delivery target: explicit config > last message target fallback > silent
|
||||
let deliverTarget: { channel: string; chatId: string } | null = job.deliver ?? null;
|
||||
|
||||
Reference in New Issue
Block a user