Commit Graph
1 Commits
Author SHA1 Message Date
yetone 814a5ed73c agent: dsh asks each of magpie's models on its own API, a route per protocol (01huadalang on Discord)
dsh's llm-pi-ai sets one api for a whole route, so magpie's single
"magpie" route asked every model over Chat Completions. A GPT served on
Responses, or a Claude served on Messages, was translated from Chat, and
its sealed reasoning was lost between tool calls. 01huadalang asked for a
group per protocol.

What changed:
- dshPutRoute writes up to three routes from each model's catalog APIs
  (dshRouteOf): magpie (openai-completions, as before, for Chat models,
  Gemini-native ones, groups and agent-bridged sign-ins),
  magpie-responses (openai-responses, gateway /v1) and magpie-anthropic
  (anthropic-messages, the gateway root, forceAdaptiveThinking where
  gateway.AdaptiveThinking). A route left with no models is taken out.
  An api the user picked for a route in dsh's Models page is kept, and so
  are keys they added to it.
- The start (agent-default-model) names its model's route on a pick, an
  effort change, and the home layer's mirror. Sync moves a start on one of
  magpie's routes to the route its model is now on (dshStartOnItsRoute),
  keeping its mark, effort and other keys. A start on the user's own
  route stays.
- dshCheck checks each route's baseURL against its own api, and asks the
  route the start names to list its model.
- Disconnect, dshOurs, dshKeepPick and dshFillNewProfiles know all three
  routes. sessions' dshGatewayProvider counts dsh sessions on any of
  them as magpie's.
- docs/subsystems/agent-wiring.md: a line on the routes.

Known limit: a dsh session resumed on a model that has since moved
routes asks for the model to be picked again once, since dsh finds a
model by route and id.

Run:
- go test -tags nogui ./internal/agent (whole package, default order)
  and ./internal/sessions -run TestDsh: pass. New tests
  TestDshRoutesAModelOnItsNativeAPI,
  TestDshSyncMovesAStartToItsModelsRoute,
  TestDshCheckSaysAStartOnAnotherRoutesModel and
  TestDshGatewayProviderTakesEveryRouteOfMagpies. With dshRouteOf forced
  back to the single route, the three agent tests go red.
- Real dsh (headless, sandbox HOME and DSH_HOME) on patches magpie wrote,
  pointed at a fake gateway: the start on magpie answered from
  /v1/chat/completions, the one on magpie-responses from /v1/responses
  (reasoning.effort high), and the one on magpie-anthropic sent
  /v1/messages with thinking adaptive and output_config.effort high. dsh
  accepted all three routes. Its Anthropic turn then ended on my fake's
  SSE, not on the wiring.
- gofmt -l clean. go vet -tags nogui for darwin, GOOS=linux and
  GOOS=windows on internal/agent and internal/sessions.
2026-10-11 04:52:26 +08:00