mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 16:47:38 +01:00
* feat(ops): agent-probe opens one agent CLI in a sealed container and prints what it says On 2026-11-12 the runner refused claude 16 times between 14:42 and 14:50 UTC and grok once at 15:21, "usage limit is exhausted", and kept no screen to show why. agent-probe (sealed-builds.yml, runs=<agent>) launches the agent as the runner does, with the credentials sandbox.ts passes through (names only), sends "Reply with the single word PONG" and prints the masked screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(ops): the PTY probe answers a modern TUI's terminal queries and its trust prompt grok drew nothing until the terminal answered its version query (ESC[>0q), and claude stopped at the trust prompt of the probe's new folder, so the first agent-probe runs (2026-11-12) never reached the composer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * feat(ops): agent-probe asks one headless turn before the interactive one grok draws nothing in the probe's terminal; a headless turn has no terminal to negotiate and prints a quota wall as plain text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi * fix(dispatch): a task nobody pinned to an agent does not walk into one Loki has just watched run out Live 2026-11-12: the orangecat project's agent was Grok, whose Grok Build balance was used up ("402 Payment Required: Grok Build usage balance exhausted", read with sealed-builds agent-probe), and every chat message to it failed in fifteen seconds while Claude Code on the same builder answered. Kickoff, Implement and the retry already route around a spent agent; the chat's path, injectPrompt with no agent pinned, did not. - lib/dispatch-agent-route: agentAvoidingSpent, the same providerChoiceFor + routeAroundSpent the kickoff uses; anything unreadable keeps the project's agent. Not a preference change. - inject-core: used only when the caller pinned no agent; a rerouted run records reroutedFrom/reroutedBecause for the Watch page; agentNotice in the body. - The chat's dispatch reply says which agent took the task and why. scripts/test/dispatch-agent-route.ts. Checkpoint updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmt4p1jMfJnbJtpeNhi --------- Co-authored-by: Claude <noreply@anthropic.com>
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
/**
|
|
* A task nobody pinned to an agent does not walk into one Loki has just
|
|
* watched run out (src/lib/dispatch-agent-route.ts).
|
|
*
|
|
* Live 2026-11-12: the orangecat project's agent was Grok, whose Grok Build
|
|
* balance was used up (402 Payment Required), and every chat message to it
|
|
* failed in fifteen seconds while Claude Code, on the same builder, answered.
|
|
* Kickoff, Implement and the retry already routed around a spent agent; the
|
|
* chat's path (injectPrompt with no adapter) did not.
|
|
*
|
|
* Run: npx tsx scripts/test/dispatch-agent-route.ts
|
|
*/
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { agentRerouteSentence } from "@/lib/agent-reroute";
|
|
import { routeAroundSpent } from "@/lib/provider-switch";
|
|
|
|
let passed = 0;
|
|
const t = (name: string, fn: () => void) => {
|
|
fn();
|
|
passed++;
|
|
console.log(` ✓ ${name}`);
|
|
};
|
|
console.log("dispatch-agent-route:");
|
|
|
|
t("the sentence names both agents and says the project's agent is unchanged", () => {
|
|
const s = agentRerouteSentence({ from: "grok", to: "claude", because: "x", why: "spent" });
|
|
assert.match(s, /Grok/);
|
|
assert.match(s, /Claude/);
|
|
assert.match(s, /unchanged/);
|
|
assert.match(s, /top up/);
|
|
});
|
|
|
|
t("a missing binary is said as such, not as a spent balance", () => {
|
|
const s = agentRerouteSentence({
|
|
from: "grok",
|
|
to: "claude",
|
|
because: "x",
|
|
why: "not-installed",
|
|
});
|
|
assert.match(s, /cannot start/);
|
|
assert.doesNotMatch(s, /run out/);
|
|
});
|
|
|
|
t("routeAroundSpent keeps the preferred agent when nothing says it is spent", () => {
|
|
const d = routeAroundSpent({ preferred: "grok", spent: {}, options: [] });
|
|
assert.equal(d.agent, "grok");
|
|
assert.equal(d.rerouted, null);
|
|
});
|
|
|
|
const core = readFileSync("src/lib/inject-core.ts", "utf8");
|
|
t("injectPrompt routes only when the caller pinned no agent", () => {
|
|
assert.match(core, /if \(!adapter\) \{\s*const routed = await agentAvoidingSpent\(/);
|
|
});
|
|
t("a rerouted run records where it came from, for the Watch page", () => {
|
|
assert.match(core, /reroutedFrom: r\.from/);
|
|
});
|
|
const chat = readFileSync("src/app/api/conversations/[id]/messages/route.ts", "utf8");
|
|
t("the chat's dispatch reply says which agent took the task", () => {
|
|
assert.match(chat, /inject\.body\.agentNotice/);
|
|
});
|
|
|
|
console.log(` ${passed} passed`);
|