fix(grok): unbreak workspace-cwd agents, free trapped agents, stop self-PR review

Three bugs surfaced by the first live Grok lifecycle run:

- Dev/QA/doc agents crash-looped at startup with ModuleNotFoundError on
  roboco.llm.providers. The entrypoint ran the opencode-config render from the
  agent's workspace-clone cwd, whose own roboco/ dir shadows /app on the
  sys.path front; a branch without the grok code lacks the providers package.
  Render from /app so the installed package always resolves (the render has no
  cwd dependency — writes global, reads ROBOCO_MCP_CONFIG).

- A budget/loop halt blocked EVERY tool, including i_am_idle, unclaim, and
  i_am_blocked, so a halted agent could neither continue nor stop and flailed —
  one billed model turn per blocked retry. The before-gate now always lets the
  release verbs through so a halted agent can exit cleanly.

- The inbound reviewer ingested the org's OWN PRs (authored by the repo-owner
  account), which can't take a REQUEST_CHANGES review (GitHub 422) and get
  re-reviewed every poll. The normalizer flags author_is_owner and ingestion
  skips them — the reviewer reviews only PRs the org did not author.
  External/contributor PRs are unaffected.

Tests: owner-authored PR flagged + skipped; normalize shape covers the new
field. Gate green on the changed modules (ruff/mypy/xenon + 48 tests).
This commit is contained in:
Renn F
2026-06-19 00:44:42 +02:00
parent 059dc91a4f
commit d1d1b638ae
6 changed files with 71 additions and 2 deletions
+9
View File
@@ -81,12 +81,21 @@ function bareVerb(tool) {
return tool;
}
// Release/escape verbs must ALWAYS be allowed through the before-gate. A halt
// (budget, loop, or fail-closed) that also blocks these traps the agent: it can
// neither continue nor stop, so it flails — and every blocked retry is another
// billed model turn. Letting i_am_idle / unclaim / i_am_blocked through is the
// only way a halted agent can exit cleanly.
const RELEASE_VERBS = new Set(["i_am_idle", "unclaim", "i_am_blocked"]);
// Named export (opencode's plugin convention) + baked into the plugin
// auto-discovery dir (~/.config/opencode/plugin/) at image build — the simplest
// registration route (no config `plugin:` path needed).
export const RobocoBudgetFeed = async () => {
return {
"tool.execute.before": async (input) => {
// Escape hatches always pass — a halted agent must be able to stop.
if (RELEASE_VERBS.has(bareVerb(String(input?.tool || "")))) return;
const status = await sdk("GET", "/budget/status", null);
if (!status) {
// One-shot delivery agents MUST have the in-container SDK budget server
+6 -1
View File
@@ -15,7 +15,12 @@ SDK_URL="http://localhost:${SDK_PORT}"
# Generate opencode.json (provider + model + MCP gateway + permissions +
# instructions). Writes to opencode's global config dir by default.
python -m roboco.llm.providers.opencode_config
# Run from /app so `python -m` resolves the INSTALLED roboco package. Dev/doc/qa
# agents run at their workspace-clone cwd, which has its own `roboco/` dir on the
# sys.path front (python -m prepends cwd); on a branch without the grok code that
# clone lacks roboco.llm.providers and shadows /app → ModuleNotFoundError. The
# config render has no cwd dependency (writes global, reads ROBOCO_MCP_CONFIG).
( cd /app && python -m roboco.llm.providers.opencode_config )
# --- SDK server bring-up (Claude-parity) ----------------------------------
# The flow/do MCP servers POST /verb/attempted here for the per-verb circuit