AppGitHub
Context API

ctx.config

ctx.config contains runtime-resolved strategy parameter values from strategy settings.

Overview

ctx.config contains the resolved runtime configuration values for the active strategy.

These values are derived from the strategy's configSchema and are provided to the strategy worker as a read-only object.

Each configuration entry becomes a property on ctx.config, using the key defined in the schema.

For example:

const depth = ctx.config.historyDepth

Shape

ctx.config is a plain object where each property corresponds to a key defined in the strategy's configSchema.

interface Config {
  [key: string]: unknown
}

At runtime, each key defined in configSchema is exposed as:

ctx.config.<key>

Supported Config Types

Strategies can define configuration parameters using the following types.

text

Text input values.

Used for prompts, labels, or free-form text configuration.

Example schema:

{
  key: "systemPrompt",
  type: "text",
  default: "You are a helpful assistant."
}

Runtime value:

ctx.config.systemPrompt

number

Numeric configuration values.

Number fields may define upper and lower bounds.

Example schema:

{
  key: "historyDepth",
  type: "number",
  default: 10,
  min: 1,
  max: 50
}

Runtime value:

ctx.config.historyDepth

Runtime guarantees that the value is clamped within the defined bounds.

boolean

Boolean toggle values.

Example schema:

{
  key: "enableRAGMemory",
  type: "boolean",
  default: true
}

Runtime value:

ctx.config.enableRAGMemory

select

Single-choice values selected from predefined options.

Example schema:

{
  key: "promptStyle",
  type: "select",
  default: "simple",
  options: ["simple", "cot", "structured"]
}

Runtime value:

ctx.config.promptStyle

If an invalid value is encountered, the default value is used.

Where Values Come From

Configuration values are resolved by the host using:

  • the strategy's configSchema
  • saved user configuration overrides
  • the currently selected strategy in the conversation

If no override exists, the schema default value is used.

Runtime Guarantees

The host ensures that all configuration values are safe to use.

At runtime:

  • all keys defined in configSchema are present on ctx.config
  • default values are always applied
  • numeric values are clamped to min / max
  • invalid select values fall back to default

Strategies therefore do not need to perform additional validation.

Usage

Strategies typically read configuration values when building prompts.

Example:

export default defineStrategy({
  configSchema: [
    {
      key: "historyDepth",
      type: "number",
      default: 10,
      min: 1,
      max: 20
    }
  ],

  onContextBuild(ctx) {
    const history = ctx.history.recent(ctx.config.historyDepth)

    ctx.slots.add("history", history)
    ctx.slots.add("input", ctx.input)

    return ctx.slots.render()
  }
})

What ctx.config Is Not

ctx.config is not the model parameter surface.

Provider-level settings such as:

  • temperature
  • max tokens
  • top-p
  • model selection

are not exposed through ctx.config.

These belong to the model runtime layer rather than the strategy configuration surface.

On this page