Files
magpie/internal/agent/agy.go
T
yetone 99a54fa874 agent: agy's own /model pick no longer costs settings.json its model, and each thinking level is a model in agy (LolingVerse on X)
agy's /model writes its pick into settings.json ("model": "magpie/…")
even when started with --settings magpie-settings.json. The next Sync's
migrate took that for an older magpie's wiring and put back the old
stash: a stale model and "modelProvider": "gemini", or nothing, which
took the user's own model and provider out. That is the wrong restore
point the reporter saw. While magpie-settings.json is already on one of
magpie's models, such a pick is now moved into magpie's file (what agy
starts on next), and settings.json's model goes back to the one
connect.was kept when magpie was switched on, or out. The old stash is
no longer read for it.

agy 1.5.9 turns /effort away for every custom model, one with a
thinkingLevel too. A custom model's thinkingLevel takes low, medium or
high, and agy sends it as generationConfig.thinkingConfig.thinkingLevel,
which the gateway already asks over the row's effort (agyLevelAsked). A
model with two or more of those levels now has a custom model per
level, magpie/<ref>:<level>. The row's model field shows such a pick as
its model, so the switch stays on (agyLevelOf).

Run:
- TestAgyOwnPickKeepsSettings is red on the old agy.go. The levels part
  fails with "level low:". The pick part, with the levels cut out,
  fails with settings.json {"model":"stale","modelProvider":"gemini"}.
  It is green on the new code.
