What Is Kimi CLI’s AFK Mode and How Does It Differ From Regular Execution?

Kimi CLI’s AFK (away-from-keyboard) mode is a special runtime state that assumes no human is present, auto-dismissing user questions and auto-approving all tool calls to enable fully unattended execution.

The Kimi CLI AFK mode in the MoonshotAI/kimi-cli repository provides a hands-off automation layer distinct from standard interactive sessions. While regular execution pauses for user input and explicit approvals, AFK mode allows the AI agent to continue operating independently when you step away from the terminal.

Key Differences: AFK vs. Regular Execution

Understanding how Kimi CLI AFK mode alters default behavior requires comparing interaction models side by side.

User Interaction Behavior

In regular execution, the CLI pauses execution when encountering AskUserQuestion tool calls, waiting indefinitely for human answers. Additionally, tool calls pass through an approval system requiring explicit user consent unless Yolo mode is enabled.

In AFK mode, the system assumes zero human availability. The AskUserQuestion tool is automatically dismissed without recording answers, effectively wasting that turn. Simultaneously, all tool calls receive automatic approval from the harness without human intervention.

Enabling and Disabling AFK

Regular execution represents the default state, though you can override approval requirements using the --yolo flag or /yolo slash command for auto-approval only.

AFK mode requires explicit activation through:

  • The CLI flag: kimi --afk
  • The slash command: /afk (toggles persistence)
  • Session state storage: approval.afk

Runtime Overlays and Persistence

Regular execution maintains no special overlays—every step follows standard approval chains.

AFK mode supports two distinct flag types managed in src/kimi_cli/soul/approval.py:

  • Persistent AFK: Stored in approval.afk, survives across commands, displayed in the status bar as afk_enabled
  • Runtime AFK: Invocation-only overlay (runtime_afk) for single-command runs like kimi --afk

Disabling AFK via /afk clears the runtime overlay while preserving the persistent state logic.

Implementation Architecture

The AFK system spans three core modules that coordinate state management, context injection, and user interface controls.

Approval State Management

The src/kimi_cli/soul/approval.py module houses the AFK state machine. It exposes four critical methods:

  • set_afk(): Toggles the AFK flag and clears runtime overlays when disabling
  • is_afk(): Checks current AFK status for approval decisions
  • is_afk_flag(): Returns the persistent session flag
  • is_runtime_afk(): Returns the temporary invocation flag

These functions determine whether the src/kimi_cli/soul/kimi_soul.py controller selects afk or yolo approval modes during tool execution.

Dynamic Context Injection

When AFK is active, src/kimi_cli/soul/dynamic_injections/afk_mode.py injects a system prompt reminding the LLM that "no user is present" and that AskUserQuestion must not be used. This AfkModeInjectionProvider emits the reminder once per AFK session, resetting only on history compaction or flag changes.

Slash Command Interface

The src/kimi_cli/soul/slash.py file implements the /afk toggle command. When invoked, it:

  • Flips the approval.afk boolean
  • Posts a toast notification ("AFK mode enabled" or "AFK mode disabled")
  • Updates the status bar indicator
  • Clears runtime overlays when turning AFK off

Practical Usage Examples

Start an unattended session from the command line:


# Enable AFK for a single invocation

kimi --afk

Toggle AFK interactively during a session:

/kimi > /afk        # enables AFK (toast notification appears)

...                 # agent runs unattended, auto-approving tools

/kimi > /afk        # disables AFK, returns to interactive mode

Check AFK status programmatically in custom tools:

from kimi_cli.runtime import Runtime

runtime = Runtime(...)
if runtime.approval.is_afk():
    # Skip user prompts, auto-approve all actions

    return ApprovalResult(True)

The src/kimi_cli/tools/ask_user.py module uses this same check to automatically dismiss questions when runtime.approval.is_afk() returns True.

Interaction with Yolo Mode

AFK mode and Yolo mode can coexist, creating distinct automation levels:

  • Yolo only: Auto-approves tool calls but still expects user answers to questions
  • AFK only: Auto-dismisses questions and auto-approves tools
  • Both enabled: Maximum automation where all tool calls pass and questions auto-dismiss

Disabling AFK while Yolo remains active returns the system to auto-approval-only behavior without question dismissal.

Summary

  • Kimi CLI AFK mode enables fully unattended execution by auto-approving tools and dismissing user questions
  • State is managed in src/kimi_cli/soul/approval.py via set_afk() and is_afk() methods
  • Dynamic context injection in src/kimi_cli/soul/dynamic_injections/afk_mode.py warns the LLM about user absence
  • Toggle via /afk slash command or --afk CLI flag, with support for both persistent and runtime-only overlays
  • Compatible with Yolo mode for configurable automation levels

Frequently Asked Questions

How do I enable Kimi CLI AFK mode temporarily for one command?

Use the --afk command-line flag when launching Kimi CLI. This sets a runtime-only overlay (runtime_afk) that automatically clears after the session ends, leaving your persistent settings unchanged.

What happens to AskUserQuestion prompts when AFK mode is active?

The system automatically dismisses them without recording answers. According to the implementation in src/kimi_cli/tools/ask_user.py, when runtime.approval.is_afk() returns True, the question is skipped entirely, wasting that conversational turn rather than pausing execution.

Can I use AFK mode and Yolo mode together?

Yes. When both modes are enabled, Kimi CLI auto-approves all tool calls (Yolo behavior) while also auto-dismissing any user questions (AFK behavior). Disabling AFK returns you to Yolo-only auto-approval, where questions still require human interaction.

Where is the AFK state stored between commands?

Persistent AFK state lives in the session's approval.afk boolean flag managed by src/kimi_cli/soul/approval.py. Runtime AFK flags exist only for the current invocation. The status bar displays afk_enabled to indicate when persistent AFK is active.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →