Repository navigation
feat(agent-core-v2): expose session and workspace IDs in Bash tool env - #5053
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
sailist
approved these changes
Nov 18, 2026
This was referenced Nov 19, 2026
Merged
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Nov 25, 2026
Route file download and session media URL calls through a sessionSync route that answers from the current owner without a session load (MoonshotAI#5336). Add thoughtsTokenCount to the Google GenAI output usage with thinking and zero-thinking fixtures (MoonshotAI#5334), update the desktop composer e2e specs for the label-only slash menu (MoonshotAI#5274), and document the Bash session/workspace env vars (MoonshotAI#5053).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
当 Kimi Code 会话内运行的脚本、Hooks 或 Agent Skill(例如通过本地 KAP 服务派生或交接并行会话的
use-kimi-code)在Bash工具子进程中执行时,此前子进程环境变量中没有当前会话 ID 与所属工作区 ID。若当前会话位于显式创建的managed工作区(wm_*),子进程仅凭$PWD(cwd)调用POST /api/v1/sessions会落入隐式wd_*桶而无法归入当前工作区。本 PR 在Bash工具子进程环境中注入KIMI_CODE_SESSION_ID与KIMI_CODE_WORKSPACE_ID,让会话内执行的命令和自动化脚本能够直接获知当前会话与所属工作区标识。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
BashTool已注入@ISessionContext(携带sessionId与workspaceId),在BashTool.spawn构造子进程noninteractiveEnv时直接写入这两个只读上下文环境变量:const noninteractiveEnv: Record<string, string> = { NO_COLOR: '1', TERM: 'dumb', GIT_TERMINAL_PROMPT: process.env['GIT_TERMINAL_PROMPT'] ?? '0', SHELL: env.shellPath, + KIMI_CODE_SESSION_ID: this.ctx.sessionId, + KIMI_CODE_WORKSPACE_ID: this.ctx.workspaceId, };packages/agent-core-v2/src/agent/tools/os/bash/bashTool.ts:向Bash工具启动的子进程环境注入KIMI_CODE_SESSION_ID与KIMI_CODE_WORKSPACE_ID。packages/agent-core-v2/test/os/backends/node-local/tools/bash.test.ts:断言子进程env包含当前会话与工作区 ID。docs/{zh,en}/reference/tools.md:在Bash工具说明中补充这两个子进程环境变量。Behavior Changes and Affected Users
Bash工具子进程环境变量NO_COLOR、TERM、GIT_TERMINAL_PROMPT、SHELL(叠加宿主进程环境)KIMI_CODE_SESSION_ID(当前会话 ID)与KIMI_CODE_WORKSPACE_ID(当前工作区 ID)Bash工具运行的命令与脚本packages/agent-core-v2(BashTool)、docs/{zh,en}/reference/tools.mdpackages/agent-core-v2/test/os/backends/node-local/tools/bash.test.ts(77 项测试全部通过)。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.