kiki-agent 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/dist/docs/en/configuration/config-files.md +32 -19
  2. package/dist/docs/en/configuration/data-locations.md +23 -1
  3. package/dist/docs/en/configuration/env-vars.md +6 -8
  4. package/dist/docs/en/configuration/overrides.md +19 -8
  5. package/dist/docs/en/configuration/providers.md +75 -4
  6. package/dist/docs/en/customization/agents-and-subagents.md +6 -2
  7. package/dist/docs/en/customization/personas.md +36 -2
  8. package/dist/docs/en/customization/plugins.md +41 -1
  9. package/dist/docs/en/customization/prompt-fields.md +4 -0
  10. package/dist/docs/en/features/agent-workflows.md +8 -8
  11. package/dist/docs/en/features/browser-and-computer.md +40 -0
  12. package/dist/docs/en/features/daily.md +10 -10
  13. package/dist/docs/en/features/ecosystem.md +5 -5
  14. package/dist/docs/en/features/extend.md +9 -8
  15. package/dist/docs/en/features/freedom.md +8 -8
  16. package/dist/docs/en/features/index.md +44 -28
  17. package/dist/docs/en/features/long-work.md +9 -9
  18. package/dist/docs/en/features/look.md +5 -5
  19. package/dist/docs/en/features/people.md +6 -6
  20. package/dist/docs/en/features/phone.md +5 -3
  21. package/dist/docs/en/features/spaces.md +7 -7
  22. package/dist/docs/en/features/workbench.md +8 -8
  23. package/dist/docs/en/guides/interface.md +16 -4
  24. package/dist/docs/en/guides/sessions.md +6 -2
  25. package/dist/docs/en/guides/settings.md +15 -2
  26. package/dist/docs/en/reference/command.md +58 -1
  27. package/dist/docs/en/reference/tools.md +25 -5
  28. package/dist/docs/en/server/acp.md +3 -1
  29. package/dist/docs/en/server/mcp.md +5 -1
  30. package/dist/docs/en/server/rest-api.md +115 -4
  31. package/dist/docs/zh/configuration/config-files.md +32 -19
  32. package/dist/docs/zh/configuration/data-locations.md +23 -1
  33. package/dist/docs/zh/configuration/env-vars.md +6 -8
  34. package/dist/docs/zh/configuration/overrides.md +19 -8
  35. package/dist/docs/zh/configuration/providers.md +75 -4
  36. package/dist/docs/zh/customization/agents-and-subagents.md +6 -2
  37. package/dist/docs/zh/customization/personas.md +36 -2
  38. package/dist/docs/zh/customization/plugins.md +41 -1
  39. package/dist/docs/zh/customization/prompt-fields.md +4 -0
  40. package/dist/docs/zh/features/agent-workflows.md +10 -10
  41. package/dist/docs/zh/features/browser-and-computer.md +40 -0
  42. package/dist/docs/zh/features/daily.md +10 -10
  43. package/dist/docs/zh/features/ecosystem.md +5 -5
  44. package/dist/docs/zh/features/extend.md +8 -7
  45. package/dist/docs/zh/features/freedom.md +8 -8
  46. package/dist/docs/zh/features/index.md +44 -28
  47. package/dist/docs/zh/features/long-work.md +8 -8
  48. package/dist/docs/zh/features/look.md +5 -5
  49. package/dist/docs/zh/features/people.md +5 -5
  50. package/dist/docs/zh/features/phone.md +5 -3
  51. package/dist/docs/zh/features/spaces.md +7 -7
  52. package/dist/docs/zh/features/workbench.md +8 -8
  53. package/dist/docs/zh/guides/interface.md +16 -4
  54. package/dist/docs/zh/guides/sessions.md +6 -2
  55. package/dist/docs/zh/guides/settings.md +15 -2
  56. package/dist/docs/zh/reference/command.md +58 -1
  57. package/dist/docs/zh/reference/tools.md +25 -5
  58. package/dist/docs/zh/server/acp.md +3 -1
  59. package/dist/docs/zh/server/mcp.md +5 -1
  60. package/dist/docs/zh/server/rest-api.md +114 -3
  61. package/dist/hostRunner.mjs +92 -1
  62. package/dist/mailbox-worker.mjs +297 -0
  63. package/dist/main.mjs +2 -2
  64. package/dist/native/windows-process-helper.exe +0 -0
  65. package/dist/query-store-worker.mjs +446 -0
  66. package/dist/sqlite-indexer.mjs +223 -401
  67. package/dist/sqlite-query-worker.mjs +226 -249
  68. package/dist/usage-parser-worker.mjs +24 -5
  69. package/dist/web/assets/AppErrorBoundary-BN6IDdP1.js +1 -0
  70. package/dist/web/assets/{LifeMark-CL6-HWDu.js → LifeMark-UBMVaTWr.js} +1 -1
  71. package/dist/web/assets/{NavScopeBoundary-CFCnvZR0.js → NavScopeBoundary-BCryw-UG.js} +1 -1
  72. package/dist/web/assets/{arc-DYDCMlOS.js → arc-C7IAvCCJ.js} +1 -1
  73. package/dist/web/assets/{architectureDiagram-3BPJPVTR-C9Y7T0O2.js → architectureDiagram-3BPJPVTR-CbwFBxn7.js} +1 -1
  74. package/dist/web/assets/{blockDiagram-GPEHLZMM-CdUrp-tD.js → blockDiagram-GPEHLZMM-B20N4t8r.js} +1 -1
  75. package/dist/web/assets/{c4Diagram-AAUBKEIU-PrwvB9IJ.js → c4Diagram-AAUBKEIU-3BYtlcP-.js} +1 -1
  76. package/dist/web/assets/channel-BJs5vJuh.js +1 -0
  77. package/dist/web/assets/{chunk-2J33WTMH-BL56g_Es.js → chunk-2J33WTMH-CpjgczxM.js} +1 -1
  78. package/dist/web/assets/{chunk-4BX2VUAB-DvJD5M9M.js → chunk-4BX2VUAB-BScxUF5G.js} +1 -1
  79. package/dist/web/assets/{chunk-55IACEB6-C8f-nzvx.js → chunk-55IACEB6-CrcLYJXd.js} +1 -1
  80. package/dist/web/assets/{chunk-727SXJPM-DOGkWKkV.js → chunk-727SXJPM-BwlyIOjw.js} +1 -1
  81. package/dist/web/assets/{chunk-AQP2D5EJ-fFOuz7g6.js → chunk-AQP2D5EJ-DKKIRkRv.js} +1 -1
  82. package/dist/web/assets/{chunk-FMBD7UC4-BpeXZ9LM.js → chunk-FMBD7UC4-CVDMj2kX.js} +1 -1
  83. package/dist/web/assets/{chunk-ND2GUHAM-CRUh76fb.js → chunk-ND2GUHAM-CL-PM6r8.js} +1 -1
  84. package/dist/web/assets/{chunk-QZHKN3VN-uNfxaPk0.js → chunk-QZHKN3VN-DPV2KbKZ.js} +1 -1
  85. package/dist/web/assets/classDiagram-4FO5ZUOK-BookeACB.js +1 -0
  86. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BookeACB.js +1 -0
  87. package/dist/web/assets/client-CXcrCawx.js +3 -0
  88. package/dist/web/assets/connection-C8nwzwXB.js +1 -0
  89. package/dist/web/assets/{cose-bilkent-S5V4N54A-BNkxG-qX.js → cose-bilkent-S5V4N54A-D1CEiQM6.js} +1 -1
  90. package/dist/web/assets/{dagre-BM42HDAG-BerioUei.js → dagre-BM42HDAG-BlFV941E.js} +1 -1
  91. package/dist/web/assets/{diagram-2AECGRRQ-Czv2SR07.js → diagram-2AECGRRQ-BC0ldkFY.js} +1 -1
  92. package/dist/web/assets/{diagram-5GNKFQAL-Uzi1weGK.js → diagram-5GNKFQAL-B22Iej6G.js} +1 -1
  93. package/dist/web/assets/{diagram-KO2AKTUF-W36h_ff3.js → diagram-KO2AKTUF-B75UNw6D.js} +1 -1
  94. package/dist/web/assets/{diagram-LMA3HP47-FG4dDk52.js → diagram-LMA3HP47-CypI7IJM.js} +1 -1
  95. package/dist/web/assets/{diagram-OG6HWLK6-CQoEjIAY.js → diagram-OG6HWLK6-OsXumvcD.js} +1 -1
  96. package/dist/web/assets/{erDiagram-TEJ5UH35-Ck06KVyZ.js → erDiagram-TEJ5UH35-3756GOvS.js} +1 -1
  97. package/dist/web/assets/{export-T_izwEkQ.js → export-Bn8PqPg4.js} +1 -1
  98. package/dist/web/assets/{flowDiagram-I6XJVG4X-C5hgxdFZ.js → flowDiagram-I6XJVG4X-DB6Y_UDg.js} +1 -1
  99. package/dist/web/assets/{ganttDiagram-6RSMTGT7-BS52Pw5_.js → ganttDiagram-6RSMTGT7-CHJeuoAY.js} +1 -1
  100. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DLlQKZHs.js → gitGraphDiagram-PVQCEYII-Dj85554Y.js} +1 -1
  101. package/dist/web/assets/{highlighted-body-OFNGDK62-Btm6MuZ4.js → highlighted-body-OFNGDK62-DMgPHetp.js} +1 -1
  102. package/dist/web/assets/{index-CZX3qUe2.js → index-0tHq8zh2.js} +1 -1
  103. package/dist/web/assets/index-7ySDqvaN.css +1 -0
  104. package/dist/web/assets/index-B0KPRi1U.js +166 -0
  105. package/dist/web/assets/{index-CRDDqofN.js → index-B599VnpP.js} +1 -1
  106. package/dist/web/assets/{index-Cd62y0wD.js → index-BFK-GypQ.js} +1 -1
  107. package/dist/web/assets/{index-BMWid2q9.js → index-BPX8gmpB.js} +1 -1
  108. package/dist/web/assets/{index-5_yzg61S.js → index-BSGYc1tb.js} +1 -1
  109. package/dist/web/assets/{index-CJ92kLtO.js → index-BTt9Q5iv.js} +1 -1
  110. package/dist/web/assets/{index-B4iu4SJW.js → index-BWzUsoY_.js} +1 -1
  111. package/dist/web/assets/{index-CgcJPsK6.js → index-BYlSV3FO.js} +1 -1
  112. package/dist/web/assets/{index-BkPV0psm.js → index-BpXQ1q-u.js} +1 -1
  113. package/dist/web/assets/{index-Dceu0bqY.js → index-BqPxpGUh.js} +1 -1
  114. package/dist/web/assets/{index-CM-nNfuV.js → index-C6qeLCPw.js} +4 -4
  115. package/dist/web/assets/{index-ByiwExpV.js → index-C7mOS2T4.js} +1 -1
  116. package/dist/web/assets/{index-CG8uIlD7.js → index-C8OFfbEs.js} +1 -1
  117. package/dist/web/assets/{index-B-6LiYTY.js → index-CI7yuMGZ.js} +1 -1
  118. package/dist/web/assets/{index-B2Pu0Iuu.js → index-CJqIcuAl.js} +1 -1
  119. package/dist/web/assets/{index-BECSk4If.js → index-CTRJmDep.js} +1 -1
  120. package/dist/web/assets/{index-Bezli3SF.js → index-CXGCKoId.js} +1 -1
  121. package/dist/web/assets/{index-hG2s2Spn.js → index-CsY571EL.js} +1 -1
  122. package/dist/web/assets/{index-BFcyN2Zw.js → index-CwQG_9rB.js} +1 -1
  123. package/dist/web/assets/{index-BLU8_Um7.js → index-D--cw39y.js} +1 -1
  124. package/dist/web/assets/{index-B9MlqF7J.js → index-D260jsUJ.js} +1 -1
  125. package/dist/web/assets/{index-D_oPSlBL.js → index-DJjmEXx4.js} +1 -1
  126. package/dist/web/assets/{index-BNch_a4L.js → index-DRMjjql1.js} +1 -1
  127. package/dist/web/assets/{index-BeMvPEXs.js → index-DUxOVxHS.js} +1 -1
  128. package/dist/web/assets/{index-Ca607_hK.js → index-DZMkZKhW.js} +1 -1
  129. package/dist/web/assets/{index-BwcG86o3.js → index-DqK8MfQN.js} +1 -1
  130. package/dist/web/assets/{index-DKIysLbI.js → index-DxUmR9aV.js} +1 -1
  131. package/dist/web/assets/{index-Cy8C_eFR.js → index-GK8aa9pT.js} +1 -1
  132. package/dist/web/assets/{index-Bg99yVX_.js → index-bYtKyBMB.js} +1 -1
  133. package/dist/web/assets/{index-eUyF-8Sq.js → index-wxHFHTgD.js} +1 -1
  134. package/dist/web/assets/{infoDiagram-5YYISTIA-CD4XJGFm.js → infoDiagram-5YYISTIA-DeDPIdEH.js} +1 -1
  135. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-fu5E3_CT.js → ishikawaDiagram-YF4QCWOH-ButuBiBW.js} +1 -1
  136. package/dist/web/assets/{journeyDiagram-JHISSGLW-CXcnKBfJ.js → journeyDiagram-JHISSGLW-Dlbmqm-j.js} +1 -1
  137. package/dist/web/assets/{kanban-definition-UN3LZRKU-BawKH6Pl.js → kanban-definition-UN3LZRKU-tlQK1cOz.js} +1 -1
  138. package/dist/web/assets/{linear-BplJuXph.js → linear-iXuNfUWp.js} +1 -1
  139. package/dist/web/assets/mermaid-GHXKKRXX-sDJax95P.js +624 -0
  140. package/dist/web/assets/{mindmap-definition-RKZ34NQL-DA1SE2uy.js → mindmap-definition-RKZ34NQL-2qPv-mwT.js} +1 -1
  141. package/dist/web/assets/{pieDiagram-4H26LBE5-6i021QeX.js → pieDiagram-4H26LBE5-CrLe1C-O.js} +1 -1
  142. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CcKSZDMT.js → quadrantDiagram-W4KKPZXB-DfeIFxc0.js} +1 -1
  143. package/dist/web/assets/{requirementDiagram-4Y6WPE33-lYVuWRuD.js → requirementDiagram-4Y6WPE33-BWtjdxie.js} +1 -1
  144. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-4Zfb4_h4.js → sankeyDiagram-5OEKKPKP-B5TxJ6mb.js} +1 -1
  145. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DqltKmlY.js → sequenceDiagram-3UESZ5HK-Cf92ZCl1.js} +1 -1
  146. package/dist/web/assets/{spaces-CjuXbmxF.js → spaces-DqMTtCXX.js} +1 -1
  147. package/dist/web/assets/{stateDiagram-AJRCARHV-HFdhqxzx.js → stateDiagram-AJRCARHV-NR9I-Q4d.js} +1 -1
  148. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BiegFWxE.js +1 -0
  149. package/dist/web/assets/{theme-beWE_6f8.js → theme-6OL1RXgY.js} +1 -1
  150. package/dist/web/assets/{timeline-definition-PNZ67QCA-HNRxaB3t.js → timeline-definition-PNZ67QCA-CBAOVMfm.js} +1 -1
  151. package/dist/web/assets/{vennDiagram-CIIHVFJN-DwsCTyaD.js → vennDiagram-CIIHVFJN-C68x6TdS.js} +1 -1
  152. package/dist/web/assets/{wardley-L42UT6IY-BWW2wtVO.js → wardley-L42UT6IY-DuZZr5jm.js} +1 -1
  153. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-C-ktKm7v.js → wardleyDiagram-YWT4CUSO-D6dVGtHd.js} +1 -1
  154. package/dist/web/assets/{xychartDiagram-2RQKCTM6-48AxNW9k.js → xychartDiagram-2RQKCTM6-DYLUhZX4.js} +1 -1
  155. package/dist/web/index.html +2 -2
  156. package/native/auth-native/prebuilds/linux-arm64/auth-native.node +0 -0
  157. package/native/auth-native/prebuilds/linux-x64/auth-native.node +0 -0
  158. package/native/auth-native/prebuilds/win32-arm64/auth-native.node +0 -0
  159. package/native/auth-native/prebuilds/win32-x64/auth-native.node +0 -0
  160. package/package.json +2 -2
  161. package/dist/search-worker.mjs +0 -14177
  162. package/dist/web/assets/AppErrorBoundary-DiGMUg4r.js +0 -1
  163. package/dist/web/assets/channel-Bj_gZ_Lv.js +0 -1
  164. package/dist/web/assets/classDiagram-4FO5ZUOK-ssCwe2R4.js +0 -1
  165. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-ssCwe2R4.js +0 -1
  166. package/dist/web/assets/client-DGj93bGT.js +0 -3
  167. package/dist/web/assets/connection-Bpf-EjrL.js +0 -1
  168. package/dist/web/assets/index-BIebkSEI.css +0 -1
  169. package/dist/web/assets/index-D8z7lcQn.js +0 -166
  170. package/dist/web/assets/mermaid-GHXKKRXX-BO9hkP3Z.js +0 -621
  171. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Dx28QuZF.js +0 -1
