Skip to content

Scope Codex heartbeat guidance to heartbeat turns - #76788

Merged
pashpashpash merged 4 commits into
mainfrom
codex/heartbeat-collaboration-mode
May 3, 2026
Merged

pashpashpash merged 4 commits into
mainfrom
codex/heartbeat-collaboration-mode

Conversation

@pashpashpash

@pashpashpash pashpashpash commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

The prompt audit showed that OpenClaw's heartbeat philosophy was still living in the shared GPT-5 friendly overlay. That meant ordinary Telegram and Discord chat turns could read proactive-heartbeat guidance even when the turn was just a normal user reply.

This moves that guidance onto the heartbeat turn itself. OpenClaw now sends Codex a Default collaboration mode on every app-server turn. Normal turns ask Codex to use its built-in Default mode text, while heartbeat turns provide OpenClaw's heartbeat guidance as turn-scoped collaboration-mode developer instructions.

The snapshots now make that boundary visible: regular direct and group turns no longer include the Heartbeats section, and the heartbeat snapshot has a Codex Collaboration Mode Instructions layer. The shared OpenAI/GPT-5 overlay follows the same split, so non-Codex OpenAI paths only get heartbeat initiative guidance when the run trigger is actually a heartbeat.

Observed heartbeat behavior

I restarted Pash's dev agent on this branch and waited for real scheduled heartbeats rather than relying on a manual system-event trigger. The first real interval heartbeat proved that the structured heartbeat tool path was active, but it also exposed a remaining prompt conflict: the heartbeat prompt no longer contained HEARTBEAT_OK, while the compiled direct-chat context still contained stale NO_REPLY guidance. This PR now fixes that by marking heartbeat tool turns as message-tool-only source delivery before prompt composition.

After that fix, the next real scheduled heartbeat had the shape we want. The submitted heartbeat trigger prompt did not contain HEARTBEAT_OK, the compiled system prompt did not contain NO_REPLY, and the model did not treat the wake as a visible chat response. It used OpenClaw tools to do proactive work: it listed Discord channels, read the active public Discord follow-up channel, checked the live Lobstar counters, recorded the fresh state in memory, and then called heartbeat_respond with notify:false.

The heartbeat tool summary was concrete: it had checked HEARTBEAT.md, the Discord #general follow-ups, and the Lobstar counters; it found no new messages after the prior public response, confirmed the visible List and /api/test counts, and logged the check in memory. Its reason for not notifying was also the right product behavior: there was no user-visible blocker, decision, safety issue, or notable completed result worth interrupting Pash about. That meets the bar for the heartbeat behavior because the agent woke up, oriented itself from durable heartbeat instructions, used tools to inspect the live workstream, made forward progress by updating memory, and stayed quiet for an explicit reason instead of spamming Telegram or returning a text sentinel.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: openai extensions: codex size: M maintainer Maintainer-authored PR labels May 3, 2026
@clawsweeper

clawsweeper Bot commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR splits GPT-5 chat and heartbeat prompt overlays, passes trigger context through provider prompt resolution, adds Codex turn-scoped collaboration-mode instructions for heartbeats, forces heartbeat tool delivery to message-tool-only, and refreshes docs, tests, snapshots, and changelog.

Reproducibility: yes. Current main source has ### Heartbeats inside the shared GPT-5 friendly overlay, and the committed regular Codex snapshots include that section in normal message-tool turns, so the leak is source-reproducible without running a live agent.

Next step before merge
The remaining repair is a localized changelog credit fix; a repair worker can also refresh the branch against current main if the maintainer promotes it.

Security
Cleared: The diff changes prompt assembly, docs, tests, generated baselines, and heartbeat delivery options without adding dependencies, workflows, secrets handling, package resolution, or new code-execution surfaces.

Review findings

  • [P3] Correct the changelog credit — CHANGELOG.md:65
Review details

Best possible solution:

Keep the trigger-scoped prompt split, correct the changelog attribution, resolve the dirty merge state, and land after required CI and maintainer review complete.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main source has ### Heartbeats inside the shared GPT-5 friendly overlay, and the committed regular Codex snapshots include that section in normal message-tool turns, so the leak is source-reproducible without running a live agent.

Is this the best way to solve the issue?

Mostly yes. The PR uses the narrow trigger-scoped overlay and existing Codex collaborationMode contract, but the changelog credit and dirty merge state should be fixed before merge.

Full review comments:

  • [P3] Correct the changelog credit — CHANGELOG.md:65
    This line thanks @pASH, but the PR and both commits are authored by @pashpashpash; those are different GitHub accounts. Release notes would credit the wrong contributor, so please change the credit to @pashpashpash unless another credited human was intended.
    Confidence: 0.96

Overall correctness: patch is correct
Overall confidence: 0.89

Acceptance criteria:

  • git diff --check
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md
  • If conflict resolution changes runtime, docs snapshots, generated API baselines, or tests: pnpm prompt:snapshots:check and pnpm check:changed in Testbox per repo policy.

What I checked:

Likely related people:

  • steipete: Introduced the shared GPT-5 prompt overlay and authored recent Codex app-server/provider runtime work in the paths extended by this PR. (role: introduced behavior and recent maintainer; confidence: high; commits: 2cd3164a0fc3, 69566e43cb8b, ed8f50f240a8; files: src/agents/gpt5-prompt-overlay.ts, extensions/codex/src/app-server/thread-lifecycle.ts, src/plugins/provider-runtime.ts)
  • pashpashpash: Authored prior merged heartbeat overlay guidance and Codex prompt snapshot work in the same prompt-scope area, beyond being this PR's author. (role: feature-history owner; confidence: high; commits: 323e37c86239, f5447aab8821, 563dca82f429; files: extensions/openai/prompt-overlay.ts, src/agents/gpt5-prompt-overlay.ts, test/helpers/agents/happy-path-prompt-snapshots.ts)
  • 100yenadmin: Carried the runtime-plan and Codex contract-suite work that defines the prompt contribution and Codex harness boundaries extended here. (role: adjacent owner; confidence: medium; commits: 860dad268d35, 2c35a6e59976; files: src/agents/runtime-plan/types.ts, extensions/codex/src/app-server/run-attempt.ts, extensions/codex/prompt-overlay-runtime-contract.test.ts)

Remaining risk / open question:

  • The changelog currently credits @pASH, which is a different GitHub account than the PR and commit author.
  • The live PR API reports mergeable_state: dirty, so it needs rebase or conflict resolution before it can land.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 4e82cacc84dc.

@pashpashpash
pashpashpash force-pushed the codex/heartbeat-collaboration-mode branch from 43ef6f0 to eefc0be Compare May 3, 2026 16:49
@pashpashpash

Copy link
Copy Markdown
Contributor Author

Addressed the changelog review: the Codex/heartbeat entry now credits @pashpashpash, matching the PR and commit author. I reran the requested checks locally: pnpm exec oxfmt --check --threads=1 CHANGELOG.md, git diff --check, and pnpm prompt:snapshots:check.

@pashpashpash
pashpashpash merged commit 5bcc321 into main May 3, 2026
109 checks passed
@pashpashpash
pashpashpash deleted the codex/heartbeat-collaboration-mode branch May 3, 2026 16:58
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
* fix(codex): scope heartbeat guidance to collaboration mode

* fix heartbeat tool direct context

* test prompt heartbeat collaboration snapshots

* fix heartbeat changelog credit
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(codex): scope heartbeat guidance to collaboration mode

* fix heartbeat tool direct context

* test prompt heartbeat collaboration snapshots

* fix heartbeat changelog credit
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix(codex): scope heartbeat guidance to collaboration mode

* fix heartbeat tool direct context

* test prompt heartbeat collaboration snapshots

* fix heartbeat changelog credit
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix(codex): scope heartbeat guidance to collaboration mode

* fix heartbeat tool direct context

* test prompt heartbeat collaboration snapshots

* fix heartbeat changelog credit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex extensions: openai maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant