Factory (Droid) direct-worker profile (B-OG-37, #2902)

This is the lightweight CLI profile for dispatching droid as a direct worker.

Factory (Droid) direct-worker profile (B-OG-37, #2902)

Prompt-first procedure: Describe the outcome you want in your agent conversation. The agent should select and load the appropriate AIWG assets, explain material changes, request any needed approval, and report verification evidence. Exact commands and flags appear only in the CLI reference.

This is the lightweight CLI profile for dispatching `droid` as a direct worker. It is unrelated to the `droid-bridge` MCP addon, which delegates batch work to a separately-configured Droid account.

Bring your own key

Use my OpenRouter key with Factory Droid through a BYOK custom model. Show

the exact model selector and safe key injection before asking to run it.

The operator's 2026-11-09 live run verified BYOK custom models. Register/select the model through the harness-owned custom-model settings, using the exact `custom:` identifier shown by Droid's model listing. A display name or upstream API ID is not necessarily the CLI selector; do not manufacture the suffix or index, or assume `qwen/qwen3.8-27b` is itself a valid Droid selector. Existing droid model fields require a full model ID. The #3969 fix replaced rejected `heavy`/`medium`/`light` tier aliases with full built-in IDs (`claude-opus-5`, `claude-sonnet-5`, `claude-haiku-4-5-20251001`); see model configuration. Those built-in IDs are separate from BYOK custom selectors; confirm the installed harness listing before choosing an ID.

Follow the agent’s stable-asset loader: keys come only from environment or a secret-store command at point of use, scoped to the child, with tracing disabled and credentials discarded on exit. Never place a key in argv, deployed AIWG files, droid definitions, harness config (including `apiKey` in `settings.json`), logs or receipts. Confirm the installed harness can consume the secret without persisting it; if it requires a plaintext key in settings, stop and choose a supported secure route with the operator. AIWG neither stores keys nor supplies a new injection mechanism. `FACTORY_API_KEY` authenticates Factory itself; it is not the OpenRouter inference key. BYOK runs bill the user's key; paid runs need explicit operator approval.

After approval and secure injection, send the one-line prompt `Reply with exactly: byok-ok` on stdin to `droid exec -m <custom-model-id>`. Inspect the harness log/session for the resolved model matching the registered upstream model. For custom models the r option reasoning effort is ignored: the live session reports `reasoning_effort none`. Do not claim `-r high` enforced high reasoning. Record only harness version, resolved model, effort and result. This does not change the direct-worker profile's qualification status.

Local custom-model discovery

Make my Factory BYOK model ready for worker selection. Check its documented

input context limit and configure my coding role for models without selectable

reasoning effort, then show me the resolved worker command.

the agent-owned models operation discovers BYOK models from `$HOME/.factory/settings.json` without a model turn or endpoint request. AIWG bounds the file read and parses only `customModels` model-selection fields: `model`, `displayName`, `baseUrl`, `provider`, `maxOutputTokens` and `maxContextLimit`. Credential fields (`apiKey`, `api_key`) are dropped during parsing: their values are never inspected, expanded, hashed, logged or included in observations, caches, doctor output or approval receipts. Discovery does not check whether a key exists or works. Keep using secure environment injection as described above. `settings.json` is the locally documented custom-model source; no undocumented `config.json` fallback is used.

Set `maxContextLimit` in Droid's custom model entry before using the agent-owned models operation. Factory's BYOK documentation defines it as the input-token context window. If the provider's window also counts output tokens, set it to that window minus `maxOutputTokens`. AIWG records the configured positive safe integer directly as `contextTokens`, with settings provenance; it does not subtract output tokens again. If omitted, `contextTokens` stays null and resolve blocks with `OG_MODEL_UNAPPROVED` at `/worker/contextTokens`, even after the worker qualifies. Invalid limits reject that model entry. Refresh the catalog after changing the setting.

Droid 1.0.0's `Available custom models` output (operator capture, 2026-11-10) shows the executable selector as `custom:<normalizedName>-<k>`, with spaces in the display name replaced by hyphens. For example, `AIWG OpenRouter Qwen 3.8 27B` becomes `custom:AIWG-OpenRouter-Qwen-3.8-27B-0`. The rejected unsuffixed selector and the listing are preserved in the sanitized output fixture. The three distinct names at settings indexes 0, 1 and 2 all have suffix `-0`: `k` counts earlier entries with the same normalized name, rather than the array index. Repeated identical display names receive `-1`, `-2`, and so on; distinct display names that normalize to the same name remain ambiguous and are rejected, as are unsafe names. Confirm selectors against your installed Droid version; the catalog's suffix-relabeling caveat concerns runtime reporting. Observations use this exact executable selector for both `id` and `apiModelId`; the upstream `model` is retained separately in configuration provenance. `llmProvider` reflects the endpoint host (`openrouter` for `openrouter.ai`), rather than treating `generic-chat-completion-api` as an inference provider.

Discovery records the settings source, observation time and `droid the version option`. Refresh binds a single configured Factory installation's accountScope label; the agent-owned doctor operation rereads custom-model settings using the targeted installation's probed version and configured accountScope (default `local-account`). Approval remains an explicit doctor step. Labels do not detect login changes or prove account entitlement. BYOK effort is `not-applicable`; in `models.json`, set `defaults.workerSelection.roleGuidance.<role>` for the role that selects these models to `initialEffort: null`, `effortLadder: []` and `allowNotApplicableEffort: true`. The custom invocation omits the r option rather than claiming it enforces reasoning effort. Other unknown facts, including data-use policy and context size when no limit is configured, remain unknown.

Built-in Factory plan models have no non-interactive listing command. Their static catalog pins remain available and are never promoted to observations by reading custom-model settings.

Direct-worker contract

The bundled `direct-shell` invocation profile in `agentic/code/providers/model-capabilities.v1.json` is version-bound to `droid-cli 1.0.x`. The titan eval (2026-11-06) help-verified `the auto option low`, the m option, the r option, the cwd option and `-o stream-json`. The stdin brief was echoed as the first stream-json message. That eval's built-in-model inference returned `402 No active subscription`; the later BYOK run above uses a separate custom model route. The direct profile stays `unqualified`. Issue #4362's titan smoke (2026-11-21, Droid 1.0.0) observed a terminal `completion` event with `finalText: "factory-smoke-ok"`; the adapter also accepts the documented legacy `result` success shape. The adapter (`tools/ralph-external/lib/factory-adapter.mjs`) renders:

droid exec [the auto option low] -m <model> -r <effort> the cwd option <workspace> \
  the output-format option stream-json < <brief>

The brief always travels on stdin (no `prompt` argument is ever emitted); the 1.0.0 eval verified ingestion when no `prompt` argument is given. `the auto option low` is emitted only for the `workspace-write` sandbox contract; the `read-only` contract omits the auto option entirely, since the CLI's own no-flags default already is read-only. the skip-permissions-unsafe option is never emitted by this profile.

Manual smoke run

The conductor runs this once on titan after explicit approval for the live call. Use an existing BYOK custom model and the operator's loader to supply `OPENROUTER_API_KEY` to the Droid child only, following the key-injection guidance above. No Factory subscription is required for this route; `FACTORY_API_KEY` alone does not supply OpenRouter inference access. Built-in plan models can fail with `402 No active subscription found`. This is not part of default CI and performs one live, billable call.

Run from the AIWG checkout, with the confirmed selector for the installed custom model. The example assumes the operator's loader already scopes the key to the child environment. BYOK effort is not applicable, so omit the r option.

AIWG_ROOT=$(pwd)
d=$(mktemp -d)
MODEL="custom:AIWG-OpenRouter-Qwen-3.8-27B-0"
droid the version option
echo 'Reply with exactly: factory-smoke-ok' \
  | droid exec the auto option low -m "$MODEL" the cwd option "$d" \
    the output-format option stream-json > "$d/stdout.jsonl" 2> "$d/stderr.txt"
status=$?
cat "$d/stdout.jsonl"
cat "$d/stderr.txt" >&2
echo "exit=$status"
test "$status" -eq 0 || exit 1
node the input-type option=module - "$AIWG_ROOT" "$d/stdout.jsonl" <<'JS'
import { readFileSync } from 'node:fs';
import { pathToFileURL } from 'node:url';
const { FactoryDirectAdapter } = await import(pathToFileURL(
  `${process.argv[2]}/tools/ralph-external/lib/factory-adapter.mjs`));
const final = new FactoryDirectAdapter().parseOutput(readFileSync(process.argv[3], 'utf8'));
if (final?.result?.trim() !== 'factory-smoke-ok') process.exit(1);
console.log(`adapter-final=${final.result.trim()}`);
JS

Reading the result

  • Exit code: the command must print `exit=0`. Any non-zero exit is a

fail.

  • Terminal stdout event: Droid 1.0.0 emits `{"type":"completion",

"finalText":"factory-smoke-ok",...}`. `finalText` must be a non-empty string. Legacy `result` events require `subtype: "success"`, `is_error: false`, and a non-empty `result` string. An `error` event anywhere, malformed JSON, or an unsuccessful terminal fails the stream.

  • Adapter extraction: the command must print

`adapter-final=factory-smoke-ok` and exit zero. Both terminal shapes normalize their answer to the adapter's `result` field.

Record the installed `droid the version option` output, the command above, and the pass/fail outcome (exit code, terminal event and adapter extraction) on #3005. Tick its Factory row only after this updated smoke passes. The worker for #4362 used offline fixtures; the live rerun and tracker update remain deferred to the conductor. This manual run is evidence only; it never marks the registry profile as qualified for automated dispatch.