openclaw - ✅(Solved) Fix bug(ci): loader.test.ts sanitizes control characters fails intermittently in CI [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#44536Fetched 2026-04-08 00:45:33
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

src/hooks/loader.test.ts sanitizes control characters in loader error logs (line 368) fails intermittently in GitHub Actions CI but passes on local machines.

Error Message

expect(messages).not.toContain(ANSI_RED) fails because CI logger output includes color codes despite non-TTY environment.

Root Cause

expect(messages).not.toContain(ANSI_RED) fails because CI logger output includes color codes despite non-TTY environment.

Fix Action

Fixed

PR fix notes

PR #37940: fix(agents): unify Think/Reasoning defaults via shared resolveReasoningDefault helper

Description (problem / solution / changelog)

User Impact

Users asking /status or session_status about a reasoning-capable model could see contradictory state such as Think: medium while Reasoning: off when no explicit reasoningLevel was persisted. This fix makes both status surfaces report the same default reasoning state.

Problem

OpenClaw already had a consistent default for Think, but Reasoning still fell back to off in several reply/status paths whenever the session entry did not carry an explicit reasoningLevel. In practice that produced contradictory state cards such as Think: medium while Reasoning was treated as off. That mismatch then leaked into agent self-reports and confused operators about whether thinking was actually enabled.

What this PR changes

  • adds a shared resolveReasoningDefault() helper next to the existing thinking-default logic
  • threads that helper through the reply/model-selection pipeline so command/status entry points use the same defaulting behavior
  • updates the system prompt guidance so agents answering model/thinking-state questions are pushed to use session_status and to interpret enabled/disabled from Think rather than Reasoning
  • adds focused tests for the new defaulting behavior and the prompt guidance

Validation

  • corepack pnpm exec vitest run src/agents/system-prompt.test.ts src/auto-reply/status.test.ts src/auto-reply/reply/commands-status.test.ts src/auto-reply/reply/commands.test.ts src/auto-reply/reply/commands-approve.test.ts src/auto-reply/reply/commands-parsing.test.ts src/auto-reply/reply/commands-policy.test.ts
  • corepack pnpm build

AI Disclosure

  • This PR was AI-assisted (Claude + Codex review)
  • Degree of testing: fully tested (system-prompt, status, commands, reply-directives tests)
  • I understand what the code does
  • Bot review conversations have been addressed

Changed files

  • src/agents/model-selection.test.ts (modified, +47/-3)
  • src/agents/model-selection.ts (modified, +8/-5)
  • src/agents/openclaw-tools.session-status.test.ts (modified, +68/-15)
  • src/agents/system-prompt.test.ts (modified, +9/-0)
  • src/agents/system-prompt.ts (modified, +1/-0)
  • src/agents/tools/session-status-tool.ts (modified, +7/-0)
  • src/auto-reply/reply/commands-info.ts (modified, +1/-0)
  • src/auto-reply/reply/commands-status.test.ts (added, +67/-0)
  • src/auto-reply/reply/commands-status.ts (modified, +4/-2)
  • src/auto-reply/reply/commands-types.ts (modified, +1/-0)
  • src/auto-reply/reply/commands.test-harness.ts (modified, +1/-0)
  • src/auto-reply/reply/commands.test.ts (modified, +1/-0)
  • src/auto-reply/reply/directive-handling.levels.ts (modified, +2/-3)
  • src/auto-reply/reply/get-reply-directives-apply.ts (modified, +5/-2)
  • src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts (modified, +1/-0)
  • src/auto-reply/reply/get-reply-inline-actions.ts (modified, +6/-0)
  • src/auto-reply/reply/get-reply.ts (modified, +1/-0)
  • src/auto-reply/reply/model-selection.ts (modified, +23/-11)
  • src/auto-reply/status.test.ts (modified, +69/-0)
  • src/auto-reply/status.ts (modified, +14/-1)
RAW_BUFFERClick to expand / collapse

Description

src/hooks/loader.test.ts sanitizes control characters in loader error logs (line 368) fails intermittently in GitHub Actions CI but passes on local machines.

Reproduction

Fails in CI (all 3 matrix entries): checks (bun), checks (node), checks-windows. Passes locally (macOS, also with CI=true FORCE_COLOR=0 and NO_COLOR=1).

Also observed on other unrelated PRs: #44397, #44390 — confirming this is not PR-specific.

Error

expect(messages).not.toContain(ANSI_RED) fails because CI logger output includes color codes despite non-TTY environment.

Impact

928 passed, 1 failed — only this single test is affected. Blocks CI green status on multiple open PRs.

extent analysis

Fix Plan

To fix the intermittent test failure, we need to ensure that the logger output does not include color codes in non-TTY environments.

Steps to Fix

  • Update the logger configuration to disable color output in non-TTY environments.
  • Use the isTTY property to check if the output is a TTY and only include color codes if it is.

Example code:

import { isTTY } from 'tty';

// ...

if (isTTY.write) {
  // include color codes in output
  logger.error(`\x1b[31m${message}\x1b[0m`); // ANSI_RED
} else {
  // do not include color codes in output
  logger.error(message);
}

Alternatively, you can use a library like chalk which automatically detects if the output is a TTY and only includes color codes if it is:

import chalk from 'chalk';

// ...

logger.error(chalk.red(message));

Verification

To verify that the fix worked, re-run the test in the CI environment and check that it passes. You can also test locally by setting CI=true and FORCE_COLOR=0 and NO_COLOR=1 to simulate a non-TTY environment.

Extra Tips

  • Make sure to test the fix in different environments to ensure it works consistently.
  • Consider using a library like chalk to handle color output, as it provides a simple and consistent way to include color codes in your output.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING