Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion docs/step-configuration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Step configuration files

Step creates the global `~/.stepcode/config.toml` when it first runs.
Step creates the global `~/.stepcode/config.toml` when it first runs, together
with `config.schema.json` and `models.schema.json` beside it.
The project file `<cwd>/.stepcode/config.toml` is optional: a missing file
contributes no project settings and does not produce a startup warning.
Reading or reloading settings does not create the project file or directory.
Expand All @@ -19,6 +20,47 @@ and `auth.json` keep their own formats — they hold model definitions and
credentials, not settings — and a stale Step endpoint recorded in `models.json`
by an older release is still repaired in place at startup.

## Editor schema and configuration discovery

`config.toml` and `models.json` each have a JSON Schema generated from the same
TypeBox definitions their loaders validate with, so a key exists in the schema
exactly when the runtime reads it. Nothing is published at a URL and nothing is
fetched: the schema travels with the build, which means an editor never
validates a file against a different version than the binary that wrote it.

| Command | Result |
| --- | --- |
| `step config show` | The stored global and project documents, `models.json`, and every resolved path. Values are not merged or defaulted; credentials are redacted |
| `step config path --json` | The same paths, including both schema files |
| `step config schema [config\|models]` | The schema on stdout |
| `step config schema --out <file>` | The schema written to a file |
| `step config init` | Template, `#:schema ./config.schema.json`, and both schemas beside the file |

The schemas are written beside the global `config.toml` only. A project file
does not receive a copy: the repository owns that directory, two ~80 KB files in
every checkout would show up in `git status`, and a relative directive there
would point at a file that is not present. Use `step config schema --out` when a
project needs one.

The schemas are committed at `packages/coding-agent/schema/`. `pnpm run
generate:config-schema` writes them; `pnpm run check:config-schema`, which is
part of `pnpm run check`, renders them again and fails when the committed copy
differs. The theme schema is generated the same way into
`packages/coding-agent/src/theme/theme-schema.json`, which is why the built-in
themes reference it as `./theme-schema.json` instead of a repository URL.

The global file this product creates starts with the editor directive. An
existing file keeps its own header, so adding one by hand is the only step
needed for a file written by an older release:

```toml
#:schema ./config.schema.json
```

The schema describes what a file may contain; it does not replace read-time
validation. Step still reports a bad value once at load and then uses its
default, and it still ignores an unknown key rather than refusing to start.

## Step Plan login and API-key fallback

Browser sign-in checks the selected region's `/step_plan/v1/usage` endpoint
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "cd packages/tui && npm run build && cd ../telemetry && npm run build && cd ../providers && npm run build && cd ../agent-core && npm run build && cd ../config && npm run build && cd ../lark-adapter && npm run build && cd ../coding-agent && npm run build && cd ../../apps/cli && npm run build",
"build:offline": "cd packages/tui && npm run build && cd ../telemetry && npm run build && cd ../providers && npm run build:offline && cd ../agent-core && npm run build && cd ../config && npm run build && cd ../lark-adapter && npm run build && cd ../coding-agent && npm run build && cd ../../apps/cli && npm run build",
"build:binaries": "bash scripts/build-binaries.sh --product step --offline-model-data",
"check": "biome check --write --error-on-warnings . && pnpm run check:pinned-deps && pnpm run check:ts-imports && pnpm run check:layer-direction && pnpm run check:ui-layer && pnpm run check:workspace-registry && pnpm run check:tui-no-ai && pnpm run check:coding-agent-entry-freeze && pnpm run check:contracts-deps-empty && pnpm run check:derived-compat-only && pnpm run check:no-provider-dispatch && pnpm run check:session-event-transports && pnpm run check:metadata-not-in-dispatch && pnpm run check:no-secret-leak && pnpm run check:legacy-scope-prefix && pnpm run check:no-observability && pnpm run check:public-boundary && tsgo --noEmit && pnpm run check:browser-smoke",
"check": "biome check --write --error-on-warnings . && pnpm run check:pinned-deps && pnpm run check:ts-imports && pnpm run check:layer-direction && pnpm run check:ui-layer && pnpm run check:workspace-registry && pnpm run check:tui-no-ai && pnpm run check:coding-agent-entry-freeze && pnpm run check:contracts-deps-empty && pnpm run check:derived-compat-only && pnpm run check:no-provider-dispatch && pnpm run check:session-event-transports && pnpm run check:metadata-not-in-dispatch && pnpm run check:no-secret-leak && pnpm run check:legacy-scope-prefix && pnpm run check:no-observability && pnpm run check:public-boundary && pnpm run check:config-schema && tsgo --noEmit && pnpm run check:browser-smoke",
"check:browser-smoke": "node scripts/check-browser-smoke.mjs",
"check:pinned-deps": "node scripts/check-pinned-deps.mjs",
"check:ts-imports": "node scripts/check-ts-relative-imports.mjs",
Expand All @@ -34,9 +34,11 @@
"check:legacy-scope-prefix": "node scripts/check-legacy-scope-prefix.mjs",
"check:no-observability": "node scripts/check-no-observability.mjs",
"check:public-boundary": "node scripts/check-public-boundary.mjs",
"check:config-schema": "tsx --tsconfig tsconfig.json scripts/generate-config-schema.ts --check",
"generate:models": "npm --prefix packages/providers run generate-models",
"hydrate:model-data": "npm --prefix packages/providers run hydrate-model-data",
"check:model-data": "npm --prefix packages/providers run check:model-data",
"generate:config-schema": "tsx --tsconfig tsconfig.json scripts/generate-config-schema.ts",
"generate:model-catalog": "npm --prefix packages/providers run generate-model-catalog",
"diff:model-catalog": "node scripts/diff-model-catalog.mjs",
"profile:tui": "node scripts/profile-coding-agent-node.mjs --mode tui",
Expand Down
6 changes: 3 additions & 3 deletions packages/coding-agent/docs/compaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contextTokens > min(
)
```

`triggerRatio` defaults to `0.85` for every model (configurable globally or per model in `~/.stepcode/config.toml` or trusted `<project-dir>/.stepcode/config.toml`). Providers clamp each request's `max_tokens` to the remaining context minus a 4096-token safety margin, so the second term keeps room for the next response: on a small window 15% of the context is less than that margin plus the response reservation. The trigger never drops below half the window. With an 8K-or-larger output limit, a 32K window compacts at 20,480 tokens (62.5%), 64K at 53,248 (81.25%), and 131K or larger at 85%. On large windows the default leaves 15% of the window as headroom for the response and for estimation error, so a prompt the heuristic underestimates (images, unusual text) is less likely to exceed the provider limit before compaction runs. A response truncated by the clamp still goes through the overflow/length recovery below. `tokenLimit` can only make compaction trigger earlier. An explicitly configured `reserveTokens` keeps its old effect as an additional ceiling, `contextWindow - reserveTokens`.
`triggerRatio` defaults to `0.9` for every model (configurable globally or per model in `~/.stepcode/config.toml` or trusted `<project-dir>/.stepcode/config.toml`). Providers clamp each request's `max_tokens` to the remaining context minus a 4096-token safety margin, so the second term keeps room for the next response: on a small window 15% of the context is less than that margin plus the response reservation. The trigger never drops below half the window. With an 8K-or-larger output limit, a 32K window compacts at 20,480 tokens (62.5%) and a 64K window at 53,248 (81.25%), because the response headroom is the smaller term; a 128K-or-larger window compacts at 90%. On large windows the default leaves 10% of the window as headroom for the response and for estimation error, so a prompt the heuristic underestimates (images, unusual text) is less likely to exceed the provider limit before compaction runs. A response truncated by the clamp still goes through the overflow/length recovery below. `tokenLimit` can only make compaction trigger earlier. An explicitly configured `reserveTokens` keeps its old effect as an additional ceiling, `contextWindow - reserveTokens`.

Step checks the threshold once immediately before every model request: before the first request of a prompt (counting the incoming prompt), before every follow-up request inside a tool loop (counting the new tool results and injected steering), and before the first request of a continuation. If the threshold is crossed, Step compacts inside the same agent run and resumes with the summary and retained messages. Steering queued while a follow-up request compacts is delivered to that same request. Input queued while the pre-run check compacts (or added by an `agent_start` listener) joins the first request and is measured again before it is sent; input typed while that first request's own check compacts is delivered with the next request. A final answer that crosses the threshold does not compact on its own; the next request compacts first. Context-overflow and truncated-length recovery still run after the failed response. If measuring or preparing maintenance throws unexpectedly, the request is sent unchanged and overflow recovery remains the fallback.

Expand Down Expand Up @@ -438,7 +438,7 @@ Configure compaction in `~/.stepcode/config.toml` or trusted `<project-dir>/.ste
```toml
[compaction]
enabled = true
triggerRatio = 0.85
triggerRatio = 0.9
keepRecentTokens = 20000

[compaction.modelTriggerRatios]
Expand All @@ -448,7 +448,7 @@ keepRecentTokens = 20000
| Setting | Default | Description |
|---------|---------|-------------|
| `enabled` | `true` | Enable auto-compaction |
| `triggerRatio` | `0.85` | Fraction of the context window that triggers auto-compaction (0.5-0.95); small windows trigger earlier to keep response room |
| `triggerRatio` | `0.9` | Fraction of the context window that triggers auto-compaction (0.5-0.95); small windows trigger earlier to keep response room |
| `modelTriggerRatios` | none | Per-model `triggerRatio`, keyed by `provider/model-id` |
| `tokenLimit` | none | Absolute token ceiling; can only trigger earlier |
| `triggerPolicy` | `"v2"` | `"legacy"` restores the previous threshold and checkpoints |
Expand Down
2 changes: 1 addition & 1 deletion packages/coding-agent/docs/context-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ next request. This avoids an unused context-edit/summary call after a completed
task, while explicit maintenance commands and error recovery keep their normal
behavior. By default it uses the native compact trigger,
`contextTokens > floor(contextWindow * compaction.triggerRatio)` with a default
ratio of 0.85, so a 131,072-token window triggers above 111,411 tokens. Smaller
ratio of 0.9, so a 131,072-token window triggers above 117,964 tokens. Smaller
windows trigger earlier to keep room for the next response. See
[Compaction](compaction.md#when-it-triggers) for the exact rule, per-model ratios, and the legacy policy.
With at least 8,000 context tokens and enough editable old text, CLM gets the first
Expand Down
2 changes: 1 addition & 1 deletion packages/coding-agent/docs/custom-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ interface OAuthLoginCallbacks {

### OAuthCredentials

Credentials are persisted in `~/.stepcode/agent/auth.json`:
Credentials are persisted in `~/.stepcode/auth.json`:

```typescript
interface OAuthCredentials {
Expand Down
18 changes: 17 additions & 1 deletion packages/coding-agent/docs/models.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
# Custom Models

Add custom providers and models (Ollama, vLLM, LM Studio, proxies) via `~/.stepcode/agent/models.json`.
Add custom providers and models (Ollama, vLLM, LM Studio, proxies) via
`~/.stepcode/models.json`.

The file is validated as a whole when it loads. A structural problem — a model
without `id`, a field with the wrong type — is reported with the failing path and
**no** custom provider is registered until the file is fixed. A half-loaded
catalog would make a model silently disappear from `/model`, which is harder to
diagnose than an explicit error.

An unknown field inside a provider or model is ignored rather than rejected, the
same way an unknown key in `config.toml` is: a newer Step may add a field, and an
older one should keep loading the file. The editor schema flags those fields, so a
typo is visible without starting a session; the runtime still ignores them.

A schema for editor completions ships with Step: run `step config init` to write
`models.schema.json` beside the file and add `"$schema": "./models.schema.json"`
as the first key, or print it with `step config schema models`.

## Table of Contents

Expand Down
4 changes: 2 additions & 2 deletions packages/coding-agent/docs/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Use `/login` in interactive mode, then select a provider:
- xAI (Grok/X subscription)
- OpenRouter (OAuth-minted API key billed from OpenRouter credits)

Use `/logout` to clear credentials. Tokens are stored in `~/.stepcode/agent/auth.json` and auto-refresh when expired. OpenRouter instead mints a user-controlled API key that does not expire automatically.
Use `/logout` to clear credentials. Tokens are stored in `~/.stepcode/auth.json` and auto-refresh when expired. OpenRouter instead mints a user-controlled API key that does not expire automatically.

### OpenAI Codex

Expand Down Expand Up @@ -102,7 +102,7 @@ Reference for environment variables and `auth.json` keys: [`const envMap`](https

#### Auth File

Store credentials in `~/.stepcode/agent/auth.json`:
Store credentials in `~/.stepcode/auth.json`:

```json
{
Expand Down
2 changes: 1 addition & 1 deletion packages/coding-agent/docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
step
```

You can also run `/login` and select an API-key provider to store the key in `~/.stepcode/agent/auth.json`.
You can also run `/login` and select an API-key provider to store the key in `~/.stepcode/auth.json`.

See [Providers](providers.md) for all supported providers, environment variables, and cloud-provider setup.

Expand Down
2 changes: 1 addition & 1 deletion packages/coding-agent/docs/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ Authentication resolution priority (handled by `ModelRuntime`):
import { InMemoryCredentialStore } from "@step-harness/providers";
import { createAgentSession, ModelRuntime } from "@step-harness/coding-agent";

// Default: uses ~/.stepcode/agent/auth.json and ~/.stepcode/agent/models.json
// Default: uses ~/.stepcode/auth.json and ~/.stepcode/models.json
const modelRuntime = await ModelRuntime.create();

// Provider-owned auth methods and current status
Expand Down
Loading