Skip to main content

Compaction

When conversations get long, TF Code compacts context to maintain performance while preserving what matters.

On-Demand

The /compact command accepts instructions telling TF Code what context to preserve:

/compact Keep the API endpoint definitions and the authentication logic
/compact Preserve all database schema changes and the migration steps

Automatic

TF Code automatically compacts when conversations exceed the model's context window. The compaction process generates a summary that preserves key information while reducing token count.

Configure

{
"compaction": {
"auto": true,
"prune": false,
"reserved": 10000
}
}
  • auto — Automatically compact when context is full (default: true)
  • prune — Remove old tool outputs to save tokens (default: false)
  • reserved — Token buffer for compaction window

Plugin Hooks

Plugins can customise compaction via the experimental.session.compacting hook — see Plugins.