Commit Graph
3 Commits
Author SHA1 Message Date
yetone 38f4f74e62 droid: a reasoning model's entry has reasoningEffort, a built-in's baseModelId
tao5010 on Discord: Droid's /model offered no thinking level for any
magpie model. magpie wrote customModels with neither reasoningEffort nor
baseModelId, and droid 1.3.0 (its customModel schema and picker read
from the 1.3.0 bundle) gives a custom model it can't match to a built-in
the levels ["none"], and sends no reasoning field whatever is picked.
With reasoningEffort it offers off, low, medium and high plus that
value, which is the default. With baseModelId it uses that built-in's
own list.

What magpie writes now:
- A model that reasons (Reasoning, or levels known) gets reasoningEffort:
  its default effort if droid's enum takes it, else medium, else the
  nearest level it has (high, low, xhigh, max, minimal). It is never none,
  off, dynamic or a value outside the enum.
- A model whose own id is one of droid 1.3.0's built-in ids exactly
  (codex/gpt-5.4 is gpt-5.4) also gets baseModelId.
- A routing group gets reasoningEffort only when its members share
  levels, and never a baseModelId.
- A model that doesn't reason gets neither.
- Both fields are droidKept, so a value the user set, or a field they
  took out, stays as they left it.

Run (on mote):
- TestDroidReasoningEffort was red on the old droid.go, with every
  expected value <nil>.
- Broken by hand, each part goes red: without the two droidKept names
  (the user's value is overwritten), without the group check in
  droidEffort (a group with no shared levels gets medium), and without
  the group check on baseModelId (group/gpt-5.4 gets baseModelId
  gpt-5.4).
- gofmt, go vet, plus Linux (nogui) and Windows vet of internal/agent.
- go test -timeout 45m ./internal/agent/...: ok (633.6s)
- Real droid 1.3.0 in a sandbox HOME on mote, with the settings.json
  this code writes, and droid exec against a fake gateway that logs
  each request:
  - oa/gpt-5.4 (baseModelId) sent reasoning effort low for -r low.
  - deepseek/flash sent reasoning_effort low.
  - group/gpt-5.4 sent low and xhigh.
  - resp/grok-5 sent xhigh.
  - A reasonless model and a group whose members share no levels sent
    no reasoning field.
  - The file parsed with no error. Earlier runs showed that an unknown
    baseModelId is ignored without breaking the entry.

Not tried:
- The TUI's /model picker itself, which needs a Factory sign-in.
- A real upstream model behind the fake gateway.
- An older droid than 1.3.0.
2026-11-04 19:36:14 +08:00
yetone cf9ea977ca agent: Droid gets a GPT on openai and a Claude on anthropic, as droid asks, and keeps an entry edited by hand
ji233 on Discord: droid warned at session start that "ultrafast/gpt-6.1-sol
appears to be an OpenAI model, but is configured with provider
generic-chat-completion-api". magpie wrote every model on a Chat provider
as generic-chat-completion-api, whatever its name.

droid's own rule, read from its bundle (droid 0.231.0, xs and g2): a
custom model's "model" matching /\bgpt[-_.]?\d/i, /codex/i or
/\bo[1-9](?:[-_.]|$)/i on any provider but openai is warned about as
OpenAI's; then one matching /claude|haiku|sonnet|opus/i on neither
anthropic nor bedrock-converse as Claude's. droid first looks the name up
among its own models; every OpenAI one there matches the patterns except
gpt-image/gpt-transcribe, so the patterns alone are used (droidWants).
Such a model now goes on the provider droid asks for (openai on the
gateway's /v1, anthropic on its root), and the gateway translates
(Responses->Chat: TestResponsesClientChatUpstream; groups on Responses
as for Codex). Other models keep their native API as before.

A provider, displayName, maxContextLimit, maxOutputTokens or
noImageSupport the user changed in one of magpie's entries stays through
a sync and a new pick: what magpie last wrote is stashed
(droid:<path>:wrote), a value other than it is the user's. Keys magpie
doesn't write stay too (droid's index aside). baseUrl follows the
entry's provider; apiKey is wiring, put back at every sync. With no
record (entries an older magpie wrote, which each sync wrote over
anyway), magpie's values are taken, so ji233's entries move to openai on
the next sync. Disconnect forgets the record. Doc: agent-wiring.md.

Run (mote):
- go test ./internal/agent -run TestDroid: ok. Red on the old droid.go
  (TestDroidWantsItsOwnRule, TestDroidProviderByName,
  TestDroidKeepsAnEntryEditedByHand all FAIL); with droidMerge forced
  to magpie's values, TestDroidKeepsAnEntryEditedByHand FAILs.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/agent ok.
- go test -count=1 -timeout 45m ./... at 5be7d8ab7 (on 133493488): 79
  packages ok; internal/gui's real-window AppKit tests killed at their
  deadline (TestPanelCloseHidesIt and TestTrayCellClickReleasedPanel
  fail the same on origin/main b4cb946f9 on mote: #4125, #2645), and
  internal/update TestRelaunchOpenTriedAgain's TempDir cleanup (#3881;
  passes -count=3 alone at this head, and alone on b4cb946f9).
  After rebasing on b4cb946f9: go test ./internal/agent ok.
- Real droid 0.231.0 in a sandbox HOME on mote, no sign-in, against a
  sandbox `magpie serve` built from this tree with a Chat-only provider
  "ultrafast" (gpt-6.1-sol, claude-opus-4-7, kimi-k2.5) on a fake
  upstream: `magpie droid magpie/ultrafast/gpt-6.1-sol` wrote openai /
  anthropic / generic-chat-completion-api; `droid exec -m
  custom:magpie/ultrafast/<m> "say pong"` answered PONG for all three
  through /v1/responses, /v1/messages and /v1/chat/completions, the
  upstream got Chat each time, and no "appears to be" warning was in
  droid's sessions. The same droid on generic-chat-completion-api for
  gpt-6.1-sol stored the warning in its session; on openai it didn't.

Not tried: droid's interactive TUI (exec only); a real vendor upstream
(fake Chat upstream only); Windows/WSL droid; droid's built-in-name
lookup cases the patterns miss (gpt-image-*, gpt-transcribe).
2026-10-30 19:34:45 +08:00
yetone cb65895ac3 agents: Factory's Droid CLI is an agent magpie sets up (#242 tasselx) — droid keeps its settings in ~/.factory/settings.json ($FACTORY_HOME_OVERRIDE/.factory when set), its BYOK models the customModels array ({model, displayName, baseUrl, apiKey, provider "anthropic" | "openai" (Responses) | "generic-chat-completion-api", maxOutputTokens, noImageSupport …}), picked as "custom:<id>". Picking a catalog model through magpie appends one entry per catalog model after the user's own (so their ids never move), each with an explicit id "custom:magpie/<provider>/<model>", the catalog's label as displayName, the gateway and token magpie, its context (maxContextLimit) and output when known, noImageSupport always written (droid takes a Chat Completions model as blind otherwise), and the API its provider speaks natively so the gateway relays it as it is: Responses → "openai" at /v1, Messages → "anthropic" at the gateway root (Anthropic's SDK adds /v1), anything else "generic-chat-completion-api" at /v1; and sets sessionDefaultSettings.model. The model shows in magpie as magpie/<ref>; the user's sessionDefaultSettings.model is stashed and put back on reset (a top-level "model", the docs' spelling, is left alone and is what droid falls back to), magpie's entries go and an emptied customModels or sessionDefaultSettings with them; everything else in the file, the user's entries included, is kept byte for byte. The picker offers the user's own custom models by the id droid gives them (its "id", else the displayName with whitespace as dashes and a count of the same name before it), including the legacy ~/.factory/config.json custom_models, which magpie never writes. Sync rewrites magpie's entries as providers change; Check reports a missing entry or a changed baseUrl/apiKey; its requests are Droid's in usage (User-Agent factory-cli/<version>). Icon is Factory's own favicon glyph (factory.ai/favicon.svg); lobehub has none. From the docs: docs.factory.ai/cli/byok/overview (customModels fields, the three providers, config.json legacy snake_case merged under settings.json), /cli/configuration/settings (model, sessionDefaultSettings.*), /droid-exec/overview (custom:<Display-Name>-<index>). Verified by reading the shipped droid 0.229.0 bundle (@factory/cli-linux-x64, unpacked, never installed or run): the zod schema of an entry (also id, index, maxContextLimit, enableThinking, reasoningEffort, bedrock-converse), ids as custom:${displayName.trim().replace(/\s+/g,"-")}-${n} with n counting equal names, an entry's own id winning, the lookup by id, top-level model/reasoningEffort/specModeModel moved into sessionDefaultSettings only when unset there, getModel reading sessionDefaultSettings.model, noImageSupport defaulting by provider, FACTORY_HOME_OVERRIDE, and BYOK requests carrying factory-cli/<version>. Tested in a sandbox HOME (internal/agent/droid_test.go): set/sync/reset on a settings.json as droid leaves it with a Groq BYOK model (its entry byte-identical, the file restored exactly), each protocol's provider and baseUrl, a moved baseUrl caught by Check and healed by Sync, picking the user's own model while on magpie's, no file at all, a top-level model, FACTORY_HOME_OVERRIDE and legacy config.json ids (custom:Local-Qwen-0/-1) offered and never written. go build -tags nogui (and GOOS=linux, GOOS=windows) and go test -tags nogui ./... pass (TestClaudeSignedOut and TestClaudeAccountNamedAsItsLogin flaked under load and pass alone). Not tried with a real droid: whether droid's /model lists the entries, that it reaches the gateway on each protocol, and how it sends thinking for a custom model (magpie sets no reasoningEffort/enableThinking) are unverified. 2026-09-30 02:35:59 +08:00