warming.mdx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ---
  2. title: "Session warming"
  3. description: "Keep recently active model sessions warm with periodic transient requests."
  4. ---
  5. Session warming sends periodic model requests for recently active sessions.
  6. This can preserve provider-side prompt caches or other short-lived session
  7. state while you pause between prompts.
  8. Warming is disabled by default. Enable it with the default settings in any
  9. [OpenCode configuration file](/config):
  10. ```jsonc title="opencode.jsonc"
  11. {
  12. "$schema": "https://opencode.ai/config.json",
  13. "warming": true
  14. }
  15. ```
  16. With the defaults, OpenCode sends a warming request after a session has made no
  17. model request for four minutes. It repeats this while the session remains idle,
  18. but stops 30 minutes after the last non-warming request. New model activity
  19. starts a new 30-minute window.
  20. ## Configuration
  21. Use the object form to customize the prompt, idle interval, or active duration:
  22. ```jsonc title="opencode.jsonc"
  23. {
  24. "$schema": "https://opencode.ai/config.json",
  25. "warming": {
  26. "prompt": "Do not perform any work. Reply with exactly: OK",
  27. "interval": "4 minutes",
  28. "duration": "30 minutes"
  29. }
  30. }
  31. ```
  32. | Field | Default | Description |
  33. | --- | --- | --- |
  34. | `prompt` | Keep-alive instruction | Prompt sent in each warming request. The default instructs the model to do no work and reply with `OK`. |
  35. | `interval` | `"4 minutes"` | Idle time between warming requests. |
  36. | `duration` | `"30 minutes"` | Maximum warming window after the latest non-warming model request. |
  37. `interval` and `duration` accept duration strings such as `"30 seconds"`,
  38. `"4 minutes"`, or `"1 hour"`. Both must be finite and greater than zero.
  39. To disable warming explicitly:
  40. ```jsonc
  41. {
  42. "warming": false
  43. }
  44. ```
  45. ## Request behavior
  46. A warming request uses the session's current model, agent, instructions, and
  47. conversation context. Tools are disabled. The configured prompt is appended as
  48. a transient user message, and the response is discarded.
  49. Warming does not admit input, add messages to session history, or otherwise
  50. mutate durable session state. A warming request resets the idle interval but
  51. does not extend the active duration; without new model activity, warming still
  52. ends when the configured duration expires.
  53. ## Costs and limits
  54. Warming requests are real provider requests. They can consume tokens, incur
  55. costs, count against rate limits, and fail for the same reasons as other model
  56. requests. OpenCode logs warming failures without failing or changing the
  57. session, then waits for the next interval before trying again.
  58. Enable warming only when the provider-side benefit is worth the additional
  59. requests. A shorter interval or longer duration increases request volume.