Skip to content

[codex] Add per-DM active directive prompt - #88668

Closed
molle-png wants to merge 1 commit into
openclaw:mainfrom
molle-png:codex/active-directive
Closed

molle-png wants to merge 1 commit into
openclaw:mainfrom
molle-png:codex/active-directive

Conversation

@molle-png

Copy link
Copy Markdown

Summary

Adds a DM-scoped active directive path so deployments can steer direct-message behavior for a turn without folding that directive into ambient group/subagent context.

The new agents.defaults.dmDirective setting is routed as extraSystemPromptDirective through the reply runner, CLI runner, and embedded runner paths. The system-prompt assembler renders it as the final system block after ## Runtime:

## Active Directive (overrides persona for this turn)

Ambient extraSystemPrompt behavior is unchanged, so existing group GroupSystemPrompt content still renders under ## Group Chat Context.

Why

OpenClaw currently sends all per-turn extra prompt material through the same ambient context slot. That makes a direct-message override such as “for this context behave like X” compete poorly with durable persona/project context such as SOUL.md.

This keeps the existing context path intact and introduces one explicit directive path for DM-only steering.

Implementation notes

  • Adds agents.defaults.dmDirective config/schema support.
  • Routes dmDirective only for direct chats.
  • Keeps the directive separate from extraSystemPrompt and followup prompt fusion.
  • Forwards the field through both CLI and embedded execution paths.
  • Renders the directive after Runtime as the last system block before the user message.
  • Adds focused tests for prompt ordering and DM-only routing.

Validation

node node_modules/vitest/vitest.mjs run src/agents/system-prompt.test.ts src/auto-reply/reply/get-reply-run.media-only.test.ts

Result: 2 test files passed, 163 tests passed.

Also ran:

git diff --check

Result: clean.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. size: S labels May 31, 2026
@clawsweeper

clawsweeper Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 29, 2026, 7:52 AM ET / 11:52 UTC.

Summary
The PR adds a DM-scoped agents.defaults.dmDirective and extraSystemPromptDirective prompt path through gateway, reply, CLI, embedded runner, prompt assembly, and focused tests.

PR surface: Source +47, Tests +72. Total +119 across 25 files.

Reproducibility: not applicable. as a user bug, but yes for the PR defect from source: the PR head adds extraSystemPromptDirective while prepareCliRunContext still builds and hashes only the existing extra prompt fields.

Review metrics: 1 noteworthy metric.

  • New Prompt-Control Surfaces: 1 config key added, 1 gateway request field added. Prompt-control inputs affect operator configuration and gateway callers, so maintainers need the contract, docs, runner parity, and upgrade behavior aligned before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Forward the directive through prepareCliRunContext and include stable directive text in CLI session reuse hashing.
  • [P1] Add config help/labels and public docs for agents.defaults.dmDirective plus the gateway request field.
  • [P1] Add redacted real behavior proof from a DM directive turn and a group non-leak check, with private data removed.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body and comments only show unit-test/diff-check output; contributor action is needed to add redacted terminal/log/screenshot/recording proof of a real DM directive turn plus a group non-leak check, then update the PR body or ask for @clawsweeper re-review if a fresh review does not trigger.

Mantis proof suggestion
A real direct-message run and a group non-leak check would materially improve review confidence for this user-visible prompt behavior. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis visual task: run a DM turn with agents.defaults.dmDirective set and show a group turn does not receive the directive.

Risk before merge

  • [P1] CLI backend users could configure or send the directive but receive old prompt behavior, and reused CLI sessions may keep stale prompt state because the directive is not part of the system-prompt hash.
  • [P1] The new config key and gateway request field create public prompt-control contracts before config help, labels, agent docs, gateway protocol docs, and maintainer-approved semantics are aligned.
  • [P1] Contributor proof is still limited to unit-test output; maintainers do not have redacted real DM directive behavior plus group non-leak evidence, and the live PR is currently draft/conflicting.

Maintainer options:

  1. Complete The Directive Contract (recommended)
    Forward the directive through CLI prompt preparation and session hashing, add config/help/protocol docs, and require real direct/group behavior proof before merge.
  2. Narrow The Public Surface
    If maintainers only want embedded or gateway support first, remove unsupported CLI/config/protocol claims until those paths are deliberately supported.
  3. Pause Product Direction
    If persona-overriding DM configuration is not accepted product direction, keep the draft paused or close it until a maintainer sponsors the API.

Next step before merge

  • [P1] Keep in human review because the PR needs contributor real-behavior proof and maintainer/product approval for a new public prompt-control config/protocol contract.

Security
Cleared: No workflow, lockfile, dependency, release-script, secret-handling, generated/vendor, or supply-chain changes were found in the diff.

Review findings

  • [P1] Forward directives through CLI prompt preparation — src/agents/cli-runner/types.ts:56
  • [P2] Document the new prompt-control config surface — src/config/zod-schema.agent-defaults.ts:69
Review details

Best possible solution:

Ship one maintainer-approved DM directive contract documented across config and gateway surfaces, wired through embedded and CLI runners with session hashing, and backed by real DM/group proof.

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

