openclaw - ✅(Solved) Fix [Bug]: xAI grok reasoning models (grok-4-1-fast-reasoning) ignore workspace IDENTITY.md behavioral rules at 0% compliance rate [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59900Fetched 2026-04-08 02:39:04
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

When xai/grok-4-1-fast-reasoning (and likely other xAI fast-reasoning variants) is used as the primary model in OpenClaw, the agent produces 0% compliance with behavioral rules defined in workspace IDENTITY.md — specifically financial advice disclaimer requirements and directive-language prohibitions — across all 5 test turns in a representative 5-prompt evaluation suite. The same rules are reliably followed by all other tested models (GPT-5.3, GPT-5.4, Sonnet, Haiku, Gemini Flash).

Root Cause

When xai/grok-4-1-fast-reasoning (and likely other xAI fast-reasoning variants) is used as the primary model in OpenClaw, the agent produces 0% compliance with behavioral rules defined in workspace IDENTITY.md — specifically financial advice disclaimer requirements and directive-language prohibitions — across all 5 test turns in a representative 5-prompt evaluation suite. The same rules are reliably followed by all other tested models (GPT-5.3, GPT-5.4, Sonnet, Haiku, Gemini Flash).

Fix Action

Fixed

PR fix notes

PR #66652: feat(tools): add model_spawn tool — live session model switch and parallel ephemeral spawns

Description (problem / solution / changelog)

Summary

  • Adds model_spawn LLM-callable tool implementing the canonical spec in docs/tools/model-spawn.md
  • live mode: switches the current session's model in-place (context preserved, takes effect at the next clean turn boundary via liveModelSwitchPending + session store)
  • spawn single: delegates one task to a specified model in an ephemeral isolated session via spawnSubagentDirect
  • spawn multi: fans out up to 10 tasks concurrently across different models via Promise.all — supports both model specialization (different subtasks to different models) and model comparison (same task across multiple models)
  • Replaces the narrower model_switch tool (live-switch only, no spawn capability)
  • Canonical spec (docs/tools/model-spawn.md) is language-agnostic; a conformant Rust implementation for zeroclaw is being submitted in parallel to zeroclaw-labs/zeroclaw

Files changed

FileChange
src/agents/tools/model-spawn-tool.tsNew tool implementation
src/agents/openclaw-tools.tsRegister model_spawn, remove model_switch
src/agents/tool-display-config.tsAdd display metadata (required by pre-commit hook)
apps/shared/OpenClawKit/Resources/tool-display.jsonRegenerated snapshot
docs/tools/model-spawn.mdCanonical spec (shared with zeroclaw)

Schema

{
  "mode": "live" | "spawn",
  "model": "provider/model-id",        // live or single spawn
  "task": "...",                        // single spawn or default for spawns[]
  "context": "...",                     // optional, prepended to task
  "spawns": [                           // multi-model parallel execution
    { "model": "...", "task": "...", "label": "...", "context": "..." }
  ],
  "cleanup": "delete" | "keep",        // default: "delete"
  "timeout_seconds": 120
}

Test plan

  • live mode: verify liveModelSwitchPending is set in session store; next turn uses new model
  • spawn single: task runs in isolated session on specified model; parent session model unchanged
  • spawn multi: all entries run concurrently; results array contains one entry per spawn with label/index/model/status/output
  • spawns[] fallback: per-entry omitted task inherits top-level task; per-entry omitted context inherits top-level context
  • Mutual exclusion: providing both top-level model and spawns[] returns an error
  • cleanup="keep": session persists after spawn completes

🤖 Generated with Claude Code

Changed files

  • apps/shared/OpenClawKit/Sources/OpenClawKit/Resources/tool-display.json (modified, +10/-0)
  • docs/tools/model-spawn.md (added, +273/-0)
  • src/agents/openclaw-tools.ts (modified, +13/-0)
  • src/agents/tool-display-config.ts (modified, +5/-0)
  • src/agents/tool-mutation.ts (modified, +1/-0)
  • src/agents/tools/model-spawn-tool.test.ts (added, +379/-0)
  • src/agents/tools/model-spawn-tool.ts (added, +319/-0)
  • src/security/dangerous-tools.ts (modified, +2/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

When xai/grok-4-1-fast-reasoning (and likely other xAI fast-reasoning variants) is used as the primary model in OpenClaw, the agent produces 0% compliance with behavioral rules defined in workspace IDENTITY.md — specifically financial advice disclaimer requirements and directive-language prohibitions — across all 5 test turns in a representative 5-prompt evaluation suite. The same rules are reliably followed by all other tested models (GPT-5.3, GPT-5.4, Sonnet, Haiku, Gemini Flash).

Steps to reproduce

  1. Start OpenClaw v2026.4.2 with xai/grok-4-1-fast-reasoning as primary model.
  2. Place behavioral rules in ~/.openclaw/workspace/IDENTITY.md requiring financial advice disclaimers and prohibiting directive language.
  3. Ask the agent portfolio-related questions (overview, rebalancing, growth, bonds, performance).
  4. Score each response for disclaimer presence: result is 0/5 (0%).
  5. Compare against anthropic/claude-sonnet-4-6 or openai/gpt-5.3-chat-latest: both score 5/5 (100%).

Expected behavior

IDENTITY.md behavioral rules should be honored by all models, including xAI grok reasoning variants.

Environment

  • OpenClaw v2026.4.2
  • ZeroClaw v0.6.9
  • xAI grok-4-1-fast-reasoning
  • Tested on zeropi (Debian 13) and Brev A16 cloud instance

Re-filed from #59900 (originally filed under wrong account).

extent analysis

TL;DR

The xai/grok-4-1-fast-reasoning model in OpenClaw is not honoring the behavioral rules defined in IDENTITY.md, specifically financial advice disclaimers and directive-language prohibitions, and a workaround using per-turn prompt injection achieves 100% compliance.

Guidance

  • Verify that the IDENTITY.md file is correctly formatted and placed in the ~/.openclaw/workspace/ directory.
  • Test the xai/grok-4.20-0309-reasoning model, which shows 100% compliance, to confirm the issue is specific to the "fast-reasoning" mode.
  • Implement a per-turn prompt injection workaround by prepending the guardrail text to every user message before it reaches the model.
  • Consider proposing a feature to add an agent:pre-turn hook or a config flag to re-inject named bootstrap files as a user-side message prefix on every turn.

Example

[GUARDRAIL — required every response]
1. End with: ⚠️ This analysis is for educational purposes only and is not financial advice. Consult a qualified financial advisor before making investment decisions.
2. No directives: no Execute / Buy / Sell / Double down / Trim $X / Rotate $X.
3. Read ~/portfolio_reports/holdings.json before citing any dollar values.
[END GUARDRAIL]

Notes

The root cause of the issue is likely due to the xAI fast-reasoning models deprioritizing behavioral constraints relative to task completion in the final output. The per-turn injection workaround confirms that the model is capable of following the rules when they appear in the user turn rather than only in the system prompt.

Recommendation

Apply the per-turn prompt injection workaround to achieve 100% compliance, as it is a reliable mechanism to enforce behavioral rules regardless of model behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

IDENTITY.md behavioral rules should be honored by all models, including xAI grok reasoning variants.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING