## Problem `dispatchTask()` shells out to `openclaw gateway call sessions.patch` which times out when the gateway is busy, causing: 1. Notifications never fire (they're at the end of dispatchTask) 2. Worker state may not be recorded 3. Workers run silently ## Solution (3 changes) ### 1. Make `ensureSession` fire-and-forget Session key is deterministic, so we don't need to wait for confirmation. Health check catches orphaned state later. ### 2. Use runtime API for notifications instead of CLI Pass `runtime` through opts and use direct API calls: - `runtime.channel.telegram.sendMessageTelegram()` - `runtime.channel.whatsapp.sendMessageWhatsApp()` - etc. ### 3. Move notification before session dispatch Fire workerStart/workerComplete notifications early (after label transition) before the session calls that can timeout. ## Files Changed - lib/dispatch.ts — fire-and-forget ensureSession, early notification, accept runtime - lib/notify.ts — use runtime API for direct channel sends - lib/services/pipeline.ts — early notification, accept runtime - lib/services/tick.ts — pass runtime through to dispatchTask - lib/tool-helpers.ts — accept runtime in tickAndNotify - lib/tools/work-start.ts — pass api.runtime to dispatchTask - lib/tools/work-finish.ts — pass api.runtime to executeCompletion/tickAndNotify
This commit is contained in:
@@ -59,12 +59,13 @@ export function createWorkFinishTool(api: OpenClawPluginApi) {
|
||||
|
||||
const pluginConfig = getPluginConfig(api);
|
||||
|
||||
// Execute completion (pipeline service handles notification)
|
||||
// Execute completion (pipeline service handles notification with runtime)
|
||||
const completion = await executeCompletion({
|
||||
workspaceDir, groupId, role, result, issueId, summary, prUrl, provider, repoPath,
|
||||
projectName: project.name,
|
||||
channel: project.channel,
|
||||
pluginConfig,
|
||||
runtime: api.runtime,
|
||||
});
|
||||
|
||||
const output: Record<string, unknown> = {
|
||||
@@ -72,9 +73,10 @@ export function createWorkFinishTool(api: OpenClawPluginApi) {
|
||||
...completion,
|
||||
};
|
||||
|
||||
// Tick: fill free slots (notifications handled by dispatchTask)
|
||||
// Tick: fill free slots (notifications handled by dispatchTask with runtime)
|
||||
const tickPickups = await tickAndNotify({
|
||||
workspaceDir, groupId, agentId: ctx.agentId, pluginConfig, sessionKey: ctx.sessionKey,
|
||||
runtime: api.runtime,
|
||||
});
|
||||
if (tickPickups.length) output.tickPickups = tickPickups;
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ export function createWorkStartTool(api: OpenClawPluginApi) {
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch
|
||||
// Dispatch (pass runtime for direct API access)
|
||||
const pluginConfig = getPluginConfig(api);
|
||||
const dr = await dispatchTask({
|
||||
workspaceDir, agentId: ctx.agentId, groupId, project, issueId: issue.iid,
|
||||
@@ -100,6 +100,7 @@ export function createWorkStartTool(api: OpenClawPluginApi) {
|
||||
pluginConfig,
|
||||
channel: project.channel,
|
||||
sessionKey: ctx.sessionKey,
|
||||
runtime: api.runtime,
|
||||
});
|
||||
|
||||
// Auto-tick disabled per issue #125 - work_start should only pick up the explicitly requested issue
|
||||
|
||||
Reference in New Issue
Block a user