Not applicable as a user bug, but yes for the PR defect from source: the PR head adds extraSystemPromptDirective while prepareCliRunContext still builds and hashes only the existing extra prompt fields.

Is this the best way to solve the issue?

No. The direction is plausible, but this is not the best merge shape until CLI parity, session hashing, public docs/metadata, maintainer-approved semantics, and real DM proof are in place.

Full review comments:

  • [P1] Forward directives through CLI prompt preparation — src/agents/cli-runner/types.ts:56
    The new RunCliAgentParams.extraSystemPromptDirective can reach the CLI runner type surface, but prepareCliRunContext still builds the CLI system prompt and reuse hash from only extraSystemPrompt/extraSystemPromptStatic. CLI backends would not receive the DM directive, and reused CLI sessions would not reset when it changes.
    Confidence: 0.91
  • [P2] Document the new prompt-control config surface — src/config/zod-schema.agent-defaults.ts:69
    Accepting agents.defaults.dmDirective creates a user-facing config key, and the PR also adds a gateway request field, but there is no matching config help, labels, agent config docs, or gateway protocol documentation. That leaves operator and client-facing contract surfaces out of sync.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against db2488b6e3d6.

Label changes

Label justifications:

  • P2: This is a normal-priority feature PR with limited blast radius while unset, but it has concrete correctness and proof blockers.
  • merge-risk: 🚨 compatibility: The diff adds config and gateway protocol inputs that affect prompt behavior before public metadata, docs, and semantics are aligned.
  • merge-risk: 🚨 session-state: The directive is not included in CLI prompt preparation or session hashing, so reused CLI sessions can carry stale prompt state after directive changes.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body and comments only show unit-test/diff-check output; contributor action is needed to add redacted terminal/log/screenshot/recording proof of a real DM directive turn plus a group non-leak check, then update the PR body or ask for @clawsweeper re-review if a fresh review does not trigger.
Evidence reviewed

PR surface:

Source +47, Tests +72. Total +119 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 23 47 0 +47
Tests 2 72 0 +72
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 25 119 0 +119

What I checked:

  • PR head adds a new gateway prompt-control field: The PR head adds extraSystemPromptDirective to AgentParamsSchema, making it a new gateway request input. (packages/gateway-protocol/src/schema/agent.ts:192, 0cad5c82a515)
  • PR head adds a new operator config key: The PR head accepts agents.defaults.dmDirective in the agent defaults schema. (src/config/zod-schema.agent-defaults.ts:69, 0cad5c82a515)
  • CLI prompt preparation still omits the directive: On the PR head, prepareCliRunContext calls buildCliAgentSystemPrompt with extraSystemPrompt but not extraSystemPromptDirective, so CLI backends do not receive the new directive even though the type accepts it. (src/agents/cli-runner/prepare.ts:451, 0cad5c82a515)
  • CLI session reuse hashes only the existing extra prompt: Current main hashes extraSystemPrompt or extraSystemPromptStatic for CLI session reuse and compares only that system-prompt hash, so a directive-only change would not invalidate a reused CLI session unless the PR updates this path. (src/agents/cli-runner/prepare.ts:349, db2488b6e3d6)
  • Current main does not already implement this feature: Searches on current main found no dmDirective, extraSystemPromptDirective, or Active Directive prompt block under source, docs, packages, or workflows. (db2488b6e3d6)
  • Config metadata/docs are not aligned with the new key: The existing config help, labels, and docs/gateway/config-agents.md surfaces contain agent defaults coverage but no dmDirective entry, while the PR adds the accepted schema key. (docs/gateway/config-agents.md:14, db2488b6e3d6)

Likely related people:

  • shakkernerd: GitHub path history for src/agents/cli-runner/prepare.ts shows several recent CLI prepare/auth commits, and the main blocking defect is in CLI prompt preparation and session hashing. (role: recent CLI runner contributor; confidence: medium; commits: 045a7148d4f6, 17ba3bc65d3f, f68b06da46eb; files: src/agents/cli-runner/prepare.ts, src/agents/cli-session.ts)
  • steipete: Path history shows work on system prompt assembly and config schema/helper docs, which overlap the proposed prompt directive and missing config metadata/docs surfaces. (role: agent prompt and config contributor; confidence: medium; commits: e12a6d6a67d7, 43190f5248b5, e96428b008a9; files: src/agents/system-prompt.ts, src/config/zod-schema.agent-defaults.ts, src/config/schema.help.ts)
  • vincentkoc: Recent path history for src/gateway/server-methods/agent.ts includes gateway agent-handler work, and the PR adds a gateway request field through that handler surface. (role: adjacent gateway contributor; confidence: medium; commits: 5571c786d3df, c2ee9b0be8ae, 0ea08076c3b5; files: src/gateway/server-methods/agent.ts, packages/gateway-protocol/src/schema/agent.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 31, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@molle-png thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed stale Marked as stale due to inactivity labels Jul 14, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@molle-png thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict low_signal_unmergeable_pr (decision packet 2026-07-15T10:30:36.772Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

@steipete steipete closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants