Repository navigation
Description
Context
PR #9402 fixed an incident where a desktop surface configured for managed piMono routing launched local Claude ACP from a background control path. The local process read a stale local Keychain credential and returned a provider 401. Omi Firebase auth was healthy; this was a cloud-to-local routing regression.
The PR also found related failures:
- Managed control paths originally rejected only ACP, leaving local Hermes/OpenClaw overrides possible.
- A background worker could try to fan out another agent; failed control calls could still end as a green parent Done.
- Explicit User Claude OAuth needs strict URL validation and retry-safe browser-launch behavior.
The current PR contains containment fixes. This issue is the durable design follow-up so future adapters and control tools cannot recreate the class.
Confirmed product decisions
- Managed Pi and any managed Claude fallback use Omi backend/cloud provider credentials. The desktop Firebase token authorizes Omi services only; it is not a local provider credential.
- Local provider adapters are allowed only when the owning desktop surface explicitly selected that local-user mode.
- A managed surface must fail closed for an unknown or locally credentialed adapter override.
- Background, delegated, and floating-pill workers are leaf workers. They may complete their assigned objective but cannot create more agents.
- A required agent-control operation that ultimately fails must not yield a green terminal completion.
Scope
-
Replace string-specific routing checks with one declarative adapter trust/credential-scope registry.
- Every registered production adapter declares managed_cloud or local_user.
- New adapters cannot register without a scope declaration.
- Managed control paths allow only managed_cloud adapters.
- Apply the policy to spawn_background_agent, spawn_agent, run_agent_and_wait, and send_agent_message.
-
Project agent-control capabilities by execution role.
- Leaf-worker tool context should omit agent-spawning tools where the runtime can safely project availability.
- Retain server-side enforcement as the authority boundary; prompt guidance remains defense in depth.
- Do not rely on prompt text alone.
-
Define terminal semantics for required control operations.
- A failed spawn/delegate/continue must yield terminal failed or explicitly degraded, never succeeded/Done.
- A later successful retry in the same turn may resolve the pending failure.
- Preserve the kernel as the owner of session/run/attempt truth.
-
Keep explicit local User Claude auth isolated.
- Validate browser OAuth URLs before opening them.
- Preserve retry after callback timeout without duplicate tabs for one attempt.
Acceptance criteria
- There is one documented and tested credential-scope source of truth for all production adapters.
- A test matrix covers every control entry point against every local adapter and an unknown adapter from a managed surface.
- Leaf workers cannot discover or invoke nested-agent creation; server enforcement proves denial even for malformed or stale tool context.
- Integration coverage proves failed child creation cannot result in a green parent terminal status, while a successful retry can complete.
- Explicit User Claude mode retains its local auth behavior; managed modes never invoke local OAuth or inspect local provider credentials.
- Product invariant references are updated as needed, especially INV-AGENT-* and INV-CHAT-1.
Non-goals
- Do not move managed provider credentials onto the desktop.
- Do not invalidate the Omi Firebase session for provider/BYOK/local-provider failures.
- Do not add another transcript, session, or pill persistence store.
- Do not remove the current safety guards while replacing them.
Verification
- Focused runtime/control-tool and pi-mono tests.
- Agent logic harness and exact pi-mono-extension tests.
- Named non-production desktop bundle smoke: managed background work completes on cloud routing with no local ACP/Hermes/OpenClaw launch.
- Negative smoke: forced required-control failure is visibly non-green.
Activity
fix(desktop): enforce managed/local agent boundaries (#9411)