fix(wake): handle relative + agent-prefixed session keys consistently in cron adapter

Address review findings from successive codex rounds:

1. next-heartbeat + sessionKey now fires a targeted immediate wake.
   The regularly-scheduled heartbeat fires for the agent's main session,
   not the supplied sessionKey, so an event queued for a non-main session
   would sit stranded indefinitely; an "event"-intent wake is also
   deferred as not-due by the heartbeat runner and not retried, so
   neither path delivers without an explicit immediate wake.

2. resolveCronWakeTarget now always runs through resolveCronAgent, both
   for agent-prefixed session keys (so non-default agents are honored)
   and relative keys (so the configured default agent is used instead
   of the hardcoded "main" returned by resolveAgentIdFromSessionKey).
   Mirrors the matching fix in the enqueueSystemEvent adapter so wake
   and enqueue resolve to the same target.

3. Generated Swift `WakeParams` models now expose the new optional
   `sessionkey` field (codingKey "sessionKey") in both the macOS and
   shared OpenClawKit copies. Locally regenerated from agent.ts via
   protocol:gen + protocol:gen:swift would have produced this; the
   environment couldn't run the generators (fs-safe transitive
   typecheck errors), so the diff was applied by hand to match what
   pnpm protocol:check would output.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kaspre
2026-05-07 00:23:39 -04:00
committed by Peter Steinberger
parent 4ddd942f5f
commit 072fa9b174
4 changed files with 67 additions and 13 deletions

View File

@@ -941,18 +941,22 @@ public struct AgentWaitParams: Codable, Sendable {
public struct WakeParams: Codable, Sendable {
public let mode: AnyCodable
public let text: String
public let sessionkey: String?
public init(
mode: AnyCodable,
text: String)
text: String,
sessionkey: String?)
{
self.mode = mode
self.text = text
self.sessionkey = sessionkey
}
private enum CodingKeys: String, CodingKey {
case mode
case text
case sessionkey = "sessionKey"
}
}