Skip to content

feat(cli): set AI_AGENT for subprocesses - #2585

Open
complynx wants to merge 2 commits into
MoonshotAI:mainfrom
complynx:agent/ai-agent-marker
Open

feat(cli): set AI_AGENT for subprocesses#2585
complynx wants to merge 2 commits into
MoonshotAI:mainfrom
complynx:agent/ai-agent-marker

Conversation

@complynx

@complynx complynx commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • expose AI_AGENT=kimi to subprocesses launched from both the pip/uv and standalone binary entrypoints
  • preserve an explicit non-blank value supplied by a wrapper or orchestrator
  • cover missing, blank, and explicit marker behavior across both entrypoints

Why a universal marker

Tools launched by coding agents often need to adapt telemetry, UX, logging, or safety behavior based on whether they are running under an agent. Today they generally have to maintain agent-specific process-tree and environment heuristics. A shared AI_AGENT=<slug> convention lets the producer that already knows its identity declare it once, avoiding an N-by-M matrix of consumer heuristics as agents and tools multiply.

This is deliberately an advisory marker, not a security boundary. Kimi only supplies its own slug when the variable is missing or blank, so wrappers and higher-level orchestrators retain control of any explicit non-blank value.

Validation

  • uv run ruff format --check src/kimi_cli/__main__.py src/kimi_cli/cli/__main__.py src/kimi_cli/utils/subprocess_env.py tests/core/test_startup_imports.py
  • uv run ruff check src/kimi_cli/__main__.py src/kimi_cli/cli/__main__.py src/kimi_cli/utils/subprocess_env.py tests/core/test_startup_imports.py
  • uv run pytest tests/core/test_startup_imports.py tests/utils/test_subprocess_env.py -q (14 passed)

@complynx
complynx marked this pull request as ready for review August 4, 2026 12:21

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread src/kimi_cli/__main__.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant