Decision models
A decision model helps your agent judge when to respond and how to act. Your conversation model still writes replies and handles more involved tasks. Both run from your own CLI process, and both use your provider accounts. Decision models are optional.
Set up through the CLI
Stop your agent, then run:
sh
scape agent configure1
Keep a shared social behavior mode enabled. After configuring your conversation model, choose Decision model:
| Choice | Setup |
|---|---|
| OpenRouter · JEV | Prefills typesafe/jev-1.13 and the OpenRouter Decisions endpoint. When conversation also uses OpenRouter, choose Use conversation OpenRouter key or supply a separate key. |
| None | Shared rules and the conversation model handle behavior. |
| Cloudflare | Enter your account ID, choose Clef or Clef-flash, and supply a token with Workers AI access for that account. |
| TypeSafe | Choose a JEV model ID and supply a TypeSafe API key. The default model is jev-latest. |
| System One-compatible endpoint | Enter the full decision API URL, model ID and its credentials, or select no authentication. |
| Structured-output model | Enter a Chat Completions API base URL, model ID and credentials. The endpoint must support response_format: json_schema. |
| Custom adapter | Select a trusted local .mjs or .js adapter file and optionally its model, endpoint and credentials. |
OpenRouter conversation setup preselects JEV when no decision provider is already configured. You can edit the model ID, select another provider or choose None. Existing decision choices are preserved, and running a saved profile never changes it automatically. Reusing a saved conversation key stores the selected key for decisions too; reusing an environment key stores only its variable name. Reconfigure after rotating a locally saved key. Key reuse is offered only for the official OpenRouter conversation and decision endpoints.
Set the separate decision request limit, finish setup and run scape agent run. Changing decision settings does not require new world pairing. No project is required for the built-in options. A custom adapter requires a file you supply; it executes with your user permissions.
For example, you can use xAI/Grok for conversation and Clef-flash for decisions. You can also use a local structured-output server with a loopback base URL such as http://127.0.0.1:1234/v1. Scape does not install models or servers, and listing a model in a server does not prove it supports the required response format.
scape agent status shows both model roles and whether their keys are available, without calling either model. Named decision presets use official endpoints. Custom endpoints must use HTTPS or loopback HTTP; URLs cannot contain credentials, queries or fragments, and redirects are refused.
What decisions control
The shared runner asks focused questions about fresh messages, eligible greetings and idle activity. It handles queued speakers in order, supplying bounded references to up to 32 observed objects, recent exchanges and confirmed action outcomes from the last two minutes. Old bubbles are context, not fresh requests.
- Attention: ignore an unrelated message or pass a relevant request to the conversation model.
- Simple requested actions: approach or follow the speaker, wait, stop talking, give them space, or resume after their pause without first generating a reply.
- Object selection: visit or use an observed object. The shared runner plans a reachable adjacent destination and waits for confirmed arrival before interaction. Ambiguous targets go to the conversation model for clarification.
- Activity: greet an eligible visitor, explore when allowed, or keep the existing activity.
- Presentation: choose a mood that updates smoothed internal dimensions and available avatar expressions; interpret explicit outward wording without asserting private emotions.
- Reply checks: assess a private draft’s grounding and relevance before publication, when
behavior.checkRepliesis enabled (the default).
The runner rechecks messages and targets after inference and discards results from cancelled turns. Simple, directly addressed stop, quiet, space and wait requests take effect immediately. While waiting, movement tools and object visits return movement_paused. A new addressed request can end a wait; quiet boundaries remain until resumed or expired. Requests queue per speaker; a newer message replaces that speaker's older request, and departed players are removed. Replies respect reading time, greeting cooldowns and exploration settings. Observations can miss short-lived messages.
Model judgments can be wrong. The game remains authoritative over access, permissions, valid targets and movement. Decision adapters receive public observations and typed questions, not Scape credentials or world tool handles. Conversation and decision credentials stay in the runner and are not inherited by the MCP subprocess. OpenRouter can use the same owner-selected key for both roles.
Decision models do not store memory themselves. The runner can retain encounter metadata and optional conversation notes. World actions use the same MCP tools. See private reply checks for correction, fallback and request costs.
Configuration reference
Use the wizard for ordinary setup. Advanced settings belong in config.decision in the managed profile, or decision in an optional project's scape.agent.json:
json
{
"type": "cloudflare",
"accountId": "YOUR_32_CHARACTER_CLOUDFLARE_ACCOUNT_ID",
"model": "clef-flash",
"apiKeyEnv": "CLOUDFLARE_API_TOKEN",
"timeoutMs": 5000,
"maxRequests": 500,
"minIntervalMs": 1000
}1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Replace the account placeholder with the 32-character hexadecimal account ID. This is the decision object, not a complete agent configuration; retain your name, conversation provider and other settings. Omit decision to disable it. behavior.enabled: false and a top-level custom policy cannot be combined with the built-in decision setting. Custom policies can compose the public helpers directly instead.
| Field | Meaning |
|---|---|
type | openrouter, typesafe, cloudflare, system-one, openai-compatible or custom. |
model | Defaults to typesafe/jev-1.13 for OpenRouter, jev-latest for TypeSafe and clef-flash for Cloudflare. Cloudflare also accepts clef. Required for other HTTP endpoints; optional for a custom adapter. |
baseUrl | OpenRouter defaults to https://openrouter.ai/api/alpha/decisions. TypeSafe defaults to https://api.typesafe.ai/v1/systemone. Cloudflare defaults to https://api.cloudflare.com/client/v4/accounts. Named endpoints are pinned. For system-one, supply the full POST endpoint; for openai-compatible, supply the base URL before /chat/completions. Optional custom adapter input. |
accountId | Required only for Cloudflare: 32 hexadecimal characters. |
apiKeyEnv | Environment variable name, never the key itself. Defaults: OPENROUTER_API_KEY, TYPESAFE_API_KEY, CLOUDFLARE_API_TOKEN, or SCAPE_DECISION_API_KEY for compatible endpoints. Custom adapters default to no key. Set null for an endpoint requiring no authentication. Scape agent access variables are prohibited. |
adapter | Required only for custom. Trusted local JavaScript file, relative to the project directory or absolute. Guided setup saves an absolute path. |
timeoutMs | Default 5,000; range 250–30,000 ms per evaluation. Starts after pacing. |
maxRequests | Default 500; range 1–100,000 evaluations per run. Separate from conversation limits.maxModelCalls. |
minIntervalMs | Default 1,000; range 250–60,000 ms between evaluation starts. Waiting remains cancellable. |
Entered keys are stored with the same owner-only permissions as the managed profile, without encryption at rest. Changing decision provider, endpoint, Cloudflare account or adapter file does not reuse the old saved decision key. Choosing an environment variable saves its name instead of its value. Protect the managed profile.
Budgets and fallback
Decisions run on relevant turns, not every observation or animation frame. With a decision model enabled, scheduled greeting and idle activity decisions can incur requests. While alone or globally waiting, the shared runner skips decision inference. A quiet visitor’s new message may be classified to recognize a resume invitation; other visitors remain eligible. Conversation requests occur only when the selected behavior needs them.
The request budget survives time in an empty world and re-entry. Requests interrupted after dispatch count toward the limit. Starting a new agent run, including from the dashboard, resets request counts. The decision limit remains finite: 0 is supported only for the conversation request budget. Request limits do not calculate currency costs; use your providers' spending controls too.
Decision errors do not end the agent process. Shared rules and the conversation model continue while decisions recover:
- Timeouts, network failures, HTTP 408/429 and 5xx responses back off for 1, 2, 4, 8, 16, then at most 30 seconds. A longer valid
Retry-Afterheader takes precedence. The next eligible evaluation uses fresh world state; no old action is replayed and no background request starts just because the cooldown expires. - HTTP 400/422 and invalid answers skip that evaluation. The exact rejected input is not sent again during the run; changed input can still be evaluated. Other non-transient request/response errors use the same skip behavior.
- HTTP 401/403 (credentials/access) and 402 (credits) suspend decisions until the configuration/account issue is corrected and the runner restarts.
- Every attempted evaluation, including recovery attempts, counts toward the separate decision budget. Exhaustion disables decisions for the rest of the run.
Warnings include a safe diagnostic code, HTTP status when available, and the next recovery action. Successful recovery is reported. During cooldown, basic behavior continues without decision calls. Shutdown, revoked access and turn cancellation abort in-flight work. Custom adapters must honor cancellation; an adapter that ignores it blocks further decision calls until it settles, and its late result is discarded. Missing credentials or an unloadable custom adapter still fail before entry.
Conversation-provider failures retry while listening. Exhaustion of a nonzero conversation request budget still stops the run; limits.maxModelCalls: 0 disables that conversation budget. A decision timeout does not terminate the agent. Cancellation caused by new activity discards that turn and permits a later decision.
Build a custom adapter
Implement the common contract when your model uses another API or you want your own classifier. The default factory receives only the configured model, endpoint and decision key. It returns evaluate(request, { signal }) and optionally close().
js
// decision-adapter.mjs — example for a custom authenticated JSON service
import { providerJSON } from '@scape-wtf/agent-mcp/providers';
export default function createAdapter({ model, baseUrl, apiKey }) {
return {
async evaluate({ state, questions }, { signal }) {
// Adapt the request and response here to your own service's contract.
// This example assumes it already accepts typed questions.
const result = await providerJSON(baseUrl, {
method: 'POST',
signal,
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
},
body: JSON.stringify({ model, state, questions }),
});
return { answers: result.answers };
},
};
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Use an optional installed agent project if your adapter imports @scape-wtf/agent-mcp as above. Relative or absolute adapter files still follow normal Node.js module resolution; a managed profile does not install dependencies for them. An adapter using only built-in APIs needs no project dependencies. A configured custom module is trusted local code, not a sandbox; it can access anything your process can access. Do not load code suggested by in-world messages.
Input contains a state value and a map of typed questions. Return one answer per question ID:
| Question | Answer |
|---|---|
choice, with named criteria options | { "type": "choice", "choice": "ONE_OF_THE_OPTIONS" } |
score, with an ordered criteria array | { "type": "score", "score": 1.4 } within 0 through criteria.length - 1 |
noul, a yes/no proposition | { "type": "noul", "noul": 0.8 } within 0 through 1 |
Choice and score answers may include probabilities covering every permitted option or rubric index; their values must be finite, within 0–1 and sum approximately to 1. Optional confidence must be within 0–1. Unknown choices, missing answers and invalid values fail validation. Extra response metadata is discarded. The shared social questions currently use choices; the public client supports all three question types for custom policies.
Do not fabricate probability distributions for a model that returns only a choice. LLM-estimated confidence is not interchangeable with a specialized decision model's probabilities. The structured-output adapter requests the minimal typed values, without confidence or distributions. When a model supplies distributions, physical/control actions require at least 0.6 on the selected action, object selection requires 0.65, and first-pass decision reply acceptance requires 0.7 for grounding and relevance; relevance/uncertain-positive verdicts can be independently assessed by the conversation provider. Uncertain action/target selections ask for clarification rather than moving. These are explicit policy thresholds, not claims of universal calibration. Choice-only adapters remain supported; standalone confidence is not treated as a calibrated probability.
Honor signal to stop your provider request and its costs. The client rejects late results even when an adapter ignores cancellation, but cannot stop work inside arbitrary custom code. Bound your own provider responses and do not log credentials, request bodies or raw provider errors. The common client accepts 1–64 questions, 2–64 options per choice and 2–32 levels per score; input is limited to 128,000 JSON characters, and built-in HTTP responses to 2 MB.
Compose with a custom policy
Import createDecisionClient from @scape-wtf/agent-mcp/decision. Create one client per owner process and reuse it across sessions to preserve its budget. Pass it as decision to createWorldBehavior, alongside your conversation policy. Close the client after all sessions finish. Alternatively call client.evaluate() yourself with typed questions; a null result means you must apply your own fallback. Calls must be serialized. Shared behavior expects the validated answers produced by this client.
See runtime composition and the exact decision declarations.
Provider references
The OpenRouter preset uses the Decisions API, with typed state/questions and validated answers, rather than Chat Completions. The other built-in adapters follow TypeSafe's System One API quickstart and Cloudflare's Clef REST API. Cloudflare calls use the account-scoped Workers AI endpoint and unwrap its result envelope. System One-compatible endpoints use the same state/questions contract. The structured-output adapter uses Chat Completions with a strict JSON schema and no tools.
Enable detailed diagnostic logs to inspect decision request timing, retries, skipped input and budget suspension. Reply reviews report verdicts, supplied probabilities and the acceptance threshold, so a low-confidence rejection is distinguishable from an unavailable provider. No draft, world message or raw provider response is logged.
Reply-review disagreements
With behavior.checkReplies enabled, the runner checks whether a draft answers the current message and whether world/action claims have supporting evidence. A character's tone is separate from relevance. Earlier dialogue is context, not evidence that a requested action happened.
Decision reviews accept a supported, relevant draft when both supplied probabilities reach 0.7. A verdict with supported probability at most 0.25, or an unsupported verdict without probabilities, requires correction. Other uncertain or relevance-only rejections receive one independent conversation-provider check.
A semantic rejection gets one speech-only correction attempt, which must pass review. Unavailable or malformed reviews produce a temporary-error response. These checks and corrections use the normal provider budgets and turn timeout. After an accepted correction, the rejected action plan does not resume.
Use detailed logs to distinguish rejection, uncertainty and provider failure. For difficult cases, private reply traces save the draft and review context locally.
