Repository navigation
fix(kap-server): bind the main agent when a session is created - #4839
Conversation
🦋 Changeset detectedLatest commit: f864272 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06e3b4e8fb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 331f495e69
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
* fix(agent-core-v2): truncate oversized skill content (#4834) * fix(kap-server): bind the main agent when a session is created (#4839) * fix(kap-server): bind the main agent when a session is created * fix(kap-server): reject a profile on prompt submissions * fix(kap-server): reject a profile change through the session profile * fix(kap-server): wait for model configuration before binding a new session * fix(agent-core-v2): deduplicate restored task notifications (#4836) * fix(agent-core-v2): deduplicate restored task notifications * chore: add notification replay fix changeset * fix(agent-core-v2): preserve task notifications after prompt-only crashes * fix(agent-core-v2): complete prompts before ending turns * test: align lifecycle snapshots with prompt completion order * fix(agent-core-v2): settle all prompts during turn finalization * fix(kap-server): drop reserved metadata keys from session profile updates (#4842) * fix(kap-server): drop reserved metadata keys from session profile updates * fix(kap-server): keep stored reserved metadata keys on profile updates * docs: split and rewrite the server API reference (#4841) * docs: split and rewrite the server API reference * docs: redirect old server API anchors to the split pages * docs: describe profile metadata as a replacement * docs: mark question responses as answered-only * fix(kap-server): avoid heartbeat timeout after scheduling stalls (#4823) * fix(kap-server): avoid heartbeat timeout reaping after stalls or clock jumps * fix(kap-server): grace heartbeat window for short scheduling stalls * fix(kap-server): treat only clearly late heartbeats as scheduling stalls * fix(kap-server): time heartbeats on a monotonic clock and drain queued input before reaping --------- Co-authored-by: Kimi Code (Grok Bot) <[email protected]> * fix(kap-server): undo a turn only once when requests race (#4846) * docs: describe heartbeat stall handling (#4849) * docs: describe heartbeat stall handling * docs: explain the monotonic clock in the heartbeat notes * fix(agent-core-v2): acquire session lock before loop restoration (#4848) * fix(agent-core-v2): acquire session lock before loop restoration * chore: add session lock lifecycle changeset * fix(agent-core-v2): hold session lock through loop restoration - add an operation-scoped lease to the session run gate - hold it across loop initialization, reset, and pending drains - cover idle timeout and release ordering * fix(agent-core-v2): keep the output of stopped tool calls (#4854) * fix(kap-server): drop the partial reply of a retried step (#4855) * fix(agent-core-v2): dedupe historical tool schemas (#4862) * fix(agent-core-v2): dedupe historical tool schemas * chore: add duplicate tool schema changeset * fix(agent-core-v2): preserve first tool schema declaration * fix(agent-core-v2): remind on changed tool schemas * fix(agent-core-v2): block stale tool schema calls * fix(agent-core-v2): normalize registry schemas in pending checks * fix(agent-core-v2): import registry tool metadata type * fix(agent-core-v2): preserve abort handling during validation * fix(agent-core-v2): refine validation hook preparation * fix(agent-core-v2): make validation hooks synchronous * fix(agent-core-v2): preserve tool result notes on fork (#4867) * fix(agent-core-v2): preserve tool result notes on fork * chore: add fork tool result note changeset * fix(agent-core-v2): scope tool result note restoration to forks * fix(agent-core-v2): normalize inherited tool result notes * fix(agent-core-v2): isolate fork note restoration * feat(tui): sweep running titles toward text and add KIMI_CODE_TUI_ANIMATION_FPS (#4843) (#4870) * chore: sync web dist from code-app (#4871) code-app: 8ab17294e031323186d357d121c5360b8353900e Co-authored-by: kimi-agent-bot <[email protected]> * ci: release packages (#4835) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: sync web dist from code-app code-app: 5835391dac3a2b9e0c65ffbd418f0d6042a7adb2 --------- Co-authored-by: Haozhe <[email protected]> Co-authored-by: qer <[email protected]> Co-authored-by: Kimi Code (Grok Bot) <[email protected]> Co-authored-by: grapedge <[email protected]> Co-authored-by: kimi-agent-bot <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Requirement or Bug
通过服务端 API 使用会话时,如果先设置思考强度、后设置模型,思考强度会在第一次绑定模型时被丢掉。这个 PR 让会话在创建时就确定 Agent profile、模型和思考强度,所有设置都针对一个确定的模型生效。
Bug Reproduction Steps
low/high的默认模型。POST /api/v1/sessions,agent_config只带{ "thinking": "high" }(或创建后先用 profile 接口只设thinking: "high")。thinking不是high,而是模型的初始强度。Root Cause
服务端创建会话时不绑定主 agent。没有绑定时,
setThinking只把强度存在未绑定的状态里;之后第一次设置模型会走bindProfile,而绑定只沿用「已绑定」状态里的强度,未绑定时存下的值被忽略。这是根本修复:会话创建时就完成绑定,之后不存在「未绑定时设置思考强度」的路径。只有服务端完全没有可用模型时会话才保持未绑定,这时设置思考强度直接返回
40113,不再悄悄丢失。Code Changes
创建会话的流程:
其余改动:
agent_config在创建请求里新增profile,只在创建时生效;Agent profile 绑定后本来就不能更换。profile时返回40001,不静默忽略。thinking时,如果主 agent 还没有模型、且同一请求没带model,返回40113(applyThinking)。profile.unknown映射为40001。server-api.md中英文同步。从
packages/kap-server/src/routes/sessionAgentConfig.ts的creationMainAgentBinding开始读。Behavior Changes and Affected Users
agent_config.modelmodel,或之后用 profile 接口换模型thinkingprofile或thinkingthinking悄悄存下40113,不创建会话thinking(profile 接口 / 提交输入)40113modelprofile字段40001,提示改用创建时的agent_config.profileagent_config.profile;不保留旧用法已与维护者确认agent_config.profile40001agent_config.profile40001,提示只能在创建时指定environment_id非local)创建profile.unknown错误5000140001desktop / web 的实际流程对比(按 code-app main 的客户端代码核对):创建会话时带
agent_config.model→ 立即用 profile 接口写思考强度、权限等 → 提交输入时带model/thinking/permission_mode,不带profile。之前的服务端收到model时同样在创建时绑定主 agent,所以这三步的结果和之前一致。测试覆盖(
packages/kap-server/test/):sessions.test.ts:thinking创建不丢;profile/model/thinking一起绑定;40001且不创建;40001,profile 不变;thinking返回40113;profile或thinking创建返回40113。prompts.test.ts:profile绑定的用例,新增「输入带profile返回40001」;Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.