kdeps-commands-fold
v2.0.0kdeps command: fold
set commands / shelf agent
PurposeShow fold status: auto on/off, threshold, items, last fold, tokens since
LLM context: none - kdeps uses it without sending it to the model
Where it runs
Part of the commands set, used in workflow and agent mode. Slash commands: the help and completion of the built-in ones, and declared commands that run other commands and prompts.
- you type /name in kdeps
- the command runs: built in, or its declared stepscommands/fold
- prompts go to the model; the output is shown
Loaded by: kdeps (agent loop), /update, kdeps run
In the code: kdeps (agent loop)agent.(*REPL).Runagent.declaredCommand
Install
A kdeps asset: installed with the first-run profile that includes its set, or the first time a command needs it, and updated without a new release.
Also installs what it requires, when missing or older: tools/session_ops.
Pin a version with kdeps install commands/fold@<version>.
Contents
- order
- 80
/foldShow fold status: auto on/off, threshold, items, last fold, tokens since/fold nowFold now, whatever the threshold/fold auto [on|off]Automatic folding: a lighter, checkpoint-only summarize+archive (default on)/fold threshold <n|default>Tokens since the last checkpoint that trigger a fold (e.g. 2000, 2k)/fold items <n|default>Checkpoints kept in the memory prompt/fold preset <tight|balanced|loose>Set threshold and items together/fold- 1
Calls a kdeps API tool
session_opsoperation: get key: foldprints
**Fold** auto: {{.value}} threshold: {{.threshold}} tokens context items: {{.items}} last fold: {{.last}} accumulated since: {{.accumulated}} / {{.threshold}} tokens
/fold now- 1
Calls a kdeps API tool
session_opsoperation: compactprints
{{if .summary}}**Fold summary:** {{.summary}}{{else}}Nothing to fold yet: the session has {{.turns}} turn(s); the last {{.keep}} always stay verbatim, so it needs more than {{.keep}} plus one.{{end}}
/fold autoShows or sets the session setting fold to one of onoff. What it prints is the setting block below.
/fold thresholdShows or sets the session setting fold-threshold. What it prints is the setting block below.
/fold itemsShows or sets the session setting fold-items. What it prints is the setting block below.
/fold preset/fold preset tight- 1
Calls a kdeps API tool
session_opsoperation: set key: fold-threshold value: "1000" - 2
Calls a kdeps API tool
session_opsoperation: set key: fold-items value: "3"prints
Fold preset tight applied: threshold={{.steps.threshold.value}}, items={{.value}} (saved)
/fold preset balanced- 1
Calls a kdeps API tool
session_opsoperation: set key: fold-threshold value: default - 2
Calls a kdeps API tool
session_opsoperation: set key: fold-items value: defaultprints
Fold preset balanced applied: threshold={{.steps.threshold.value}}, items={{.value}} (saved)
/fold preset loose- 1
Calls a kdeps API tool
session_opsoperation: set key: fold-threshold value: "8000" - 2
Calls a kdeps API tool
session_opsoperation: set key: fold-items value: "10"prints
Fold preset loose applied: threshold={{.steps.threshold.value}}, items={{.value}} (saved)
requires:
tools/session_ops: ""
version: 2.0.0
# kdeps update installs these with this command: what its run steps use
requires:
tools/session_ops: ""
name: fold
order: 80
usage:
- args: ""
help: "Show fold status: auto on/off, threshold, items, last fold, tokens since"
- args: now
help: Fold now, whatever the threshold
- args: "auto [on|off]"
help: "Automatic folding: a lighter, checkpoint-only summarize+archive (default on)"
- args: "threshold <n|default>"
help: "Tokens since the last checkpoint that trigger a fold (e.g. 2000, 2k)"
- args: "items <n|default>"
help: Checkpoints kept in the memory prompt
- args: "preset <tight|balanced|loose>"
help: Set threshold and items together
subcommands:
"":
run:
- tool: session_ops
args:
operation: get
key: fold
print: |-
**Fold**
auto: {{.value}}
threshold: {{.threshold}} tokens
context items: {{.items}}
last fold: {{.last}}
accumulated since: {{.accumulated}} / {{.threshold}} tokens
now:
run:
- tool: session_ops
args:
operation: compact
# .summary is empty when there were too few turns; .keep is how many recent turns stay
print: |-
{{if .summary}}**Fold summary:**
{{.summary}}{{else}}Nothing to fold yet: the session has {{.turns}} turn(s); the last {{.keep}} always stay verbatim, so it needs more than {{.keep}} plus one.{{end}}
auto:
setting:
key: fold
values: [on, off]
show: "Auto-fold: {{.value}}"
set: "Auto-fold {{.value}} (saved)"
invalid: "Usage: /fold auto [on|off]"
threshold:
setting:
key: fold-threshold
show: "Fold threshold: {{.value}} tokens"
set: "Fold threshold set to {{.value}} tokens (saved)"
invalid: "threshold must be a positive token count (e.g. 2000, 2k) or default"
items:
setting:
key: fold-items
show: "Fold context-items cap: {{.value}}"
set: "Fold context-items cap set to {{.value}} (saved)"
invalid: "items must be a positive integer or default"
preset:
subcommands:
tight:
run:
- tool: session_ops
args: {operation: set, key: fold-threshold, value: "1000"}
as: threshold
- tool: session_ops
args: {operation: set, key: fold-items, value: "3"}
print: "Fold preset tight applied: threshold={{.steps.threshold.value}}, items={{.value}} (saved)"
balanced: # the "fold" event's own threshold and items
run:
- tool: session_ops
args: {operation: set, key: fold-threshold, value: default}
as: threshold
- tool: session_ops
args: {operation: set, key: fold-items, value: default}
print: "Fold preset balanced applied: threshold={{.steps.threshold.value}}, items={{.value}} (saved)"
loose:
run:
- tool: session_ops
args: {operation: set, key: fold-threshold, value: "8000"}
as: threshold
- tool: session_ops
args: {operation: set, key: fold-items, value: "10"}
print: "Fold preset loose applied: threshold={{.steps.threshold.value}}, items={{.value}} (saved)"
Versions
| Version | Published | Status |
|---|---|---|
| 2.0.0 | 10/24/2026 | active |
| 1.0.1 | 10/21/2026 | active |
| 1.0.0 | 10/12/2026 | active |
Details
- Author
- kdeps
- License
- Apache-2.0
- Latest Version
- 2.0.0
- Published
- 10/12/2026