Skip to content

fix: suppress SUBAGENT_SPAWN_ACCEPTED_NOTE for cron isolated sessions#27330

Closed
kevinWangSheng wants to merge 2 commits intoopenclaw:mainfrom
kevinWangSheng:fix/cron-sessions-spawn-note
Closed

fix: suppress SUBAGENT_SPAWN_ACCEPTED_NOTE for cron isolated sessions#27330
kevinWangSheng wants to merge 2 commits intoopenclaw:mainfrom
kevinWangSheng:fix/cron-sessions-spawn-note

Conversation

@kevinWangSheng
Copy link

Summary

Fixes issue #27308 - Cron isolated sessions break with sessions_spawn because the 'do not poll/sleep' note causes premature turn completion.

Root Cause

When the agent sees the SUBAGENT_SPAWN_ACCEPTED_NOTE ("auto-announces on completion, do not poll/sleep"), it immediately responds with "Waiting for sub-agents..." and the turn completes. In cron isolated sessions, the turn ending means the cron job finalizes, so subagent results are never collected.

Fix

Detect cron sessions by checking if starts with "cron:" and suppress the note in that case. This allows the agent to wait naturally for subagent results, keeping the turn alive until subagents complete.

Testing

  • TypeScript compiles without errors
  • Need to test with actual cron job with sessions_spawn

Related

Kevin Shenghui added 2 commits February 26, 2026 00:08
- Modified assertSystemdAvailable to check both user and system scope
- Added detectSystemdScope function for explicit scope detection
- Updated execSystemctl to support optional --user flag
- Fixes openclaw#27267: openclaw status incorrectly reports 'systemd not installed' when gateway is running via systemd
Cron isolated sessions end immediately after the agent produces a
response. When the agent sees the 'do not poll/sleep' note, it
immediately responds with 'Waiting for sub-agents...' and the turn
completes prematurely, before subagent results are collected.

This fix detects cron sessions (by checking if agentSessionKey starts
with 'cron:') and suppresses the note in that case, allowing the agent
to wait naturally for subagent results.

Fixes openclaw#27308
@openclaw-barnacle openclaw-barnacle bot added gateway Gateway runtime agents Agent runtime and tooling size: S labels Feb 26, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

This PR includes two separate fixes: (1) suppresses the "do not poll/sleep" note for cron isolated sessions to prevent premature turn completion, and (2) improves systemd detection to check both user and system scopes. The cron session fix correctly detects cron sessions by checking if agentSessionKey starts with cron: and suppresses the note that would cause the agent to immediately end the turn before collecting subagent results.

  • Fixed cron isolated sessions breaking with sessions_spawn by suppressing SUBAGENT_SPAWN_ACCEPTED_NOTE
  • Added systemd scope detection for both user and system services
  • Critical bug: Line 148 in systemd.ts uses --status flag which doesn't exist - will cause runtime failure when checking systemd availability

Confidence Score: 2/5

  • This PR has a critical syntax error that will cause runtime failures when checking systemd user service availability.
  • The cron session fix is well-implemented and addresses the stated issue correctly, but the systemd changes contain a critical bug on line 148 where --status is used instead of status, which will cause the systemd detection to fail. This is a straightforward syntax error that needs to be fixed before merging.
  • src/daemon/systemd.ts requires attention - line 148 has an invalid systemctl command that will cause runtime errors.

Last reviewed commit: 0acf294

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile


export async function isSystemdUserServiceAvailable(): Promise<boolean> {
const res = await execSystemctl(["--user", "status"]);
const res = await execSystemctl(["--status"], true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--status is invalid - systemctl doesn't have a --status flag. Should be status without the double dash since execSystemctl will prepend --user when useUser is true.

Suggested change
const res = await execSystemctl(["--status"], true);
const res = await execSystemctl(["status"], true);
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/daemon/systemd.ts
Line: 148

Comment:
`--status` is invalid - systemctl doesn't have a `--status` flag. Should be `status` without the double dash since `execSystemctl` will prepend `--user` when `useUser` is true.

```suggestion
  const res = await execSystemctl(["status"], true);
```

How can I resolve this? If you propose a fix, please make it concise.

@Lukavyi
Copy link
Contributor

Lukavyi commented Feb 26, 2026

@kevinWangSheng thanks for the fix!
Pls check out greptile's comments
Looks like your systemd change is not relevant to the issue, maybe commited by mistake?

@Lukavyi
Copy link
Contributor

Lukavyi commented Feb 26, 2026

Bug in isCronSession check

The current check:

const isCronSession = ctx.agentSessionKey?.startsWith("cron:");

Never matches. The agentSessionKey format for cron isolated sessions is:

agent:main:cron:dd871818-8eae-4218-a3b3-862e0f077b1e:run:cf959c9f-...

It starts with "agent:", not "cron:". Fix:

const isCronSession = ctx.agentSessionKey?.includes(":cron:");

Verified locally

I applied this one-line fix, rebuilt, and tested:

Check Duration Result
startsWith("cron:") (this PR) 43s ❌ "Sub-agents launched. Waiting for results..."
includes(":cron:") (fixed) 257s ✅ Full news digest with 30+ items, delivered

The includes version correctly suppresses the SUBAGENT_SPAWN_ACCEPTED_NOTE, allowing the cron agent to poll/wait for subagent results instead of immediately ending the turn.

Minor note

After the cron run completes, subagents still attempt to announce back to the (now dead) cron session, producing "Subagent announce direct announce agent call transient failure" warnings in the console. This is cosmetic and does not affect delivery, but could be a follow-up cleanup.

Lukavyi added a commit to Lukavyi/openclaw that referenced this pull request Feb 26, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
@Lukavyi
Copy link
Contributor

Lukavyi commented Feb 26, 2026

Alternative fix with corrected session key check and tests: PR #27470

Lukavyi added a commit to Lukavyi/openclaw that referenced this pull request Feb 26, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
obviyus pushed a commit to Lukavyi/openclaw that referenced this pull request Feb 26, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
obviyus pushed a commit that referenced this pull request Feb 26, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR #27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes #27308
Fixes #25069
@obviyus
Copy link
Contributor

obviyus commented Feb 26, 2026

Fixed by 69590de.

@obviyus obviyus closed this Feb 26, 2026
execute008 pushed a commit to execute008/openclaw that referenced this pull request Feb 27, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
vincentkoc pushed a commit to Sid-Qin/openclaw that referenced this pull request Feb 28, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
vincentkoc pushed a commit to rylena/rylen-openclaw that referenced this pull request Feb 28, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069

(cherry picked from commit 69590de)

# Conflicts:
#	src/agents/subagent-spawn.ts
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069

(cherry picked from commit 69590de)

# Conflicts:
#	src/agents/subagent-spawn.ts
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
thebenjaminlee pushed a commit to escape-velocity-ventures/openclaw that referenced this pull request Mar 7, 2026
The 'do not poll/sleep' note added to sessions_spawn tool results causes
cron isolated agents to immediately end their turn, since the note tells
them not to wait for subagent results. In cron isolated sessions, the
agent turn IS the entire run, so ending early means subagent results
are never collected.

Fix: detect cron sessions via includes(':cron:') in agentSessionKey
and suppress the note, allowing the agent to poll/wait naturally.

Note: PR openclaw#27330 used startsWith('cron:') which never matches because
the session key format is 'agent:main:cron:...' (starts with 'agent:').

Fixes openclaw#27308
Fixes openclaw#25069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants