# Observations

## Open

- Host tests fail under Homebrew `node` (26.x): `better-sqlite3` native module is compiled for the service's Node 22. Run `PATH=/opt/homebrew/opt/node@22/bin:$PATH pnpm test`.
- Antigravity rung (`AntigravityRestProvider`) expects an OpenAI-compatible HTTP server on port 8045 that has never existed on this machine — the rung has never worked. `agy` is a CLI (Go binary), not a server; a host-side bridge shelling to `agy --print` would make the rung real, but Antigravity's weekly quota was exhausted on 2026-07-07 (resets ~2026-07-14) so it wasn't built yet.
- `agy --print` exits 0 with EMPTY stdout when quota is exhausted (RESOURCE_EXHAUSTED only visible via `--log-file`) — any future bridge must treat empty output as failure, not success.

## Closed

- `SqliteError: attempt to write a readonly database` in delivery poll — fixed in 349ed2e (2026-07-26): root cause was `writeOutboundDirect` opening outbound.db with the readonly opener then attempting an INSERT; switched to `openOutboundDbRw`. Also isolated per-session errors in `pollActive`/`pollSweep` so one session's failure doesn't block others.
- Recurring `Killing container past absolute ceiling` false-positive kills for sessions with active Agent sub-agents — fixed in 0ac74eb (2026-07-25): `decideStuckAction()` in `host-sweep.ts` now exempts non-Bash tools (e.g. `Agent`) from the ceiling kill when `tool_started_at < NON_BASH_TOOL_CEILING_MS` (90 min); heartbeat staleness during sub-agent execution is expected, not a fault. `NON_BASH_TOOL_CEILING_MS` exported; two new tests added (ok + kill-ceiling paths). Tests must run on Mac Studio (`pnpm test`).
- `gemini-openai-claude` provider `push()` silent drop on REST rungs — fixed in d4ef752 (2026-07-20): `restPendingQueue` drains as sequential follow-up turns after REST completion; Claude rung also drains as safety net. 135/135 tests pass; awaiting Studio deploy.
- Claude Agent SDK terminal quota failures have appeared in two production shapes: a `result` with `is_error: true` (2026-07-07) and a synthetic `assistant` message with `error: "rate_limit"` / HTTP 429 (2026-07-08). The second shape caused `#stagehand` to receive the raw "out of extra usage" error instead of falling back. Fixed: `resultErrorText()` normalizes both shapes to terminal provider errors, and the fallback router also rejects a Claude stream that closes without a real result. Covered by the production-shaped test in `claude.test.ts` and the no-result/fallback cases in `gemini-openai-claude.test.ts`.
- `~/.config/nanoclaw/mount-allowlist.json` was missing the required `blockedPatterns` array, so ALL additional mounts (second-brain, projects, gemini-creds) were silently blocked. Fixed 2026-07-07 by adding `"blockedPatterns": []`.
- REST fallback rungs (LM Studio especially) silently dropped replies: local models answered with only `<internal>…</internal>` (no `<message to=…>` block), `dispatchResultText` discarded it as scratchpad, and the poll-loop nudge can't reach REST rungs (`push()` is Claude-only). Fixed 2026-07-07: the provider now retries once with a corrective instruction and, failing that, force-wraps the visible/internal text in a `<message>` block addressed to the prompt's last `from=` destination. Covered by `gemini-openai-claude.test.ts` tests 8–12; verified live against LM Studio + qwen.
- Containers could never use the Claude Pro subscription: OneCLI's gateway env ships `ANTHROPIC_API_KEY=placeholder` + HTTPS_PROXY and injects the vault's (depleted) API key on the wire. Fixed 2026-07-07: `resolveClaudeAuthEnv` in `container/agent-runner/src/providers/claude.ts` strips the API-key vars and NO_PROXYs `api.anthropic.com` when `CLAUDE_CODE_OAUTH_TOKEN` is set; host passes the token through in `src/providers/gemini-openai-claude.ts`. Token created and added to `.env` 2026-07-07 (valid 1 year); verified live — container session read a file and delivered a Telegram reply via claude-sonnet-4-6 on the subscription.

## Notes

- LM Studio (port 1234) is the local fallback rung; `LM_STUDIO_MODEL=qwen/qwen3.6-27b` set in `.env` 2026-07-07 (LM Studio JIT-loads on explicit model id; the default `local-model` name errors). It runs before Claude for plain chat, but remains the last rung for tool-shaped work because it has no tool access.
- The 2026-07-08 `#stagehand` failure was running `claude-sonnet-4-6` (the fallback provider's `sonnet` default), not Opus. Active routing is documented in `docs/provider-routing-plan.md`: tool work uses Codex → Claude → LM Studio; plain chat uses Codex → LM Studio → Claude. Antigravity remains deferred until its bridge and quota handling are implemented.