@@ -237,18 +237,19 @@ The following sections detail the nested tables listed above.
237
237
 
238
238
  ## `providers`
239
239
 
240
- Each entry in the `providers` table defines an API provider, keyed by a unique name. The provider's `api_key` lives in [`credentials.toml`](#provider-credentials), and the CLI does **not** fall back to shell environment variables automatically. Running `export KIMI_API_KEY` in the terminal does not give any provider its key — write it in `credentials.toml` instead.
240
+ Each entry in the `providers` table defines an API provider, keyed by a unique name. Store an API key in [`credentials.toml`](#provider-credentials), or set `api_key_env` in `config.toml` to read a named environment variable from the Kiki process. Without that explicit reference, exporting a provider key in the shell has no effect.
241
241
 
242
242
  | Field | Type | Required | Description |
243
243
  | --- | --- | --- | --- |
244
244
  | `type` | `string` | Yes | Provider type: `kimi`, `anthropic`, `openai`, `openai_responses`, `google-genai`, `vertexai` |
245
245
  | `api_key` | `string` | No | API key. Stored in `credentials.toml`; a value in `config.toml` is used only when `credentials.toml` has none for that provider |
246
+ | `api_key_env` | `string` | No | Non-empty environment variable name, not a key value. Stored in `config.toml`; consulted only when `api_key` is empty. See [credential priority and example](./overrides.md#provider-credentials) |
246
247
  | `base_url` | `string` | No | API base URL |
247
248
  | `oauth` | `table` | No | OAuth credential reference (`storage` and `key` fields); injected automatically by the login flow — normally no need to write this by hand |
248
- | `env` | `table<string, string>` | No | Fallback source for provider credentials; see below |
249
+ | `env` | `table<string, string>` | No | Provider environment values; see below |
249
250
  | `custom_headers` | `table<string, string>` | No | Custom HTTP headers attached to each request |
250
251
 
251
- **`env` sub-table**: You can write provider-conventional key names (such as `KIMI_API_KEY`) inside `[providers.<name>.env]` as a fallback source for `api_key` / `base_url`. This sub-table is **read only from the config file** and does not modify the shell environment:
252
+ **`env` sub-table**: You can write provider-conventional key names (such as `KIMI_API_KEY`) inside `[providers.<name>.env]` as a fallback source for `api_key` / `base_url`. It also takes priority over the process environment for the variable named by `api_key_env`, including an explicitly empty value. This sub-table is **read only from the config file** and does not modify the shell environment:
252
253
 
253
254
  ```toml
254
255
  [providers.kimi.env]
@@ -256,7 +257,7 @@ KIMI_API_KEY = "sk-xxx"
256
257
  KIMI_BASE_URL = "https://api.moonshot.ai/v1"
257
258
  ```
258
259
 
259
- Priority: `api_key` field > `env` sub-table key > if both are absent, startup fails with an error. `type = "vertexai"` can omit `api_key` when the env sub-table sets both `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION`. An `api_key` set alongside those coordinates is still sent. See [Vertex AI](./providers.md#vertexai).
260
+ If the variable named by `api_key_env` is missing or empty, Kiki does not fall back to another credential variable. See [Config overrides](./overrides.md#provider-credentials) for the full resolution order. `type = "vertexai"` can omit `api_key` when the env sub-table sets both `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION`. An API key set alongside those coordinates is still sent. See [Vertex AI](./providers.md#vertexai).
260
261
 
261
262
  ## `models`
262
263
 
@@ -536,6 +537,8 @@ A partial update changes only the fields you send. `POST /api/config` with `{ "m
536
537
  | --- | --- | --- | --- |
537
538
  | `max_steps_per_turn` | `integer` | — | Maximum steps per turn; unset or `0` means unlimited |
538
539
  | `max_attempts_per_step` | `integer` | `5` | Maximum total attempts for a failing step, including the initial attempt |
540
+ | `thinking_only_continuation` | `boolean` | `true` | Send one explicit `Continue.` user message when a model ends normally with only non-empty thinking |
541
+ | `zero_output_continuation` | `boolean` | `false` | Send one explicit `Continue.` user message when a normal completion has no thinking text, visible text, or tool call |
539
542
  | `reserved_context_size` | `integer` | `50000` | Tokens reserved above the automatic compaction point for model output |
540
543
  | `auto_compact` | `string` | — | Global default compaction point as a percentage of the model's usable context (e.g. `"85%"`). This layer does not accept token counts; model, profile, and session settings use positive integer tokens |
541
544
  | `compaction_trigger_ratio` | `number` | `0.85` | Legacy trigger ratio, used only when no `auto_compact` is set at any layer |
@@ -546,7 +549,13 @@ The compaction point resolves in this order: the session's per-model token overr
546
549
 
547
550
  `max_steps_per_turn` can be overridden by the `KIKI_LOOP_MAX_STEPS_PER_TURN` environment variable, and `max_attempts_per_step` by `KIKI_LOOP_MAX_ATTEMPTS_PER_STEP`; both take higher priority than the config file.
548
551
 
549
- Retries only apply to transient failures — connection errors, timeouts, HTTP 429 rate limits, and all HTTP 500–599 server errors. A 429 caused by an exhausted quota or insufficient account balance is not retried and fails immediately, since it cannot succeed until the account is recharged.
552
+ Retries only apply to transient failures — connection errors, timeouts, HTTP 429 rate limits, and eligible HTTP 500–599 server errors. Partial output, safety refusals, and exhausted quota stop rather than replaying the request.
553
+
554
+ When a provider confirms a normal end with non-empty thinking but no answer, tool call, or refusal, Kiki keeps the thinking and its signature and sends a `Continue.` user message at most once per turn. A gateway's exact `antigravity_thinking_only` event can also qualify, but only when Kiki retained the actual thinking and confirmed that no other output, grounding, or refusal occurred. Cancellation, missing terminal events, interrupted streams, and token-limit stops do not qualify. The follow-up counts as a real model request with its own usage. A second empty response or failure stops the turn—even HTTP 429 or a temporary server error is not retried for this follow-up.
555
+
556
+ Set `[loop_control] thinking_only_continuation = false` to disable this automatic message. Changes apply at the next step boundary. Google models that reject a trailing model turn keep their existing original-snapshot retry; it shares the same one-recovery-per-turn budget and is not disabled by this setting. Google `CONTINUATION` stops still require a continuation token that this SDK cannot send.
557
+
558
+ `zero_output_continuation` stays off when omitted or set to `false`. Set `[loop_control] zero_output_continuation = true` to send one `Continue.` user message after a provider confirms a normal completion whose thinking text, visible answer, and tool calls are all empty. A signature attached to empty thinking is not thinking content and stays in the conversation. Non-empty redacted thinking data is output. Non-empty thinking text still uses `thinking_only_continuation`. A child agent uses the same rule; while the switch is off, a child completion with no content still fails, and a second empty completion stops the turn. Token counts do not decide this. The choice applies at the next step boundary. That follow-up is one model request in the same turn and is not retried as a connection or rate-limit error. Cancellation, provider errors, and a stream that ends without a normal stop stay on their existing paths.
550
559
 
551
560
  ### Continuity reminder settings
552
561
 
@@ -590,7 +599,7 @@ New sessions keep changing date, directory listings, workspace instructions and
590
599
 
591
600
  ## `retry`
592
601
 
593
- `retry` customizes the total attempt budget and fixed backoff for selected step errors. By default, a retryable step gets five total attempts, with waits of 2, 4, 8, and 16 seconds plus up to 25% jitter (30–37.5 seconds in total). A provider `Retry-After` value or a matching policy's fixed `backoff` replaces the corresponding default wait. The section and each policy are strict: an unknown field is rejected rather than silently ignored.
602
+ `retry` customizes the total attempt budget and fixed backoff for selected step errors. By default, a retryable step gets five total attempts, with waits of 2, 4, 8, and 16 seconds plus up to 25% jitter (30–37.5 seconds in total). A provider `Retry-After` value or a matching policy's fixed `backoff` replaces the corresponding default wait. Policies can also target exact model and provider configuration keys, so one provider's temporary failures do not change retry behavior elsewhere. The section and each policy are strict: an unknown field is rejected rather than silently ignored.
594
603
 
595
604
  | Field | Type | Default | Description |
596
605
  | --- | --- | --- | --- |
@@ -601,27 +610,28 @@ Each `[[retry.policies]]` entry has these fields:
601
610
 
602
611
  | Field | Type | Required | Description |
603
612
  | --- | --- | --- | --- |
604
- | `match` | `string` | Yes | Regular expression matched against the error code and error name |
613
+ | `match` | `string` | Yes | JavaScript regular expression matched against the error code and error name; inline modifiers such as `(?i)` are invalid and cause the policy to be ignored with a configuration warning |
614
+ | `models` | `array<string>` | No | Exact canonical `[models]` keys; the policy applies only when the bound model is listed |
615
+ | `providers` | `array<string>` | No | Exact `[providers]` keys; the policy applies only when the bound provider is listed |
605
616
  | `max_attempts` | `integer` | No | Total attempts for matching errors, including the initial attempt; overrides the section-level budget |
606
617
  | `backoff` | `integer` | No | Fixed delay in milliseconds before each retry; a provider retry-after hint still takes precedence |
607
618
  | `retry` | `boolean` | No | Defaults to `true`. `false` can suppress an error that Kiki normally considers retryable; `true` cannot force retries for an error classified as non-retryable |
608
619
 
609
- Policies are checked from top to bottom, so put specific regular expressions before broader ones:
620
+ Policies are checked from top to bottom. A policy whose `models` or `providers` selector does not contain the current binding is skipped; the first remaining policy whose `match` expression matches the error applies. If both selectors are present, both must match. Omitting both selectors preserves the earlier global per-error behavior.
610
621
 
611
- ```toml
612
- [retry]
613
- max_attempts = 4
622
+ This example keeps the ordinary five-attempt default for every other model and provider, but gives one native Google GenAI Argon binding up to 20 total attempts for HTTP 429 rate limits:
614
623
 
624
+ ```toml
615
625
  [[retry.policies]]
616
626
  match = '^provider\.rate_limit$'
617
- max_attempts = 6
618
- backoff = 1000
619
-
620
- [[retry.policies]]
621
- match = '^provider\.'
622
- retry = false
627
+ models = ['gemini-4-argon']
628
+ providers = ['google-native']
629
+ max_attempts = 20
630
+ backoff = 15000
623
631
  ```
624
632
 
633
+ Replace `gemini-4-argon` and `google-native` with the exact keys used in your `[models]` and `[providers]` tables. The `backoff` applies only when the provider does not send `Retry-After`. The policy does not make HTTP 400, exhausted quota, partial output, or already-executed failures retryable; `retry = true` never overrides Kiki's non-retryable classification.
634
+
625
635
  ## `transcript_memory`
626
636
 
627
637
  `transcript_memory` controls how much transcript history the server keeps in memory. All three fields are optional: an omitted field uses its default.
@@ -836,16 +846,19 @@ Any registered flag can be overridden here by id, with a boolean value. Every bu
836
846
 
837
847
  ## `browser_control`
838
848
 
839
- `browser_control` holds the browser connections managed by [Browser control](../guides/settings.md#browser-control) and the default used for new sessions. The settings page is the supported editor: it saves one entry per connection, reads it back before showing the result, and saving never starts a browser.
849
+ `browser_control` holds the browser connections managed by [Browser control](../guides/settings.md#browser-control) and the default used for new sessions. The settings page is the supported editor: it saves one entry per connection, reads it back before showing the result, and saving never starts a browser. To add an HTTP bridge connection, choose **Add browser** and set **Connection style** to **Kimi WebBridge**.
840
850
 
841
851
  | Field | Type | Description |
842
852
  | --- | --- | --- |
843
853
  | `default_browser` | `string` | Connection id used for sessions created afterwards; unset means a call has to name a connection |
844
854
  | `allowed_browsers` | `string[]` | Connection ids an agent may use. Omit it to keep the previous default. An empty list still allows listing and discovery |
845
855
  | `disabled_sources` | `string[]` | Sources that are off: `kimi-webbridge`, `independent-browser`, `codex-browser`, `ego-lite`. Turning a source off does not clear `allowed_browsers` |
856
+ | `webbridge_preset_route` | `boolean` | Defaults to `true`: route the legacy `kimi-webbridge` id stored as `agent-browser-cdp` through the Kimi HTTP bridge. Set `false` to keep that entry on the CDP driver |
846
857
  | `connections` | `table` | One entry per connection, keyed by the connection's fixed id |
847
858
 
848
- Each entry describes one connection through its `type` (`agent-browser-profile` or `agent-browser-cdp`), `name`, `enabled`, and the fields that style needs; the settings page shows the fields for each style. An entry whose fields do not match its style is rejected and the saved file is left unchanged. A stored CDP address counts as a credential: the page masks it and reveals it only when asked.
859
+ Each entry has `name`, `enabled`, and a `type`: `agent-browser-profile`, `agent-browser-cdp`, `codex-extension`, `ego-lite`, `kimi-webbridge`, or `webbridge-command`. The [browser connection API](../server/rest-api.md#browser-connections) describes each type's fields. Fields that do not match the type are rejected without changing the saved file. A stored CDP address counts as a credential: the page masks it and reveals it only when asked. `webbridge-command` takes only `name` and `enabled`, uses the fixed local command bridge, and belongs to the `kimi-webbridge` source switch. It has no endpoint or driver path; a CDP row is not converted into this type.
860
+
861
+ The `kimi-webbridge` type uses the server's local HTTP daemon at `http://127.0.0.1:10086` and takes no endpoint. This is not a CDP address. The legacy-id routing above does not rewrite the saved entry and does not affect other CDP ids; an explicit `kimi-webbridge` type always uses HTTP, even when `webbridge_preset_route` is `false`.
849
862
 
850
863
  ## `computer_control`
851
864
 
@@ -54,6 +54,8 @@ $KIKI_HOME (default: ~/.kiki)
54
54
  │ └── <key>-<suffix>.json
55
55
  ├── sessions/ # Session data (see below)
56
56
  │ └── <workDirKey>/<sessionId>/
57
+ ├── store/
58
+ │ └── thread-mailbox-sqlite-v1/ # Canonical mailbox and upgrade recovery copies
57
59
  ├── server/
58
60
  │ └── events/ # Bounded client event replay journals
59
61
  ├── bin/
@@ -89,7 +91,7 @@ Inside each session directory:
89
91
 
90
92
  - **`state.json`**: session metadata including title, `lastPrompt`, creation/update timestamps, and `forkedFrom`.
91
93
  - **`upcoming-goals.json`**: the TUI-only queue created by `/goal next <objective>`. It is not part of the agent conversation until a queued goal is promoted after the current goal completes.
92
- - **`agents/main/wire.jsonl`**: the main Agent's complete communication record, used for session resumption and replay.
94
+ - **`agents/main/wire.jsonl`**: the main Agent's complete communication record, used for session resumption and replay. [`kiki session seal`](../reference/command.md#kiki-session) leaves this file in place, so its size does not drop; [`kiki session unseal`](../reference/command.md#kiki-session) removes the seal without modifying the file.
93
95
  - **`agents/main/plans/`**: plan files written in Plan mode, named by plan id (`<id>.md`).
94
96
  - **`agents/agent-0/` etc.**: sub-Agent instance directories, each containing their own `wire.jsonl`.
95
97
  - **`logs/kimi-code.log`**: diagnostic log for this session; only present when a diagnostic event occurs.
@@ -104,6 +106,26 @@ Older journals shrink when the new writer first appends to them. Browsing a cold
104
106
 
105
107
  This retention does not remove `sessions/`, agent `wire.jsonl` files, or saved media. Clients whose cursor is no longer covered recover through a snapshot/reset rather than replaying the old event sequence; see [Reconnect and recovery](../server/rest-api.md#reconnect-and-recovery). If you need to clear old journals manually, first stop every Kiki server using this data root, then clear only `server/events/` and restart. Never delete or truncate these journals while a writer is running.
106
108
 
109
+ ## Canonical mailbox
110
+
111
+ `store/thread-mailbox-sqlite-v1/` contains durable peer messages, delivery state, idempotency receipts, activity cursors, and workspace overrides. Unlike the search and query caches, these records are authoritative and must not be deleted to trigger a rebuild. `authority.json` selects `mailbox-<migrationId>.sqlite`; keep the adjacent `-wal` and `-shm` files while it is open. Use [`kiki storage backup`](../reference/command.md#kiki-storage) for a consistent SQLite copy instead of copying only a live `.sqlite` file.
112
+
113
+ The 0.5.x upgrade retains its checkpoint in `migration.json`, its source backup under `recovery/<migrationId>/sources/`, and moved originals under `recovery/<migrationId>/originals/`. The former `store/thread-mailbox-v3`, `store/thread-mailbox-v1`, and `store/agent-collaboration-mailbox-v2` directory names become fence files. Keep these files: they stop older versions from reopening those locations as writable mailboxes. Do not point an old binary at the recovery copies. Run `kiki storage status` to inspect recovery state and `kiki storage migrate` to resume; follow the [storage command's rollback rules](../reference/command.md#kiki-storage) rather than moving original directories back by hand.
114
+
115
+ ## Session and usage query cache
116
+
117
+ `cache/query-store-sqlite-v1/index.sqlite` holds the SQLite query cache for session lists, usage facts, and thread-turn lookups. Kiki rebuilds these views from session metadata, usage-fact journals, and conversation history when needed. The database may have adjacent `-wal` and `-shm` files while it is open.
118
+
119
+ If this cache is damaged, stop every Kiki process using the data root, back up and remove only `cache/query-store-sqlite-v1/`, then restart. Rebuilding a large history can take several requests; Usage reports incomplete coverage until preparation finishes. Keep `cache/usage-facts-v1/`, `sessions/`, and `store/`: they contain the journals and records needed for recovery. The older `cache/query-store-v*/` directories are separate from the SQLite cache and are not imported by this backend.
120
+
121
+ ## Content search index
122
+
123
+ Content search uses SQLite at `search-index-v2/index.sqlite`. Kiki reuses a compatible index or rebuilds an older recognized search schema from session metadata and conversation history; results may be incomplete while rebuilding. This cache rebuild does not change the source history. The older MiniDb `search-index/` directory is left intact and is neither imported nor used as a fallback. Keep `sessions/` and `store/`: rebuilding a search cache does not replace the separate mailbox storage upgrade.
124
+
125
+ In the 0.5 migration series, an explicit `search_backend = "minidb"` in `config.toml` or `KIKI_SEARCH_BACKEND=minidb` is a deprecated alias for SQLite and produces a migration warning. Remove the old setting, or change it to `sqlite`, before upgrading to 0.6, which retires that value. Environment selection takes precedence over `search_backend`; Kiki does not rewrite either setting. The old `search_worker` experimental switch has been removed because SQLite always isolates database work in its writer process and query worker.
126
+
127
+ Search is available by default. `[search] enabled = false`, `KIKI_SEARCH_DISABLED=1`, or an explicit desktop `desktop_search = false` keeps it off; the migration alias does not start a worker or rebuild the cache when search is disabled. Set `[search] index_subagents = true` to include subagent content; it is off by default. These settings take effect after restarting Kiki. Search matches user and assistant text and session titles by default; tool-result output is included only when explicitly requested. Thinking, tool names, and tool-call arguments stay excluded.
128
+
107
129
  ## Built-in tool cache
108
130
 
109
131
  The first time the `Grep` tool needs ripgrep, the CLI can automatically download `rg` and cache it at `bin/rg` (`bin/rg.exe` on Windows). File-reference completion in the terminal UI uses `fd`; the CLI downloads and caches it at `bin/fd` (`bin/fd.exe` on Windows) in the background when needed. Subsequent runs reuse the cached binaries. `rg` prefers the system `PATH` before the cache, while `fd` checks the managed cache before falling back to system `fd` / `fdfind`. Deleting the `bin/` directory triggers a fresh download on the next use.
@@ -4,12 +4,10 @@ Kiki uses environment variables to control a small number of runtime behaviors
4
4
 
5
5
  Kiki-owned runtime controls use the `KIKI_*` prefix. Provider credential key names such as `KIMI_API_KEY` and `KIMI_BASE_URL` remain upstream-facing and are documented separately. Treat the exact names listed on this page as authoritative.
6
6
 
7
- ::: warning Important: API keys are not configured here
8
- Credential variables such as `KIMI_API_KEY`, `ANTHROPIC_API_KEY`, and `OPENAI_API_KEY` are **not** read automatically from shell environment variables. Running `export KIMI_API_KEY=xxx` in the terminal does not give any provider its key — they must be written in the config files under `[providers.<name>]` or its `[providers.<name>.env]` sub-table. API keys live in the companion `credentials.toml`; `config.toml` never carries a plaintext credential.
9
-
10
- The only exception is the `KIKI_MODEL_*` family, which is an explicit channel that *does* read credentials from the shell — see [Define a model from environment variables](#define-a-model-from-environment-variables-kiki-model).
7
+ ::: warning
8
+ Provider API key variables are **not** read automatically. To use one, set `api_key_env = "YOUR_PROVIDER_KEY"` in the provider's `config.toml` table and supply that variable to the Kiki process. See [credential priority and example](./overrides.md#provider-credentials). Stored key values remain in `credentials.toml`; the environment reference stores only the variable name.
11
9
 
12
- For background, see [Config overrides: provider credentials](./overrides.md#provider-credentials).
10
+ The separate `KIKI_MODEL_*` family can supply a temporary model and key — see [Define a model from environment variables](#define-a-model-from-environment-variables-kiki-model).
13
11
  :::
14
12
 
15
13
  ## Core paths
@@ -36,7 +34,7 @@ Switch models temporarily without modifying `config.toml` — when `KIKI_MODEL_N
36
34
 
37
35
  ## Provider credential key names
38
36
 
39
- The key names below are not read from the shell. They are keys written inside the `[providers.<name>.env]` sub-table, used as fallback values for `api_key` / `base_url`. Secret keys go in the companion `credentials.toml`; the non-secret `*_BASE_URL` keys stay in `config.toml`.
37
+ The names below are the conventional keys for the `[providers.<name>.env]` sub-table, used as fallback values for `api_key` / `base_url`. Secret keys go in the companion `credentials.toml`; the non-secret `*_BASE_URL` keys stay in `config.toml`. To read an API key from the process instead, explicitly reference its variable name with [`api_key_env`](./overrides.md#provider-credentials).
40
38
 
41
39
  ```toml
42
40
  # ~/.kiki/credentials/credentials.toml
@@ -68,7 +66,7 @@ Key names per provider:
68
66
  | `GOOGLE_CLOUD_LOCATION` | Vertex AI, together with `GOOGLE_CLOUD_PROJECT` | None |
69
67
 
70
68
  ::: warning
71
- `GOOGLE_APPLICATION_CREDENTIALS` (path to a service account JSON file) is the only exception that goes through the system environment variable mechanism — it is read by the Google SDK directly via the standard ADC flow, and the CLI does not participate. All other key names must be placed in the `[providers.<name>.env]` sub-table to take effect — the secret ones in `credentials.toml`, the `*_BASE_URL` ones in `config.toml`.
69
+ `GOOGLE_APPLICATION_CREDENTIALS` (path to a service account JSON file) is read directly by the Google SDK through the standard ADC flow. Project, location, and base URL values still come from the provider's config sub-table; `api_key_env` opts in only the named API key, not other shell variables.
72
70
  :::
73
71
 
74
72
  For the full provider type and field reference, see [Providers and models](./providers.md).
@@ -146,7 +144,7 @@ Switches that control the behavior of subsystems such as background tasks, the b
146
144
  | `KIKI_MCP_TOOL_TIMEOUT_MS` | Global default single tool-call timeout (ms) for all MCP servers; takes higher priority than `[mcp] tool_timeout_ms` in `config.toml`, but a per-server `toolTimeoutMs` in `mcp.json` still wins (default `60000`) | Integer from `1` to `2147483647`; invalid values are ignored |
147
145
  | `KIKI_LOOP_MAX_STEPS_PER_TURN` | Maximum Agent steps per turn; takes higher priority than `[loop_control] max_steps_per_turn` in `config.toml` (unset or `0` means unlimited) | Non-negative integer; invalid values are ignored |
148
146
  | `KIKI_LOOP_MAX_ATTEMPTS_PER_STEP` | Maximum total attempts for a failing step (including the initial attempt); takes higher priority than `[loop_control] max_attempts_per_step` in `config.toml` (default `5`) | Non-negative integer; invalid values are ignored |
149
- | `KIKI_INFINITE_RETRY` | Retry every failed LLM request indefinitely — turn steps and background operations such as compaction alike — instead of failing the task; waits use exponential backoff (capped at 32 s) and honor the server's `Retry-After` header, and aborting still cancels immediately. Intended for long-running unattended evaluations against endpoints that may fail temporarily | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
147
+ | `KIKI_INFINITE_RETRY` | Retry failed LLM requests indefinitely, including turn steps, compaction, HTTP 400/404, and quota errors. Waits use exponential backoff (capped at 32 s) and honor `Retry-After`. Does not override cancellation, local admission denials, observed output or tool execution, `retry = false`, or per-request `retry: 'never'`; the one-use [`Continue.` request](./config-files.md#loop-control) is never retried. Context overflow still uses context recovery. Intended for unattended evaluations against temporarily failing endpoints | Truthy: `1`/`true`/`yes`/`on`; falsy: `0`/`false`/`no`/`off` |
150
148
  | `KIKI_TOKEN_COUNTING_STRATEGY` | Which context token count is reported externally (the context-size display); takes higher priority than `[token_counting] strategy` in `config.toml` (default `measured+estimated`) | `measured+estimated`, `measured`, `estimated` (case-insensitive); invalid values are ignored |
151
149
  | `NB_SEARCH_CONFIG` | Path to a canonical JSON configuration for the built-in search and retrieval module, loaded before Kiki's `[nb_search]` patch | File path |
152
150
  | `NB_SEARCH_HOME` | Data directory for the built-in search and retrieval module | Directory path |
@@ -25,7 +25,7 @@ For ordinary runtime parameters such as model alias, Plan mode, yolo mode, and S
25
25
  A small number of environment variables explicitly override specific config file fields — for example, `KIKI_BACKGROUND_KEEP_ALIVE_ON_EXIT` has higher priority than `[background].keep_alive_on_exit`. These exceptions are noted in [Environment variables](./env-vars.md) and in the relevant field descriptions in [Configuration files](./config-files.md).
26
26
 
27
27
  ::: warning
28
- **Ordinary runtime parameters do not fall back to shell environment variables.** Provider `api_key` / `base_url` are read only from the config files — secrets from `credentials.toml`, everything else from `config.toml` — and do not fall back to `export`-ed shell variables. The only exception is the explicit `KIKI_MODEL_*` channel — see [Define a model from environment variables](./env-vars.md#define-a-model-from-environment-variables-kiki-model).
28
+ **Ordinary runtime parameters do not fall back to shell environment variables.** A provider reads a shell credential only when you explicitly name it with `api_key_env`, as described below. The separate `KIKI_MODEL_*` channel can also supply a temporary model and key — see [Define a model from environment variables](./env-vars.md#define-a-model-from-environment-variables-kiki-model).
29
29
  :::
30
30
 
31
31
  The CLI reads user-level configuration from `KIKI_HOME` (default `~/.kiki`) and project-local settings from `<project-root>/.kiki/local.toml`. The legacy `.kimi-code/local.toml` path is not read. To isolate config between different projects, point `KIKI_HOME` at different data directories — see [Common scenarios](#common-scenarios) below.
@@ -36,15 +36,26 @@ Provider credentials (`api_key`, `base_url`) follow their own resolution rules,
36
36
 
37
37
  Provider API keys are stored in `credentials/credentials.toml` under the data root. Kiki reads the two files as one document, and on a shared TOML path the value in `credentials.toml` wins; `config.toml` never holds a plaintext credential. See [Provider credentials](./config-files.md#provider-credentials) for the file, its permissions, and the first-load migration.
38
38
 
39
- For a single provider, credentials are resolved in this order:
39
+ A model's own API key or OAuth reference takes priority over its provider's credential. For an API-key provider, the remaining order is:
40
40
 
41
- 1. `[providers.<name>].api_key` — the key stored in `credentials.toml`; highest priority
42
- 2. The matching key inside the `[providers.<name>.env]` sub-table (`KIMI_API_KEY`, `ANTHROPIC_API_KEY`, etc.) — consulted only when `api_key` is empty; these secret values live in `credentials.toml` too
43
- 3. If both are absent — startup fails with an error indicating the provider is missing credentials
41
+ 1. `[providers.<name>].api_key` — the stored key; a non-empty value wins over environment sources.
42
+ 2. If `api_key_env` is set, read that variable from `[providers.<name>.env]` when the same name is present there; otherwise read it from the Kiki process environment. An explicitly empty sub-table value does not fall back to the process. A missing or blank variable leaves the API key unconfigured and does not try a different variable.
43
+ 3. If `api_key_env` is not set, use the provider type's existing key in `[providers.<name>.env]` (`KIMI_API_KEY`, `ANTHROPIC_API_KEY`, etc.). These stored secret values live in `credentials.toml` too; there is no implicit shell fallback.
44
44
 
45
- `base_url` is resolved the same way: first `[providers.<name>].base_url`, then the `*_BASE_URL` key in `[providers.<name>.env]`. `base_url` is not a secret, so it stays in `config.toml`.
45
+ To keep the key in the environment, store only its name in `config.toml`:
46
46
 
47
- > The `[providers.<name>.env]` sub-table is just a TOML section in the config files — it does not write anything into the shell environment. It is only consulted when the corresponding direct field (`api_key` / `base_url`) is empty.
47
+ ```toml
48
+ [providers.gateway]
49
+ type = "openai"
50
+ base_url = "https://api.example.com/v1"
51
+ api_key_env = "YOUR_PROVIDER_KEY"
52
+ ```
53
+
54
+ Start Kiki from a process that has `YOUR_PROVIDER_KEY` set. A desktop app launched from a shortcut may not inherit variables from your terminal. To switch an existing provider from a stored key, clear its `api_key`; otherwise the stored key still wins. Kiki does not copy the resolved environment value into its credential store. Provider readiness, model requests, and model discovery use the same resolution rule; readiness means a value is available, not that the remote service has accepted it.
55
+
56
+ A provider's OAuth reference still uses its existing token flow. As with a stored key, a resolved environment key cannot be combined with OAuth at that same provider layer.
57
+
58
+ `base_url` is unchanged: first `[providers.<name>].base_url`, then the `*_BASE_URL` key in `[providers.<name>.env]`. It is not a secret, so it stays in `config.toml`. The `env` sub-table does not write values into the shell environment.
48
59
 
49
60
  For the full list of credential key names, see [Environment variables: provider credential key names](./env-vars.md#provider-credential-key-names).
50
61
 
@@ -107,7 +118,7 @@ Every surface accepts `files` and `fields`. Files load from the Kiki home direct
107
118
  KIKI_HOME="$PWD/.kiki-sandbox" kiki
108
119
  ```
109
120
 
110
- **One-off test key** — since provider credentials are read only from the config files, write a test key into `credentials.toml`:
121
+ **Test key saved in a config file** — write it into `credentials.toml`. For an environment-only key, use the `api_key_env` example above:
111
122
 
112
123
  ```toml
113
124
  # ~/.kiki/credentials/credentials.toml
@@ -17,7 +17,7 @@ The `type` field in the `providers` table sets the default request format (the A
17
17
 
18
18
  All providers communicate with models in streaming mode by default. Capabilities such as thinking, vision, and tool use are matched automatically by model name prefix — you typically do not need to declare them manually.
19
19
 
20
- **Credential priority**: `api_key` direct field > `[providers.<name>.env]` sub-table key > if both are absent, startup fails with an error. Both are read from the config files — `credentials.toml` overlays `config.toml` — and the CLI does not fall back to shell environment variables for credentials. See [Config overrides: provider credentials](./overrides.md#provider-credentials).
20
+ **Credential priority**: a model's own credential wins; otherwise Kiki uses the provider's `api_key`, then its explicitly configured `api_key_env` variable. Without `api_key_env`, the existing `[providers.<name>.env]` credential fallback remains unchanged. Shell variables are not read automatically. See [Config overrides: provider credentials](./overrides.md#provider-credentials) for the full priority and an environment-variable example.
21
21
 
22
22
  ### Model request format overrides
23
23
 
@@ -44,6 +44,71 @@ Replace the example endpoint and remote IDs with your service's values. Both mod
44
44
 
45
45
  The [model REST API](../server/rest-api.md#models-and-providers) reports the saved `protocol` separately from `effective_protocol`, the resolved request format. Saving a format does not test connectivity.
46
46
 
47
+ ## Request compression
48
+
49
+ Request compression stays off until you configure it. `[request_compression]` applies to every provider that does not set its own table. A provider table replaces individual fields and inherits the rest: an omitted `targets` list, `min_bytes`, or `dictionary` stays as the system set it. `targets`, when set, replaces the system list in order; Kiki does not add the two lists together. Leave the provider key unset to inherit. `encoding = "off"` on a provider turns compression off for that provider even when the system table turns it on. With no system table, only providers that already set `request_compression` compress.
50
+
51
+ ```toml
52
+ [request_compression]
53
+ encoding = "zstd"
54
+ targets = ["https://example.com/v1"]
55
+ min_bytes = 1024
56
+ dictionary = true
57
+
58
+ [providers.gateway.request_compression]
59
+ min_bytes = 0
60
+ ```
61
+
62
+ The provider above keeps zstd, the same targets, and dictionary consent, and changes only the size threshold. Omit `dictionary` to keep the system choice. `dictionary = false` refuses retention for that provider. `dictionary` applies only to zstd. Saving either table applies on the next model request; a request already in flight keeps the settings it started with. `POST /api/config` writes the system table. `GET /api/providers` returns a provider table as saved, including a partial table, `encoding` set to `"off"`, and the original `targets` order.
63
+
64
+ For a gateway that explicitly supports compressed request bodies, this applies to Responses, Messages, and Chat Completions; other protocols keep their existing transport. A saved target does not skip the gateway's own compression support.
65
+
66
+ ```toml
67
+ [providers.gateway.request_compression]
68
+ encoding = "gzip"
69
+ targets = ["https://example.com/v1"]
70
+ min_bytes = 1024
71
+ ```
72
+
73
+ `targets` lists supported HTTP(S) API base URLs. A request must match the origin and path boundary; changing a model to another endpoint does not enable compression there. `min_bytes` counts UTF-8 body bytes and defaults to 1024. Empty, smaller, streaming, already encoded, and non-JSON bodies are left unchanged. Kiki uses the compressed body only when it is smaller. Remove the provider table to inherit again, or set `encoding = "off"` to disable compression for that provider. Remove the system table to leave every unset provider uncompressed.
74
+
75
+ To use ordinary zstd instead, set `encoding = "zstd"`. Neither gzip nor ordinary zstd asks the gateway to retain request bodies. If the gateway also implements the Portway request-dictionary extension, you may explicitly consent to temporary body retention:
76
+
77
+ ```toml
78
+ [providers.gateway.request_compression]
79
+ encoding = "zstd"
80
+ targets = ["https://example.com/v1"]
81
+ dictionary = true
82
+ ```
83
+
84
+ `dictionary = true` asks the gateway to cache exact request bytes, which can include messages, media, tool results, and signatures. Kiki keeps acknowledged dictionaries only in bounded process memory, for up to ten minutes. A dictionary acknowledgement confirms cached bytes, not completed model generation. Every request is still built from the full local history; a changed or compacted history is never reconstructed from guessed model output.
85
+
86
+ Only a marked, pre-execution decoding rejection permits an encoding fallback, with at most three attempts. Transport failures and temporary provider errors before any output use the existing [request retry policy](./config-files.md#retry), even when delivery is uncertain. Partial output or observed tool execution prevents resending that generation; completed tool results remain in local history. If a target does not support compression, disable it before starting a new request rather than relying on automatic format probing.
87
+
88
+ ## Incremental Responses over WebSocket
89
+
90
+ Responses WebSocket stays off until you configure it. `[responses_web_socket]` applies to every provider that does not set its own table. A provider table replaces that value as a whole. `targets`, when set on the provider, replaces the system list in order and is not added to it. Omit the provider key to inherit. `off = true` keeps that provider on ordinary HTTP even when the system table lists targets. With no system table, only providers that set `responses_web_socket` open a socket. Saving either table applies on the next model request. An idle socket closes immediately; a socket serving an in-flight request stays open until that request completes, fails, or is canceled, then the next request uses a new connection.
91
+
92
+ For a gateway that advertises the version 1 `X-Responses-WebSocket-Capabilities` handshake, opt in to connection-local Responses history:
93
+
94
+ ```toml
95
+ [responses_web_socket]
96
+ targets = ["https://example.com/v1"]
97
+
98
+ [providers.gateway]
99
+ type = "openai_responses"
100
+ base_url = "https://example.com/v1"
101
+
102
+ [providers.other.responses_web_socket]
103
+ off = true
104
+ ```
105
+
106
+ The target must match the origin and path boundary of the Responses endpoint. A saved target does not skip the handshake. Kiki uses the official OpenAI SDK, keeps one socket per Agent, and sends only new input when the previous completed response still matches the local history. Helper requests, other Agents, and forks do not share that history. Canceling a request closes its socket; model, credentials, policy, and context changes reset the connection or send a full request. Remove the provider table to inherit again, or set `off = true` to keep ordinary HTTP for that provider. Remove the system table to leave every unset provider on ordinary HTTP.
107
+
108
+ The gateway temporarily retains native request and response items on the connection. Unlike HTTP request dictionaries, this state follows completed generation, not dictionary acknowledgements. Unknown output fields are retained in an in-memory sidecar and sent in full rather than used for an incremental request.
109
+
110
+ If the gateway explicitly reports missing history before execution, Kiki sends the full current history once. A pre-execution unsupported upstream format or prompt policy can fall back to a full HTTP request. The transport does not use this fallback for access denials or partial responses. A connection loss or temporary provider failure with no observed output uses the same request retry policy as HTTP; uncertain delivery alone does not block that recovery. This path supports `response.create` generation only; it does not enable background generation, steering, or `generate:false` warmup.
111
+
47
112
  ## `/provider` — interactive provider management
48
113
 
49
114
  Prefer not to edit TOML by hand? Type `/provider` in the TUI to open the **provider manager**, where you can interactively add or remove providers.
@@ -61,7 +126,9 @@ Two paths when adding:
61
126
 
62
127
  ### Fetching model suggestions
63
128
 
64
- In GUI **Settings → Models & providers**, click **Get models** to fetch suggestions from configured providers. API-key providers and custom registries are fetched only on request, not at startup or on a timer. Fetching does not change your providers, configured models, or default model. Choose a suggestion and save it separately to add a model; an upstream removal does not delete an existing model.
129
+ In GUI **Settings → Models & providers**, click **Get models** to fetch suggestions from configured providers. API-key providers and custom registries are fetched only on request, not at startup or on a timer. Fetching these suggestions does not change your providers, configured models, or default model. Choose a suggestion and save it separately to add a model; an upstream removal does not delete an existing model.
130
+
131
+ Kimi Code account sign-in maintains its managed catalog separately. When that catalog refreshes and no global default is set, Kiki selects a managed model even if the catalog itself has not changed. An unchanged catalog preserves explicit defaults, including a choice made while the refresh was in progress.
65
132
 
66
133
  Suggestions are kept in server memory and disappear when the server restarts. Changing or deleting a provider connection discards its cached suggestions. A failed fetch shows an error while retaining the last successful suggestions; a successful empty response clears them. Models already configured for that provider are excluded even if their local aliases differ from the upstream model IDs.
67
134
 
@@ -83,7 +150,11 @@ For connecting to Moonshot AI's OpenAI-compatible interface, including the Kimi
83
150
 
84
151
  - Default `base_url`: `https://api.moonshot.ai/v1`
85
152
  - Credential key names: `KIMI_API_KEY`, `KIMI_BASE_URL` — these are entries of the `[providers.<name>.env]` sub-table, not shell environment variables
86
- - Additional capability: supports video upload
153
+ - Additional capabilities: video upload and stored image attachment references
154
+
155
+ For `type = "kimi"` models using Chat Completions or Messages on the official endpoints listed in this section, Kiki uploads stored image attachments with the current provider credentials and sends a file reference. Local originals remain unchanged. Remote copies follow the provider's retention policy; closing or deleting the local session does not delete them. Each cached reference is checked with the current credentials before reuse, and a deleted or expired file is uploaded again. Cache entries are isolated by endpoint, protocol, provider, and credentials. Other endpoints and inline image inputs keep their existing inline transport. A temporary upload failure uses the image inline; authentication failures use the existing sign-in recovery.
156
+
157
+ Kiki keeps the attachment size limits enforced by the composer and does not discard older media to meet an additional 20 MiB provider request budget.
87
158
 
88
159
  Kimi Code subscription keys pair with the managed base URL `https://api.kimi.com/coding/v1` (configured automatically by `/login`). Open-platform keys pair with the endpoint of the portal that issued the key: `https://api.moonshot.cn/v1` for keys from [platform.kimi.com](https://platform.kimi.com), or the default `https://api.moonshot.ai/v1` for keys from [platform.kimi.ai](https://platform.kimi.ai).
89
160
 
@@ -134,7 +205,7 @@ api_key = "sk-ant-xxxxx"
134
205
 
135
206
  For connecting to the OpenAI Chat Completions protocol, as well as any third-party service compatible with that protocol (override `base_url` as needed).
136
207
 
137
- Third-party reasoning models (DeepSeek, Qwen, One API, etc.) work out of the box: the CLI automatically handles the `reasoning_content` field and `reasoning_effort` injection. If your gateway returns reasoning content under a non-standard field name, set `reasoning_key` on the model alias to override.
208
+ Third-party reasoning models (DeepSeek, Qwen, One API, etc.) work out of the box: the CLI automatically handles the `reasoning_content` field and `reasoning_effort` injection. OpenAI-compatible Chat connections also retain structured `reasoning_details`, including encrypted records, when restoring conversations and sending subsequent requests. Summaries are shown only when no nonempty string reasoning is returned; encrypted records stay out of the transcript. If your gateway returns reasoning content under a non-standard field name, set `reasoning_key` on the model alias to override.
138
209
 
139
210
  For both `openai` and `openai_responses`, Kiki does not send an output-length limit of its own when you have not set one and the model's capability is unknown — the request carries no `max_tokens`, `max_completion_tokens` or `max_output_tokens`, and the server's own default applies. A limit you set yourself, a known model output capability, a tighter session or profile limit, and a remaining-window budget are all still honored; the context window size on its own is not treated as an output limit. That maximum is a ceiling, not a promise about answer length — what the model returns still depends on the task and on when it stops — and you are billed for the response you actually get.
140
211
 
@@ -74,6 +74,8 @@ Peer-thread communication lets a main agent coordinate other Kiki sessions on th
74
74
 
75
75
  A thread reference identifies a host, workspace and session. `ThreadList` returns the references later calls need, `ThreadRead` reads completed main-agent turns without resuming a cold session, `ThreadSend` derives the source from the current main-agent session, and `ThreadWait` waits up to 60 seconds for activity from up to eight threads. Messages cannot cross hosts.
76
76
 
77
+ During local history preparation, `ThreadRead` may return `turns: []` and `incomplete: "history_preparing"`; that state is not an empty thread. Continue with the returned `nextCursor` in the same scope. Large local input or output can also be previewed with `contentRefs`; use `content_ref` to continue its bounded segment read. [Collaboration Tools](../reference/tools.md#collaboration-tools) documents cursor compatibility, ordering, rewrite invalidation, and segment limits.
78
+
77
79
  A message is recorded as coming from a peer only when the source thread's own main agent calls `ThreadSend`. REST and the `global.threads` Klient facade take target-addressed input only and record it as external-client input, so an external client cannot claim a source thread or a direct human origin.
78
80
 
79
81
  Leave `[thread_communication] enabled` unset to allow the tools and keep the default off. Set `enabled = false` to turn them completely off. A conversation’s own on/off is in the right-hand capabilities list and applies on the next step. Sending can resume a cold target session and consume model quota. A workspace can persist a disable override, but it cannot turn the tools on after a hard off. See [Server API](../server/rest-api.md#session-leases-and-peer-threads) for those interfaces.
@@ -108,9 +110,11 @@ Agent files are watched and reloaded on change. An agent already running or resu
108
110
 
109
111
  ### Choosing the engine and its profile
110
112
 
111
- The control at the left of the composer's status line answers one question — what runs this session — in one panel. Kiki itself is the first entry; each external engine follows, and under each engine sit that engine's own main profiles. The first row of every engine is that harness **as it is**: no Kiki profile, no Kiki prompt, no injected tools, and the harness's own model, effort and approval mode. Picking a profile under an engine takes both at once, so the two halves can never disagree.
113
+ The **Profile** menu at the left of the composer's status line lets you choose Kiki, an external engine, or a named profile. Selecting a profile also selects its engine. For an external engine, its built-in passthrough entry runs the harness **as it is**: no Kiki profile, no Kiki prompt or injected tools, and the harness's own model, effort and approval mode.
114
+
115
+ On the **New session** page, the same menu also has a **Personas** group. Select a [persona](../features/people.md) there; its name and avatar appear in the composer.
112
116
 
113
- The panel also runs a profile straight from a Markdown file. Select the small file button in the search row: on a local desktop, Kiki opens the native file picker and previews the selected file before you choose **Use**; on an SSH, remote, browser or other host without a native path picker, enter the path and choose **Check file** instead. Relative paths resolve against the session's working directory or workspace, and a remote path is read on the host running the session rather than on your machine. A file that is not a main profile — `main: false`, or one that overrides a built-in — works the same way. Nothing is registered or imported: the file is not added to the profile catalog, no existing profile is replaced, and cancelling or closing the picker/form changes neither your draft nor the current selection. A file that cannot be read is refused in place, with the server's own reason.
117
+ The menu also runs a profile straight from a Markdown file. Choose **Use a profile file…**: on a local desktop, Kiki opens the native file picker and previews the selected file before you choose **Use this profile**; on an SSH, remote, browser or other host without a native path picker, enter the path and choose **Check file** instead. Relative paths resolve against the session's working directory or workspace, and a remote path is read on the host running the session rather than on your machine. A file that is not a main profile — `main: false`, or one that overrides a built-in — works the same way. Nothing is registered or imported: the file is not added to the profile catalog, no existing profile is replaced, and cancelling or closing the picker/form changes neither your draft nor the current selection. A file that cannot be read is refused in place, with the server's own reason.
114
118
 
115
119
  Picking a file takes its engine with it — a file declaring an external `executor` runs that engine — so one choice answers both halves. The file supplies what it declares: leave the model and approval controls alone and the file's choices apply, while changing one yourself wins for that message. A session that runs a file keeps running it; changing only the model on the next message carries the same file instead of falling back to the bare harness. **Rebuild context** reads the file again.
116
120
 
@@ -55,9 +55,43 @@ max_handoffs_per_hour = 30
55
55
  room_budget = 12
56
56
  ```
57
57
 
58
- A session's `delivery` is either `reply` or `message`. In message mode only successful `SendMessage` calls become delivered messages, and ordinary model text stays in the process view; if a user-triggered turn ends with text and no send, Kiki asks the model to reconsider **once**, which can cost one extra request. The shipped `agent` profile exposes `SendMessage` in message mode and omits it in reply mode, and a custom profile with an explicit `tools` allowlist must list it — delivery mode does not bypass profile permissions. The tool table is frozen for a turn, so a delivery change applies to the next one.
58
+ A session's `delivery` is either `reply` or `message`. New persona sessions use message mode when the persona omits `delivery`; an explicit session choice takes priority, and an existing session keeps its saved choice. Sessions without a persona, and personas with explicit `reply`, answer directly. The persona editor saves the delivery mode it shows, including an explicit `reply`.
59
59
 
60
- `SendMessage` addresses the user or another persona with `to: "@Name"`; use the persona ID when names collide. A handoff can wake a closed conversation and counts toward the hourly limit, though retrying the same delivery key does not consume another slot. Attachments are immutable copies from the session workspace, its additional directories or the persona's own area, not arbitrary filesystem paths.
60
+ In the message view, a completed turn's last complete ordinary reply also appears when that turn has no successful `SendMessage`. Long replies and sent messages load the rest of their text automatically. Failed turns keep a failure indicator; switch to the process view to read any unfinished prose. This display fallback does not send to a room, another persona, or an IM channel; those destinations still need an actual delivery.
61
+
62
+ When `SendMessage` confirms delivery to the user, its result tells the model to end the turn without another closing message if the request is complete and no work remains. Progress updates still allow required tools and pending work to continue. A native-executor turn that ends in ordinary text instead receives guidance in the next model request when the tool is available; it does not add a request to the completed turn or resend its answer.
63
+
64
+ The shipped `agent` profile exposes `SendMessage` in message mode and omits it in reply mode. A custom profile with an explicit `tools` allowlist must include it; delivery mode does not bypass profile permissions. The tool table is frozen for a turn, so a delivery change applies to the next one.
65
+
66
+ `SendMessage` addresses the user or another persona with `to: "@Name"`; use the persona ID when names collide. A handoff can wake a closed conversation and counts toward the hourly limit, though retrying the same delivery key does not consume another slot. Attachments are immutable copies from the session workspace, its additional directories or the persona's own area, not arbitrary filesystem paths. Set an attachment's `kind` to request `image`, `audio`, `voice`, or `video` delivery; omitting it preserves ordinary `file` delivery. A message can contain attachments without text:
67
+
68
+ ```json
69
+ {
70
+ "attachments": [
71
+ { "path": "output/voice.ogg", "kind": "voice", "mime_type": "audio/ogg" }
72
+ ]
73
+ }
74
+ ```
75
+
76
+ ## Connect conversation channels
77
+
78
+ A user-directed `SendMessage` uses the Kiki in-app channel, named `internal`, and the conversation's enabled IM bindings. The in-app channel stays on when an IM binding is added. HTTP clients can inspect the channels with `rest.imSessions.channelViews(sessionId)`.
79
+
80
+ Each attachment must be supported by at least one enabled channel. Otherwise the send fails with `media_unsupported`; with no enabled destination, it fails with `no_destination`. If only some channels support an attachment, Kiki sends it to those channels and tells the others which media were skipped. The receipt's `channels` list identifies each destination as `delivered`, `unsupported`, `failed`, or `unknown`; a delivered channel can also list skipped types in `unsupported`. Do not automatically resend an `unknown` outcome: the platform may already have accepted it.
81
+
82
+ Voice is an explicit intent, not permission to fall back to a file. The in-app channel plays audio and voice in its audio player. Discord, Slack, and Matrix accept ordinary `audio` but do not support outgoing native `voice`; Discord and Slack upload audio as attachments, while Matrix uses `m.audio`. Matrix connections support only unencrypted rooms and refuse plaintext sends into encrypted rooms.
83
+
84
+ HTTP clients configure these connections through `rest.imSessions.setupCatalog()` and `setup(...)`. The catalog supplies each platform's required fields and actual capabilities:
85
+
86
+ | Platform | Required fields | Setup route |
87
+ | --- | --- | --- |
88
+ | Discord | `bot_token` | `discord_install` builds a bot invitation from `application_id`; enable Message Content Intent in the developer portal. |
89
+ | Slack | `bot_token`, `app_token` | `slack_manifest` creates a Socket Mode app; OAuth can supply the bot token, but an app-level `xapp` token is still required. |
90
+ | Matrix | `homeserver`, `access_token` | `matrix_discover` reads login methods; `matrix_sso_begin` / `matrix_sso_complete` or `matrix_password` can obtain and save a token. |
91
+
92
+ Call `setup({ action: "save", provider_kind, fields })` to save credentials without starting a listener. Then use the returned `provider_instance_id` with `check` and `listen(id, true)`, send the bot a platform message, and confirm the resulting discovery against the intended session or persona. Existing Telegram, Feishu, OneBot, and WeChat connections keep their configuration and binding flow. The [REST API guide](../server/rest-api.md) covers connection authentication; the HTTP endpoints for these operations are `GET` / `POST /api/im/sessions/setup` and `GET /api/im/sessions/targets/{sessionId}/channels`.
93
+
94
+ After confirming a binding, call `rest.imSessions.testBinding(bindingId)` to send a fixed, clearly marked test message to that binding's chat without starting a model reply. It uses the existing connection and requires the binding to be enabled and connected. The HTTP equivalent is `POST /api/im/sessions/bindings/{bindingId}/test` with `{}`; custom text and targets are rejected. The result contains `binding_id`, `status`, `message_ids`, and an optional `detail`. A `delivered` result confirms platform acceptance, not that someone read the message; for `failed`, fix the reported cause before trying again. If the status is `unknown`, check the chat before manually retrying.
61
95
 
62
96
  ## Discuss in a room
63
97
 
@@ -80,7 +80,7 @@ You are approving the source, not the exact bytes: Kiki fingerprints the plugin
80
80
 
81
81
  Install one copy of a plugin, then choose where it is used. The GUI install preview offers global use, use in one workspace, or installation for later. Installing for later leaves it off by default and does not start its App background service. The same preview and one-time consent apply to every choice.
82
82
 
83
- In **Settings → Workspaces**, open a workspace to set its plugin defaults. In a conversation, the right rail's **Plugins** section controls only that session; selecting an installed plugin from the composer's **+** menu or plugin picker also enables it only for that session, without sending a message. Before your first message, those choices stay with the new-conversation draft and apply before that message starts; a failed application keeps the draft for retry. Other sessions and workspace defaults stay unchanged. This capability is available by default; an explicit `[experimental] plugin_workspace_usage = false` or `KIKI_EXPERIMENTAL_PLUGIN_WORKSPACE_USAGE=0` keeps the selection surface off.
83
+ In **Settings → Workspaces**, open a workspace to set its plugin defaults. In a conversation, open **Capability controls → Plugins** in the right rail to change plugin use for that session only; **Capability inventory → Tools** shows the plugin's tools rather than its usage switch. Selecting an installed plugin from the composer's **+** menu or plugin picker also enables it only for that session, without sending a message. Before your first message, those choices stay with the new-conversation draft and apply before that message starts; a failed application keeps the draft for retry. Other sessions and workspace defaults stay unchanged. This capability is available by default; an explicit `[experimental] plugin_workspace_usage = false` or `KIKI_EXPERIMENTAL_PLUGIN_WORKSPACE_USAGE=0` keeps the selection surface off.
84
84
 
85
85
  The most specific selection wins: session, then workspace, then global default. **Restore default** removes the local override. An explicitly globally disabled or invalid plugin cannot be enabled locally; restore its master switch in Plugin settings first. Profile tool restrictions still apply.
86
86
 
@@ -445,6 +445,46 @@ Supported fields:
445
445
 
446
446
  Unsupported runtime fields such as `tools`, `apps`, `inject`, and `configFile` appear as diagnostics and are ignored.
447
447
 
448
+ ### Chat channels and message delivery
449
+
450
+ Plugins can connect a platform account to Kiki's existing session bindings and send messages from an admitted tool call. Declare executable contributions in `x-kiki`, then register the same definitions from `entry.mjs`. The SDK contracts are exported from `@kiki/plugin-sdk/im` and `@kiki/plugin-sdk/messages`.
451
+
452
+ A plugin that uses another installed plugin declares its required version range, for example `"dependencies": { "kiki-media": "^1.0.0" }` inside `x-kiki`. Kiki checks that each dependency is installed, enabled and version-compatible before activation or execution. Install or enable a missing dependency yourself; Kiki does not do so automatically. Plugins without `dependencies` keep their existing behavior.
453
+
454
+ For chat connections, declare `x-kiki.imAdapters` and call `api.registerImAdapter(definition, adapter)`. Each definition represents one configured account and has `schemaVersion: 1`, a local `id`, `label`, independent `inbound` and `outbound` booleans, `maxInboundBytes`, and a `mediaCapabilities` array. Kiki assigns `plugin:<pluginId>/<adapterId>` as the provider and instance ID. Inbound definitions also require `listenerRealm`, the real protocol or message-source namespace. Use `qq-onebot` with the actual QQ self ID as `start()`'s `listenerAccountId`; QQ official API connections use `qq-official` with the app ID. `accountId` remains the plugin's stable binding identity and may keep an existing prefix. When `listenerAccountId` is omitted, Kiki uses `accountId` for listener ownership. An already-running listener retains a source/account claim; a conflicting new listener stops and reports `account_in_use`. Output-only connections do not claim inbound ownership.
455
+
456
+ `start({ signal, settings, instanceId, offset, messageLimits, emit })` returns `{ accountId, listenerAccountId?, targets? }`. Emit only after startup completes. Output-only adapters can return `targets` for the user to confirm without fabricating an inbound event. Disabling, reloading or removing the plugin closes its own connections and keeps the user's listening preference and bindings for later re-enabling. The user confirms each destination; group bindings default to the original sender and can explicitly use `binding_scope: "topic"` or `"chat"`. A shared group session preserves each message's real sender, and does not let another member answer the original sender's pending approval or question.
457
+
458
+ For one platform message containing text and several attachments, finish normalization and media downloads before calling `await emit({ kind: "message", eventId, sourceMessageId, identity, parts, ...metadata })` once. Put the real mention, quote and sender metadata on that envelope. Each ordered part has `kind: "text" | "image" | "file" | "audio" | "video"`, optional `text`, and hydrated `media: { name, mediaType, bytes }` when available. `sourceMessageId` is required and `operation` is omitted or `"create"`; edits and retractions use the existing single-event form. Kiki admits all parts before one prompt and keeps their order. Existing single-kind events keep their per-event behavior; Kiki does not guess when a series of them is complete.
459
+
460
+ Read the frozen `context.messageLimits` object supplied to `start()`; managed plugins need no runtime SDK import to obtain it. Its keys are `parts: 256`, `mediaBytes: 33554432`, `textChars: 1048576`, `serializedChars: 67108864`, and `chunkChars: 4194304`. A complete message has 1–256 parts, at most 32 MiB of decoded media in total, and at most 1,048,576 UTF-16 code units across all part text. `definition.maxInboundBytes` still limits **each attachment**, up to 8 MiB, so two 8 MiB images fit together. The serialized envelope, including base64, escaped text and metadata, is limited to 67,108,864 UTF-16 code units. The runner automatically frames it in 4,194,304-code-unit chunks; ordinary RPC lines retain their 16,777,216-code-unit limit. Do not implement framing in the plugin.
461
+
462
+ If an attachment is known to have no usable download URL, keep its non-text `kind` and put its name, reason and any available ASR transcript in nonempty `text`, without `media`. Kiki renders that part in place as explicitly unavailable external text and creates no media bytes for it. A real download failure or cancellation must emit nothing for that source message; retry the whole source with the same root `eventId`. Exceeding a message budget rejects `emit()` as a whole. A part marked `tooLarge: true` also rejects the entire `emit()` without submitting or saving an earlier prefix. Stop or unload discards incomplete transport frames and rejects queued emissions from the retired connection.
463
+
464
+ Keep `eventId` for event deduplication and send the platform's real message ID separately as `sourceMessageId`. Inbound `mentioned`, `mentionIds`, `replyToMessageId`, optional `isSelf` and epoch-millisecond `timestamp` reach the session's message metadata. Emit `operation: "edit"` or `"retract"` with the real target `sourceMessageId`; these update the received history without starting another model turn. Do not infer self identity from a display name. The model receives real sender facts and selected background beside the current body, marked as untrusted external data rather than instructions or authorization. Outbound text carries `replyToMessageId` for a quote, `messageId` for an edit, and `mentionIds` for platform mentions. Declare `supportsReply`, `supportsEdit` and `supportsMentions` only when implemented; unsupported requests return a channel receipt instead of silently dropping those fields. Platform passive-reply tokens stay inside the adapter.
465
+
466
+ New explicit topic/chat group bindings retain ordinary messages quietly and wake on a real mention or reply to a known self message. The user can choose a literal prefix, every-message wake, or record-only mode through [`group_policy`](../server/rest-api.md#im-account-and-channel-bindings). Older sender-scoped bindings keep their every-message behavior. Mention/reply wake requires real adapter metadata; built-in transports that do not expose it can use a configured prefix or `wake: "always"`. [ReadMessageHistory](../reference/tools.md#im-chat-history) reads the retained journal through the current session's admitted binding.
467
+
468
+ For optional platform backfill, declare `supportsHistory: true` and implement `readHistory({ chatId, topicId, cursor?, limit }, context)`. `limit` is 1–50; the cursor is an opaque adapter token. Return `{ status: "unsupported", detail? }` or `{ status: "ok", messages, order, nextCursor?, coverage, end }`. Each message has its real `sourceMessageId`, `identity` and media/text `kind`, with optional `text`, `operation`, `isSelf`, `timestamp`, mention/reply fields and up to four path-free media descriptors `{ kind, name, mediaType }`. `order` is `chronological` or `reverse_chronological`; `coverage` is `complete`, `partial` or `unknown`; `end` is `reached`, `more` or `unknown`. A short or empty page does not establish an end. Kiki validates every returned chat/topic and the requested limit. Platform reads require an enabled inbound connection and an explicit chat/topic binding; unsupported adapters keep working without a history method.
469
+
470
+ Inside a plugin tool, `context.messages.send()` follows the same main-agent, capability, tool-deny and approval checks as `SendMessage`, then uses the thread's enabled bound outputs. For example:
471
+
472
+ ```js
473
+ const receipt = await context.messages.send({
474
+ request_id: "report-1",
475
+ messages: [
476
+ { text: "First message\nwith a line break" },
477
+ { text: "Second message", attachments: [{ file_id: artifact.file_id, kind: "voice" }] }
478
+ ]
479
+ });
480
+ ```
481
+
482
+ Pass a completed `context.media.generate()` artifact's `file_id` to send generated output already stored in this session. An admitted tool can compose a pure TTS request from its own text and voice arguments without declaring `mediaInputs`. A tool declaring `mediaInputs: true` must keep the exact admitted request in `args.request`; image and video requests still require that admission. Ordinary attachment `path` inputs still require a workspace, additional-directory or Bot-directory path; generated files elsewhere in the home directory do not become generally readable.
483
+
484
+ Use either single-message `text`/`attachments`/`reply_to`/`mention_ids` or an explicit `messages` array, never both. A newline stays inside one message. Outer `to`, `channel` and `channels` select destinations for every item. Batch results contain ordered `messages` receipts with stable `index`, `message_id`, channel outcomes and attachment references; cancellation stops unlaunched items. An explicit `request_id` is scoped to the plugin, session and agent across tool calls and restarts: the same payload reuses its receipt, and changed content conflicts. An interrupted admitted request remains unknown and is not sent again; use a new ID only after checking its delivery. Without an ID, deduplication is local to that tool call's send sequence.
485
+
486
+ `minSendIntervalMs` sets the Host's per-target sending interval. Adapters may report `{ status: "failed", errorKind: "rate_limited", retryAfterMs }` only when the platform explicitly rejected the send without accepting it. Kiki retries that result at most twice; delivered results with no message IDs, partial deliveries and unknown outcomes are not retried. Built-in channels also use the Host's target pacing; a platform rate limit without an exact retry delay remains a failed receipt.
487
+
448
488
  ### Native tool results
449
489
 
450
490
  Native tools declared under `x-kiki.tools` can return text and PNG, JPEG or WebP images as base64 data URLs. Large results are saved automatically as session attachments: text keeps a preview with the complete original's path and `kimi-file://` reference, and images remain available through the session attachment reference. Ask the agent to use `Read` to page through the original text or `ReadMediaFile` to inspect the original image. Plugin authors can keep the usual return format; they do not need to split the result themselves.
@@ -8,6 +8,10 @@ Prompt field overrides replace named pieces of the built-in prompt — system se
8
8
 
9
9
  Useful built-in field ids include `system.language`, `system.reply_style`, `system.coding`, `system.shared`, `tool.web-search.description`, `tool.web-search.guidance`, `delegation.sub.notice` and `delegation.independent.notice`. System fields replace sections of the built-in prompt, except `system.shared`, which is the one shared outer addition and is appended once when non-empty. A tool `description` replaces its static description; a tool `guidance` is appended under the existing `User-configured guidance:` label.
10
10
 
11
+ Kiki's built-in collaboration guidance works without a Recipe. It asks agents to give one owner a complete outcome, inspect and incorporate returned work before accepting it, and send the inputs a recipient still needs for its next action. It does not impose a message quota on user-requested discussion. Reply language follows the user or task brief, including an explicit reply-language requirement; internal steering, reminders and quoted documents do not by themselves switch it. Customize this guidance through `system.delegation_brief_hygiene`, `delegation.sub.notice`, or the `description` and `guidance` fields for `tool.agent-run`, `tool.agent-send` and `tool.thread-send`.
12
+
13
+ These defaults keep existing profile and Recipe overrides, delegation-notice off choices, and role and tool limits intact. A custom replacement profile still controls its own body. External executors receive the text through their selected profile or configured `executor_prompt` composition; [direct external execution](./agents-and-subagents.md#direct-external-execution) without those additions stays bare.
14
+
11
15
  ## Where overrides live
12
16
 
13
17
  Every override surface uses the same format — optional `files` (strict TOML files relative to the Kiki home) and inline `fields`: