Skip to content

feat: add agent catalog/auth API and safer orchestrator switching#276

Open
nikhilachale wants to merge 5 commits into
aoagents:mainfrom
nikhilachale:agent-switcher
Open

feat: add agent catalog/auth API and safer orchestrator switching#276
nikhilachale wants to merge 5 commits into
aoagents:mainfrom
nikhilachale:agent-switcher

Conversation

@nikhilachale

@nikhilachale nikhilachale commented Jun 17, 2026

Copy link
Copy Markdown

Summary

This PR adds a daemon-backed agent catalog, exposes installed/authorized agent state to the frontend, and uses that data in project settings so users can choose worker/orchestrator agents more safely.

It also adds orchestrator replacement handling: when the saved orchestrator agent changes, AO starts the replacement first and only retires the previous orchestrator after the new one is up, so a failed replacement does not cause downtime.

A key caveat is that agent-auth/login flows can interfere with replacement startup. If switching agents triggers the agent’s own bootstrap path, the replacement may come up outside AO’s normal orchestrator initialization path and miss the AO orchestrator system prompt.

What Changed

Backend

  • Added agent inventory service for:

    • supported agents
    • installed agents
    • authorized agents
    • counts for each
  • Added optional AgentAuthChecker capability on adapters.

  • Added shared CLI auth probing helper for adapters with cheap local auth checks.

  • Added GET /api/v1/agents.

  • Extended registry inventory entries to carry adapter manifest metadata for user-facing labels.

  • Added orchestrator replacement flow in the session service:

    • spawn replacement first
    • retire previous orchestrator only after successful replacement
    • preserve previous orchestrator when replacement startup fails
  • Added backend tests for agent catalog, controller responses, session replacement behavior, and related project/service wiring.

Frontend

  • Regenerated API types for the new agents endpoint/DTOs.

  • Updated ProjectSettingsForm to:

    • load agent catalog from the daemon
    • show authorized agent options
    • handle installed-but-not-authorized states
    • surface orchestrator replacement pending state
    • allow retry once replacement is safe to perform
  • Added/updated tests for the new settings behavior.

Why

Before this change, the UI did not have a daemon-backed view of which agents are actually installed and authenticated on the local machine, and changing orchestrator agent config did not have a clear replacement flow.

This PR makes agent selection more grounded in local runtime state and reduces the chance of downtime during orchestrator switches.

Risks / Caveats

  • A large part of the file count comes from:

    • generated API artifacts
    • frontend tests
    • small per-adapter auth probe shims
  • The CLI/runtime/session model is unchanged outside the new inventory/auth and orchestrator replacement paths.

  • Generated files are included intentionally:

    • backend/internal/httpd/apispec/openapi.yaml
    • frontend/src/api/schema.ts
  • Auth/login flows remain a review risk. If switching agents triggers the agent’s own login/bootstrap flow, that flow can spawn a fresh native session outside AO’s normal orchestrator startup path.

  • In that case, the replacement session may miss AO’s expected initialization, including the orchestrator system prompt.

  • The old orchestrator is intentionally preserved on replacement failure, but reviewers should pay close attention to whether
    replacement startup still guarantees AO system-prompt delivery.

Closes #275

- Implemented AgentsController to handle /agents endpoint, returning a list of supported and installed agents.
- Created agent inventory service to manage agent data and detect installed agents.
- Updated ProjectSettingsForm to fetch and display agent information, including installed and supported agents.
- Enhanced error handling for agent detection and orchestrator restarts.
- Added tests for agent catalog and service to ensure correct functionality and error handling.
…flect changes

- Added `AuthStatus` method to various agent plugins to check authorization status using CLI probes.
- Introduced `authprobe` package to handle common CLI command checks for agent authorization.
- Updated backend tests to include scenarios for authorized and unauthorized agents.
- Modified frontend API schema to include `authorized` counts and `authStatus` for agents.
- Enhanced `ProjectSettingsForm` to display authorized agents and their statuses, including prompts for login when necessary.
- Adjusted agent selection logic to prioritize authorized agents and provide feedback for unauthorized or uninstalled agents.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant