Commit Graph
7 Commits
Author SHA1 Message Date
Cato 186679c091 fix(runner): auth and quota failures are judged only on the run's own evidence (#1650)
* fix(runner): the auth canary fails a run only on that run's own evidence

A fresh solon tab on the cloud runner was failed as "claude is not
authenticated" because the newest Claude transcript in its folder was a
two-day-old session ending "Please run /login". A Grok run a minute later
was failed with the same text, telling the operator to set
CLAUDE_CODE_OAUTH_TOKEN, because the canary read Claude's folder for an
agent that never writes there. The runner's sign-ins were fine.

- Claude: a transcript last written before the prompt is not evidence.
- Other agents: read what the agent printed since the prompt, minus the
  prompt's own words; never Claude's transcripts.
- The error names the refused agent and its own fix.

* chore(runner): 0.8.66 with its release note: the auth canary reads only this run

* fix(runner): a quota wall is the agent's own answer, and a provider that answered since is not spent

At 05:41 Zurich a Solon brief about replacing a "rate limiter" whose
memory "resets on deploy" failed its run as "claude cannot generate
because its usage limit is exhausted", and Loki then offered Claude as
spent for an hour. Claude kept working for fourteen more minutes.

- Claude: a wall counts only when Claude's own transcript since the
  prompt holds an API error naming a limit. The screen echoes our brief.
- Other agents: the screen check also ignores an echo of the prompt
  whose spaces a TUI redraw dropped.
- spentProviders: newest run per provider decides; a run that finished
  successfully after the wall clears it. An open run proves nothing.
