feat(web): 添加 embedded session runtime 并默认启用 || feat(web): Add embedded session runtime and enable it by default#1650
Open
luzhongqiu wants to merge 6 commits intoMoonshotAI:mainfrom
Open
Conversation
fa9f822 to
3938e20
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b3a65d7c6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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.
概要
kimi web增加进程内的 embedded runtime,同时保留现有的 subprocess runtimeembedded,并保留KIMI_WEB_RUNTIME=process作为回退开关背景
#1641 讨论了
kimi web是否还需要维持“每个 session 一个 worker 子进程”的模式。由于底层 CLI 已经可以作为 Python async 代码在进程内运行,因此这个 PR 尝试以最小改动验证 embedded 方案是否可行。这次改动的目标是:
改动内容
EmbeddedSessionProcess和EmbeddedWireWorker,用于进程内执行 sessionSessionProcess作为 subprocess 实现,并在KimiCLIRunner中按配置选择 runtimekimi web的默认 runtime 切换为embeddedScopedLocalKaos,将 cwd 从进程级状态改为 session-local 状态chdir兼容性
这次改动有意保持现有 Web 接口契约不变:
web/api/*路由如果需要回退到原有子进程模式,仍然可以通过:
测试
uv run ruff check src/kimi_cli/web/app.py src/kimi_cli/web/runner/process.py src/kimi_cli/web/runner/embedded_process.py src/kimi_cli/web/runner/embedded_worker.py tests/web/test_runner.pyuv run pytest tests/web/test_runner.py tests/vis/test_app.pyuv run pytest packages/kaos/tests/test_local_kaos.pyuv run pytest tests/acp/test_kaos.py tests/acp/test_session_notifications.py tests/acp/test_protocol_v1.pyuv run pyright packages/kaos/src packages/kaos/tests src/kimi_cli/acp/server.py tests/acp/test_kaos.pyRefs #1641
Summary
kimi webwhile retaining the existing subprocess runtimeembeddedand keepKIMI_WEB_RUNTIME=processas fallback switchBackground
#1641 discussed whether
kimi webstill needs to maintain the "one worker child process per session" mode. Since the underlying CLI can already run in-process as Python async code, this PR attempts to verify whether the embedded solution is feasible with minimal changes.The goals of this change are:
Change content
EmbeddedSessionProcessandEmbeddedWireWorkerfor in-process session executionSessionProcessas subprocess implementation, and select the runtime according to configuration inKimiCLIRunnerkimi webtoembeddedScopedLocalKaosto change cwd from process-level state to session-local statechdirCompatibility
This change intentionally leaves the existing web interface contract unchanged:
web/api/*routesIf you need to return to the original sub-process mode, you can still pass:
Test
uv run ruff check src/kimi_cli/web/app.py src/kimi_cli/web/runner/process.py src/kimi_cli/web/runner/embedded_process.py src/kimi_cli/web/runner/embedded_worker.py tests/web/test_runner.pyuv run pytest tests/web/test_runner.py tests/vis/test_app.pyuv run pytest packages/kaos/tests/test_local_kaos.pyuv run pytest tests/acp/test_kaos.py tests/acp/test_session_notifications.py tests/acp/test_protocol_v1.pyuv run pyright packages/kaos/src packages/kaos/tests src/kimi_cli/acp/server.py tests/acp/test_kaos.pyRefs #1641