- go test -count=1 ./internal/agent ./internal/cli on mote: ok (agent 259s, cli 67s) at base 139a6be2b.
- GOOS=linux go vet ./internal/agent and GOOS=windows go vet of both packages (cli's Linux vet needs cgo for Wails on a Mac); gofmt -l is
  clean.
- Real agy 1.5.9 in a sandbox HOME against a fake Gemini endpoint:
  - /model lists magpie/openai/gpt-5.5:low/:medium/:high;
  - picking :high wrote settings.json "model" and sent
    thinkingLevel "HIGH" with model openai/gpt-5.5;
  - /effort still says "Effort isn't adjustable" for custom models.

Not tried: a real magpie gateway and account behind agy (the fake
endpoint stood in), and Windows or a WSL distro.

Not changed: the agent-agy plugin has the same two gaps
(magpie-community/plugins#1188). The switch turning itself off didn't
reproduce on the built-in or the plugin.
2026-11-15 23:19:21 +08:00

574 lines
23 KiB
Go

package agent
// Antigravity's CLI, agy, keeps its settings in
// ~/.gemini/antigravity-cli/settings.json. With "modelProvider": "gemini" it
// asks a Gemini API endpoint rather than Google's own backend, and lists the
// models of customModelsConfig.customModels, each {apiProvider, modelName},
// the one picked being "model". magpie's gateway speaks the Gemini API, so
// magpie adds one custom model per catalog model, keyed
// "magpie/<provider>/<model>", and sets modelProvider and model; the user's
// own are stashed and put back when magpie steps out. The endpoint and key
// agy takes only from its environment (GOOGLE_GEMINI_BASE_URL and
// GEMINI_API_KEY; no .env file), so magpie can't set them: the agent's row
// gives the command that starts agy with them (see Agent.Launch). That
// names the model with --model too: agy 1.2 asks for a custom model picked
// in settings.json or its /model picker with no model name ("model is
// empty"); only one given on the command line resolves.
//
// None of that is written to settings.json any more (baysonfox on X: with
// "modelProvider": "gemini" in it every agy runs on an API key, with no
// Google account, and remote control, which needs the sign-in, was gone;
// a plain agy asked for GEMINI_API_KEY too). The model, the provider and
// the custom models (the user's own and magpie's, since agy takes the key
// whole) are in a file of magpie's beside it, magpie-settings.json, which
// the launch hands agy as --settings for that one session. settings.json
// stays the user's, and a plain agy, and `agy remote-control` or
// --remote-control through the function, run on their Google sign-in.
//
// A model that takes two or more of low, medium and high is listed once
// more per level, "magpie/<ref>:<level>" with that thinkingLevel, the
// thinking depth picked in agy's /model (agyLevels).
//
// So that typing agy just works (bestony on Discord: the command was
// copied at each start), magpie puts a function named agy in the profile
// of each shell the user has, between "# >>> magpie agy >>>" and
// "# <<< magpie agy <<<" (update.ShellFunction), while agy is on one of
// magpie's models. It runs `magpie agy run`, which starts the real agy
// with the two variables and --model when settings.json's model is still
// magpie's and as it is otherwise (cli/agy_cli.go); PowerShell's asks
// `magpie agy env` for them, since the app it would run is a GUI program
// PowerShell doesn't wait for. A terminal open before takes the command
// from the row.
import (
"encoding/json"
"os"
"path"
"path/filepath"
"runtime"
"slices"
"sort"
"strings"
"github.com/tidwall/gjson"
"github.com/tidwall/jsonc"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/gateway"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/update"
)
const agyModels = "customModelsConfig.customModels"
// AgyLaunch is the command that starts agy on magpie's gateway and one of
// its custom models, in the shell of this system. Its key names agy: its
// requests go out as Google's Gemini SDK's (User-Agent google-genai-sdk/…),
// with nothing of agy's own, so the gateway knows them by the key
// (x-goog-api-key) alone. A command copied before, with the plain token,
// still reaches magpie.
func AgyLaunch(model string) string {
return agyLaunchAt(gateway.URL(), agentKey("agy"), agySettingsFile(), model, runtime.GOOS == "windows")
}
// agyOverride is the name of magpie's settings file in agy's folder.
const agyOverride = "magpie-settings.json"
// agySettingsFile is magpie's settings file for agy on this machine.
func agySettingsFile() string {
home, _ := homes()
return filepath.Join(home, ".gemini", "antigravity-cli", agyOverride)
}
// agyPlain are what ask agy for its remote control, which only a Google
// sign-in has, never an API key's session: agy runs plain with one of
// them (alone or with "=value").
var agyPlain = []string{"remote-control", "--remote-control", "-remote-control"}
// agyLaunchAt is AgyLaunch for agy reaching the gateway at gw with key and
// magpie's settings file, in PowerShell or a POSIX shell.
func agyLaunchAt(gw, key, settings, model string, powershell bool) string {
if powershell {
return `$env:GEMINI_API_KEY="` + key + `"; $env:GOOGLE_GEMINI_BASE_URL="` + gw + `"; agy --settings '` + strings.ReplaceAll(settings, "'", "''") + `' --model '` + strings.ReplaceAll(model, "'", "''") + `'`
}
return "GEMINI_API_KEY=" + key + " GOOGLE_GEMINI_BASE_URL=" + gw + " agy --settings '" + strings.ReplaceAll(settings, "'", `'\''`) + "' --model '" + strings.ReplaceAll(model, "'", `'\''`) + "'"
}
// agyShell gives the user's shells the function agy, or takes it out of
// them; only for agy on this machine. What fails leaves the setting as it
// is: the row's command still starts it.
func agyShell(home string, on bool) {
if here, _ := homes(); here != home {
return
}
if on {
update.ShellFunction("agy", agyFunction)
} else {
update.DropShellFunction("agy")
}
}
// agyFunction is the function agy in a shell of kind, which runs prog
// (this magpie) to start it; the agy on PATH when prog is gone.
func agyFunction(kind, prog string) string {
switch kind {
case "fish":
q := "'" + strings.NewReplacer(`\`, `\\`, "'", `\'`).Replace(prog) + "'"
return "function agy\n if test -x " + q + "\n " + q + " agy run $argv\n else\n command agy $argv\n end\nend"
case "powershell":
q := "'" + strings.ReplaceAll(prog, "'", "''") + "'"
return `function agy {
$real = Get-Command agy -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $real) { Write-Error 'agy is not installed'; return }
$start = @{}
if (Test-Path -LiteralPath ` + q + `) {
foreach ($l in @(& ` + q + ` agy env)) { $k, $v = "$l" -split '=', 2; if ($v) { $start[$k] = $v } }
}
if (-not $start.model -or @($args | Where-Object { "$_" -match '^--?(remote-control)(=|$)|^remote-control$' }).Count) { & $real @args; return }
$was = $env:GEMINI_API_KEY, $env:GOOGLE_GEMINI_BASE_URL
$env:GEMINI_API_KEY = $start.GEMINI_API_KEY; $env:GOOGLE_GEMINI_BASE_URL = $start.GOOGLE_GEMINI_BASE_URL
try {
if (@($args | Where-Object { "$_" -match '^--?model(=|$)' }).Count) { & $real --settings $start.settings @args } else { & $real --settings $start.settings --model $start.model @args }
} finally { $env:GEMINI_API_KEY = $was[0]; $env:GOOGLE_GEMINI_BASE_URL = $was[1] }
}`
}
q := "'" + strings.ReplaceAll(prog, "'", `'\''`) + "'"
return agyPosixHead + " if [ -x " + q + " ]; then " + q + ` agy run "$@"; else command agy "$@"; fi` + "\n}"
}
// agyPosixHead opens the function agy in a POSIX shell's profile. It is
// "agy() {", not bash's "function agy {", which dash refuses: a ~/.profile
// that reads ~/.bashrc is read by sh -lc too, as Debian's dash (ljlwlcz on
// X: fnOS, where an SSH probe's sh -lc failed on it). An alias named agy
// would be expanded in "agy()", so it is taken out first, on a line of its
// own, since a shell expands aliases a line at a time.
const agyPosixHead = "unalias agy 2>/dev/null || true\nagy() {\n"
// agyDistroProfiles are the profiles of a WSL distro's shells the
// function goes in, as magpie opens them: bash's ~/.bashrc (which the
// ~/.profile of a login bash reads on Debian and Ubuntu), zsh's ~/.zshrc
// and fish's config.fish, each where it is already, and the one of the
// user's login shell in the distro's /etc/passwd (bash when it says
// nothing) made where it isn't, as fish's is where ~/.config/fish is. The
// distro's ZDOTDIR and XDG_CONFIG_HOME aren't read.
func agyDistroProfiles(at place) []update.ShellProfile {
login := distroLoginShell(at)
fish := at.join(".config", "fish", "config.fish")
return []update.ShellProfile{
{Kind: "posix", Path: at.join(".bashrc"), Create: login == "bash"},
{Kind: "posix", Path: at.join(".zshrc"), Create: login == "zsh"},
{Kind: "fish", Path: fish, Create: login == "fish" || at.isDir(filepath.Dir(fish))},
}
}
// distroLoginShell is the name of the login shell /etc/passwd gives the
// distro's user, the one whose home is at's; "bash" when it can't say.
func distroLoginShell(at place) string {
if at.sys == nil {
return "bash"
}
b, err := os.ReadFile(at.sys("/etc/passwd"))
if err != nil {
return "bash"
}
home := at.native(at.home)
for _, l := range strings.Split(string(b), "\n") {
f := strings.Split(strings.TrimRight(l, "\r"), ":")
if len(f) >= 7 && f[5] == home && f[6] != "" {
return path.Base(f[6])
}
}
return "bash"
}
// agyDistroModel is the sed script that prints magpie's settings file's
// model, for the function in a distro, where no magpie runs to read it.
// Its model is a line of its own as magpie writes the file; one written on
// a single line is found too, so long as nothing after it is named
// "model".
const agyDistroModel = `s|^.*"model"[[:space:]]*:[[:space:]]*"\(` + magpieID + `/[^"]*\)".*$|\1|p`
// agyDistroFunction is the function agy in a distro's shell of kind:
// while settings.json's model is magpie's, the agy on PATH started with
// the gateway at gw, its key and --model (none when one is given), as
// `magpie agy run` does on this machine; as it is otherwise.
func agyDistroFunction(kind, key, gw string) string {
q := func(v string) string { return "'" + strings.ReplaceAll(v, "'", `'\''`) + "'" }
settings := `"$HOME/.gemini/antigravity-cli/` + agyOverride + `"`
if kind == "fish" {
fq := func(v string) string { return "'" + strings.NewReplacer(`\`, `\\`, "'", `\'`).Replace(v) + "'" }
return "function agy\n" +
" set -l m (sed -n " + fq(agyDistroModel) + " " + settings + " 2>/dev/null | head -n 1)\n" +
" if test -z \"$m\"\n command agy $argv\n return\n end\n" +
" for a in $argv\n switch $a\n case 'remote-control' '--remote-control' '-remote-control' '--remote-control=*'\n command agy $argv\n return\n end\n end\n" +
" for a in $argv\n switch $a\n case '--model' '--model=*' '-model' '-model=*'\n set m ''\n end\n end\n" +
" if test -n \"$m\"\n set argv --model $m $argv\n end\n" +
" set argv --settings " + settings + " $argv\n" +
" env GEMINI_API_KEY=" + fq(key) + " GOOGLE_GEMINI_BASE_URL=" + fq(gw) + " agy $argv\nend"
}
return agyPosixHead +
" local m a\n" +
" m=$(sed -n " + q(agyDistroModel) + " " + settings + " 2>/dev/null | head -n 1)\n" +
` if [ -z "$m" ]; then command agy "$@"; return; fi` + "\n" +
` for a in "$@"; do case "$a" in remote-control|--remote-control|--remote-control=*|-remote-control) command agy "$@"; return;; esac; done` + "\n" +
` for a in "$@"; do case "$a" in --model|--model=*|-model|-model=*) m=;; esac; done` + "\n" +
` if [ -n "$m" ]; then set -- --model "$m" "$@"; fi` + "\n" +
" set -- --settings " + settings + ` "$@"` + "\n" +
" GEMINI_API_KEY=" + q(key) + " GOOGLE_GEMINI_BASE_URL=" + q(gw) + ` command agy "$@"` + "\n}"
}
// agyCustom reads customModels as it is, raw JSON by key.
func agyCustom(path string) map[string]json.RawMessage {
out := map[string]json.RawMessage{}
raw, err := edit.Read(path)
if err != nil || len(raw) == 0 {
return out
}
gjson.GetBytes(jsonc.ToJSONInPlace(raw), agyModels).ForEach(func(k, v gjson.Result) bool {
out[k.String()] = json.RawMessage(v.Raw)
return true
})
return out
}
func agy(home string) *Agent { return agyIn(here(home)) }
// agyIn is agy at a place: this machine's home, or a WSL distro's, whose
// shells get a function of their own (agyDistroFunction).
func agyIn(at place) *Agent {
home := at.home
dir := at.open(filepath.Join(home, ".gemini", "antigravity-cli"))
path := filepath.Join(dir, "settings.json")
over := filepath.Join(dir, agyOverride)
settingsModel, overModel := jsonGet(path, "model"), jsonGet(over, "model")
provider := jsonGet(over, "modelProvider")
// the model is magpie's while its own file names one; a settings.json
// still wired by an older magpie says so too, until migrate moves it.
// It is the custom model's key, a level's (agyLevelKey) too.
get := func() string {
if m := overModel(); usesMagpie(m) {
return m
}
return settingsModel()
}
stashModel, stashProvider := "agy:"+path+":model", "agy:"+path+":modelProvider"
// put sets key to v, or takes it out for ""
put := func(key, v string) error {
if v == "" {
return edit.DelJSON(path, key)
}
return edit.SetJSON(path, edit.KV{Path: key, Value: v})
}
// ownModels is the user's own custom models, as settings.json has them
ownModels := func() map[string]any {
ms := map[string]any{}
for k, v := range agyCustom(path) {
if !strings.HasPrefix(k, magpieID+"/") {
ms[k] = v
}
}
return ms
}
// writeOver writes magpie's settings file: the provider, the model and
// every custom model, the user's own too, as agy takes the key whole
writeOver := func(model string) error {
ms := ownModels()
for _, m := range sharedModels("agy") {
ms[magpieID+"/"+m.ID] = map[string]string{"apiProvider": "API_PROVIDER_GOOGLE_GEMINI", "modelName": m.ID}
for _, l := range agyLevels(m.Efforts) {
ms[agyLevelKey(magpieID+"/"+m.ID, l)] = map[string]string{"apiProvider": "API_PROVIDER_GOOGLE_GEMINI", "modelName": m.ID, "thinkingLevel": l}
}
}
if err := os.MkdirAll(dir, 0o755); err != nil {
return err
}
return edit.SetJSON(over, edit.KV{Path: "modelProvider", Value: "gemini"}, edit.KV{Path: "model", Value: model}, edit.KV{Path: agyModels, Value: ms})
}
dropOver := func() error {
if err := os.Remove(over); err != nil && !os.IsNotExist(err) {
return err
}
return nil
}
// migrate takes what an older magpie wrote into settings.json out of
// it, the user's model and provider back; it returns the model that
// was magpie's there, "" when settings.json was never wired.
//
// While magpie's own file is on one of magpie's, a model of magpie's
// in settings.json is not an older magpie's: it is agy's /model, which
// writes the pick into settings.json, --settings or not. That pick is
// kept in magpie's file (it is what agy starts on next) and
// settings.json's model goes back to what it was when magpie was
// switched on (connect.was), or out of it. The old stash is never read
// for it: one left from an older magpie, or none, put a stale model and
// provider into settings.json or took the user's out of it
// (LolingVerse on X).
migrate := func() (string, error) {
m := settingsModel()
if !usesMagpie(m) {
return "", nil
}
if usesMagpie(overModel()) {
return m, put("model", agyConnectWas())
}
if err := put("modelProvider", unstash(stashProvider)); err != nil {
return m, err
}
if err := put("model", unstash(stashModel)); err != nil {
return m, err
}
if ms := ownModels(); len(ms) > 0 {
return m, edit.SetJSON(path, edit.KV{Path: agyModels, Value: ms})
}
if err := edit.DelJSON(path, agyModels); err != nil {
return m, err
}
if v, ok := edit.GetJSON(path, "customModelsConfig"); ok && strings.TrimSpace(v) == "{}" {
return m, edit.DelJSON(path, "customModelsConfig")
}
return m, nil
}
// the function agy, in this machine's shells or the distro's
distro := at.sys != nil
gw, key := at.gw, func() string { return agentKeyAt("agy", at.gw()) }
shell := func(on bool) {
if !distro {
agyShell(home, on)
return
}
if on {
k, g := key(), gw()
update.ShellFunctionAt(agyDistroProfiles(at), "agy", func(kind string) string { return agyDistroFunction(kind, k, g) })
} else {
update.DropShellFunctionAt(agyDistroProfiles(at), "agy")
}
}
shellIn := func() []string {
if !distro {
return update.ShellFunctionIn("agy")
}
return update.ShellFunctionInAt(agyDistroProfiles(at), "agy")
}
launch := func(model string) string {
if !distro {
return AgyLaunch(model)
}
return agyLaunchAt(gw(), key(), strings.TrimRight(filepath.ToSlash(home), "/")+"/.gemini/antigravity-cli/"+agyOverride, model, false)
}
return &Agent{
ID: "agy", Name: "Antigravity CLI", Icon: "antigravity-color", Aliases: []string{"antigravity-cli"}, Spelled: prefixed, NoNames: true,
Bin: "agy", Dir: dir, Path: path,
Launch: func() string {
if v := get(); usesMagpie(v) {
return launch(v)
}
return ""
},
Typed: func() string {
if !usesMagpie(get()) || len(shellIn()) == 0 {
return ""
}
return "agy"
},
Start: func() Starting {
s := Starting{Bin: "agy", Flag: "--model", Plain: agyPlain}
if v := overModel(); usesMagpie(v) {
s.Env, s.Model = []string{"GEMINI_API_KEY=" + key(), "GOOGLE_GEMINI_BASE_URL=" + gw()}, v
s.Args = []string{"--settings", at.native(over)}
}
return s
},
Sync: func() error {
m, err := migrate()
if err != nil {
return err
}
if m == "" {
m = overModel()
}
on := usesMagpie(m)
shell(on)
if !on {
return nil
}
return writeOver(m)
},
Notice: func() string {
v := get()
if !usesMagpie(v) {
return ""
}
if in := shellIn(); len(in) > 0 {
for i := range in {
if distro {
in[i] = at.native(in[i])
} else {
in[i] = update.TildeHome(in[i])
}
}
return noticeAgyTyped.say("profiles", strings.Join(in, ", "), "command", launch(v))
}
return noticeAgy.say("command", launch(v))
},
Check: func() string {
v := get()
if !usesMagpie(v) {
return ""
}
if _, ok := agyCustom(over)[v]; !ok {
return "Antigravity CLI's custom model " + v + " (" + agyOverride + ") is gone, so it no longer reaches magpie"
}
if p := provider(); p != "gemini" {
return "Antigravity CLI's modelProvider (" + agyOverride + ") is " + orDefault(p) + ", not gemini, so it asks Google directly"
}
// a distro's function names the gateway's address: one WSL
// changed on a restart (NAT) no longer reaches it
if distro {
for _, p := range shellIn() {
if b, err := os.ReadFile(p); err == nil && !strings.Contains(string(b), "GOOGLE_GEMINI_BASE_URL='"+gw()+"'") {
return "Antigravity CLI's function agy in " + at.native(p) + " names magpie at an address it no longer has"
}
}
}
return ""
},
Fields: []Field{{
Key: "model", Label: "model",
// a level's custom model is its model's, the level agy's
Get: func() string { return agyLevelOf(get()) },
Set: func(v string) error {
if _, err := migrate(); err != nil {
return err
}
cur := overModel()
if ref, ok := strings.CutPrefix(agyLevelOf(v), magpieID+"/"); ok && isMagpie(ref) {
if err := writeOver(v); err != nil {
return err
}
shell(true)
return nil
}
// back to the user's own: settings.json was never touched
if usesMagpie(cur) {
if err := dropOver(); err != nil {
return err
}
shell(false)
}
if v == "" {
return nil
}
return put("model", v)
},
Options: func(cur map[string]string) []Option {
custom := agyCustom(path)
// its own say they go to their provider, not through magpie,
// as every agent's own do (EZN7L2C3, #834)
var own []Option
for k := range custom {
if !strings.HasPrefix(k, magpieID+"/") {
to := "Google"
if p := gjson.GetBytes(custom[k], "apiProvider").String(); strings.Contains(p, "ANTHROPIC") {
to = "Anthropic"
} else if strings.Contains(p, "OPENAI") {
to = "OpenAI"
}
own = append(own, Option{Value: k, Icon: modelIcon("", gjson.GetBytes(custom[k], "modelName").String()), Direct: to})
}
}
sort.Slice(own, func(i, j int) bool { return own[i].Value < own[j].Value })
if c := cur["model"]; c != "" && !usesMagpie(c) && custom[c] == nil {
own = append([]Option{{Value: c, Icon: modelIcon("", c), Direct: "Google"}}, own...)
}
return withVia(group("Antigravity CLI", own), "agy", magpieID+"/")
},
}, agyEffortField(func() bool { return !at.cold && usesMagpie(get()) })},
}
}
// agyLevelNames are the levels a custom model of agy's takes as its
// thinkingLevel, weakest first: agy 1.5.9 takes low, medium and high
// ("customModels %q: ignoring thinkingLevel %q (want low, medium, or
// high)") and asks the model at it (generationConfig.thinkingConfig.
// thinkingLevel), which the gateway asks for over the row's
// (agyLevelAsked).
var agyLevelNames = []string{"low", "medium", "high"}
// agyLevels are the levels of efforts agy's custom models can ask, weakest
// first: none unless two or more, as one is no choice.
func agyLevels(efforts []string) []string {
var out []string
for _, l := range agyLevelNames {
if slices.ContainsFunc(efforts, func(e string) bool { return strings.EqualFold(e, l) }) {
out = append(out, l)
}
}
if len(out) < 2 {
return nil
}
return out
}
// agyLevelKey is the key of the custom model that asks key's model at
// level. agy's /effort is turned away for every custom model, one with a
// thinkingLevel too ("Effort isn't adjustable for …", agy 1.5.9), and its
// /model lists custom models by key, so each level is one of its own
// there (LolingVerse on X: no thinking depth in agy).
func agyLevelKey(key, level string) string { return key + ":" + level }
// agyLevelOf is the key of the model a level's custom model asks: key
// without its level; key as it is otherwise.
func agyLevelOf(key string) string {
i := strings.LastIndex(key, ":")
if i < 0 || !slices.Contains(agyLevelNames, key[i+1:]) || !usesMagpie(key) {
return key
}
return key[:i]
}
// agyConnectWas is the model agy was on when magpie was switched on for
// it, when it was the user's own; "" otherwise.
func agyConnectWas() string {
var was map[string]string
json.Unmarshal([]byte(unstashPeek("agy.connect.was")), &was)
if m := was["model"]; !usesMagpie(m) {
return m
}
return ""
}
// agyEffortField is effortField for agy.
func agyEffortField(on func() bool) Field { return effortField("agy", on) }
// effortField is how hard agy's models reason, picked in its row. agy
// 1.5 has --effort (low, medium, high) and /effort for one session only;
// /effort is turned away for magpie's models ("not adjustable", xyenon on
// Discord) and works on the Google names agy knows, and either one's level
// goes over the row's (agyLevelAsked). settings.json has no key for it
// (--settings: unknown setting "effort"). Its request asks
// thinkingBudget -1, the model's own choice. The gateway asks its
// requests for the level picked here (provider.AgentEffort), as the
// model takes it (withGeminiEffort); with none they go as agy asks.
// Shown only while agy is on magpie's models, and never read at a
// stopped distro (#3896). An agent a plugin adds that says effort has
// one as well, under its id.
func effortField(id string, on func() bool) Field {
return Field{
Key: "effort", Label: "effort",
Get: func() string { return provider.AgentEffort(id) },
Set: func(v string) error { return provider.SetAgentEffort(id, v) },
Options: func(map[string]string) []Option {
if !on() {
return nil
}
return pickedEfforts(id)
},
}
}
// what agy says after a change (notice.go)
var (
noticeAgy = newNotice("agy takes magpie's gateway and model only from how it is started — start it with {command}")
noticeAgyTyped = newNotice("Type agy in a new terminal: magpie added it to {profiles}, to start agy on magpie's gateway and model (in a terminal open now: {command}).")
)