- Runner 0.8.67 (0.8.66 went to #1643).
2026-11-12 08:02:13 +01:00
CatoandClaude 5b0f93f117 feat(copy): the machine that runs the work is a runner, not a builder (#1482)
"Builder" meant three things on Loki's screens: the machine that runs
agent work ("Cloud builder", "Waiting for a builder"), the role on a
project, and the approved builder a customer books through Bitbaum. The
person keeps the word; the machine becomes a runner, the word the code
and the desktop app already use (box-runner, Fleet Runner, "Hosted
runner"). Not "engine": on screen that is already the model and
subscription a change is built with.

- every user-facing string where "builder" meant the machine, with
  EXECUTOR_COPY as the source, plus docs, quickstart, pricing and voice
- unchanged: the Builder role, "a builder or owner can start work",
  people who build ("App builders", "for one builder running Loki"),
  the site widget's "Send to builder" (the site's maker), stored
  transcript parsing, and internal codes and paths (needs-builder,
  cloud-builder-private, /api/builder/presence)
- tests that pin the wording follow it


Claude-Session: https://claude.ai/code/session_019MDtmw5m9WhdN77N2YeqDm

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-30 22:30:16 +01:00
CatoandClaude 331e5aa528 fix(watch): send work to an agent the builder has, and say a stop once (#1353)
A report filed from Loki's own page went to Grok on the cloud builder,
which only runs Claude Code. Watch then showed the refusal three times,
"Try again" (which fails the same way), empty future stages, "Grok
stopped" for an agent that never opened, "Done." filler, and the
report's technical details inside "You asked".

- Dispatch (Implement, kickoff, retry) routes around an agent the
  builder reported it does not have, and records why (reroutedWhy).
- A not-installed stop offers the installed agent as the one button.
- The reason and the buttons sit together in the card; the duplicate
  Loki message and "Stopped · N steps" line go when a track exists.
- The track ends at a failed stage; "could not start" when nothing opened.
- The user's bubble hides "--- technical details ---" behind Dispatch details.
- Reroute line says the true reason; an operator's own pick says nothing.


Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-20 18:16:39 +02:00
CatoandClaude Opus 5.5 82d886c936 fix(feedback): an agent that opened and never answered is routed around (#964)
* fix(feedback): an agent that opened and never answered is routed around

Petvity, 2026-09-28: a feedback run launched Claude, injected the prompt,
and Claude produced nothing ("could not verify generation … produced no
response"). Loki's automatic retry then went straight back to Claude and
failed identically a minute later. The runner's own message says the move
is "choose another AI provider and Retry"; Loki was not taking it, because
spentProviders only counted runs whose error named a limit.

- looksLikeAgentNoAnswer (agent-resolution.ts) is the one reading of
  "opened, took the prompt, never answered"; auto-reimplement-policy uses
  it instead of its own copy of the regex.
- spentProviders counts that silence as the provider being unable to
  answer inside the window, with its own reason ("opened but never
  answered"), so implementFeedback → routeAroundSpent sends the automatic
  retry (and a manual Retry) to the next provider in the operator's order.
  The chooser's suffix for either case reads "not answering".
- The row no longer says "It never reached an agent — check the builder is
  online" for this: it says "The agent opened but never answered — Retry
  runs it on the next provider."
- Tests: provider-switch (silent agent rerouted; an unrelated failure does
  not remove a provider), feedback-auto-reimplement, feedback-tour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsT2PtLuBKwgaaBU5pheG8

* chore(web): the session-start hook fetches release tags

Cloud sessions start from a shallow clone with no tags, so the pre-push
gate's desktop-release-drift check reported UNCHECKED and blocked every
push until someone ran `git fetch --tags` by hand. The hook now does it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsT2PtLuBKwgaaBU5pheG8

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-28 13:16:25 -07:00
Cato 05e9430646 feat(dispatch): Implement doesn't walk into an agent Loki just watched run out of quota (#909)
* wip: Implement routes around an agent Loki has seen run out

* test: routeAroundSpent, proved by mutation
2026-09-25 04:35:54 -07:00
CatoandClaude Opus 5 7cbdbf0db5 fix(providers): scope the installed list to the builder that would run it (#790)
Risk 2 of the 2026-09-17 review: /api/providers read
getRuntimeSnapshot(userId) — no channel.

That function's own doc says what the channel-less form returns:
"whichever channel pushed last". Both builders push their own row every
~5 minutes, so which machine's capability report the chooser saw was
decided by a race between two heartbeats. A cloud push could make a
laptop-only agent read "not installed"; a laptop push did the same to
the box. The chooser DISABLES rows on that evidence, so this was a
confident claim about a different computer.

The project already knows where it would dispatch —
pickDispatchChannel() is the SSOT for that decision — so now we ask that
channel. Without a project there is no "the" builder, so the honest
input is the union across this user's builders: an agent installed on
ANY of them is launchable somewhere, and only an agent no builder
reports is genuinely absent.

Unknown stays unknown. No row for a channel means null, not [] — the
three-state rule this module is already built on. Rendering silence as
"none installed" would disable every alternative, which is the one
control the operator came to that row for.

And the claim is now stamped. `evidence: { channel, observedAt }` rides
along, and the chooser says "Installed list as observed on This computer
(Fleet Runner), 4m ago" — or, when nothing has reported, that
availability here is unknown rather than empty. A capability claim with
no machine and no time reads as "true now, everywhere"; it is neither.

Lint caught a real defect mid-change: describeProviderEvidence took a
`now` it never used, because the phrasing comes from timeAgo(), which
reads the clock itself. A parameter the function ignores is worse than
none — it makes a test look deterministic when it isn't — so it is gone
rather than papered over with an underscore.

Tests: three cases, proved by mutation — disabling the unknown branch
fails "The input did not match /unknown, not empty/". tsc clean, lint 0
errors, test:unit 204/204.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 09:31:50 -07:00
CatoandClaude Opus 5 b71941be63 feat(providers): one-tap switch to a provider that still has quota (#757)
* feat(providers): one-tap switch to a provider that still has quota

When the agent building a project hits a rate limit, the way out already
existed — four other agent CLIs, most with untouched quota. Taking it was
the problem. The only chooser lived in the Terminal right rail, it offered
every agent in a fixed order whether or not the connected builder had it
installed, and taking it swapped the live PTY without recording the choice,
so the next dispatch went straight back to the agent that had just run out.

One ranking, three surfaces:

- src/lib/provider-switch.ts — the whole decision as pure functions. Ranks
  the operator's order, filters on two pieces of OBSERVED evidence (the
  builder's installed-agent report, and recent runs that died with capacity
  language), and holds the three-state rule provider_quota is built on: an
  agent nothing was reported about is unknown, and unknown reads as usable.
  Nothing is hidden — a provider that cannot answer still appears, disabled,
  saying why. 18 inline checks in scripts/test/provider-switch.ts.
- GET /api/providers — that ranking, once, for every surface. Accepts either
  the user_projects id or the entity id, because the Feedback row holds one
  and Control/Terminal hold the other.
- ProviderSwitch — "Try <next>" plus a menu of the rest, now the PRIMARY
  control on a Needs-you / Failed feedback row (Retry steps down beside it),
  in the Control inbox, and in the Terminal rail.

And it sticks: POST /api/feedback/<id>/dispatch takes an `agent`, records it
as the project's agentPref, then dispatches on it — no scavenger hunt through
project settings.

The order is the operator's, not the fleet's: user_preferences.agent_order
(migration 0072, nullable and additive) with a reorder list in Settings →
Agent. Null means "never stated", and the fleet default applies.

Two SSOT repairs the work ran into:
- AGENT_FALLBACK_ORDER was defined TWICE (agent-registry.ts and
  agent-resolution.ts) — the server reroute and the client reroute each read
  their own copy. agent-registry now re-exports the client-safe leaf.
- QUOTA_ALTERNATIVE_AGENTS is derived from that order instead of being a
  second hand-written list of the same five ids.
- TerminalRunView.alternatives is gone; quotaDeath stays as the flag that
  asks the shared chooser.

provider_quota is deliberately NOT an input: it meters the ai-kit inference
chain (groq, openrouter) behind Loki's own chat, not the agent CLIs. The
agent-CLI equivalent is the run evidence above — observed, never probed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(providers): never offer the agent the project would actually run on

Self-review caught a gap in the chooser's exclusion rule. It read "current"
straight off `user_projects.agent_pref`, so a project that has never had a
preference set reported no current agent at all — and dispatch does not work
that way. Such a project still runs, on DEFAULT_ADAPTER_ID, which means the
escape offered from a Claude Code rate limit could be Claude Code.

currentProviderFor() answers the question the exclusion is actually asking —
which agent just died — in the order the evidence deserves:

  1. what this project LAST RAN on (freshest run inside the window). A stored
     preference can be stale by one switch; a run is what happened.
  2. else its stored preference.
  3. else the fleet default, because that is what the next dispatch picks.

A run on an agent the chooser cannot offer (openclaw) is not "current" — it
falls through rather than excluding nothing.

Three more checks in scripts/test/provider-switch.ts, 21 total.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 00:59:08 -07:00