Skip to content

Ask for a credential's value directly when the setup agent has no LLM provider - #91

Draft
josephschorr wants to merge 1 commit into
mainfrom
setup-identity-static-prompt
Draft

josephschorr wants to merge 1 commit into
mainfrom
setup-identity-static-prompt

Conversation

@josephschorr

Copy link
Copy Markdown
Member

Motivation

oap agent setup-identity <agentclass> --refresh anthropic-api-key, for a
credential declared type: static with a static.secretRef, failed with:

→ anthropic-api-key: provider "anthropic-api-key" has no builtin; using LLM-driven setup agent …
setup: anthropic-api-key: llmagent: provider: llmagent: LLM provider unavailable: anthropic: ANTHROPIC_API_KEY not set

A credential with no builtin flow is handed to the LLM-driven setup agent,
which needs a model API key in the environment. Setting that very key
therefore required already having it exported, and no credential without a
builtin flow could simply be typed.

Summary of changes

  • llmagent.Run reports a failed LLMProviderFactory as ErrNoLLMProvider
    (error text unchanged).
  • On that error the setup engine asks for the value directly with a new
    engine-built pasteFlow, run through the same presenter, token-shape gate,
    verify-then-store closure and Store chokepoint as a builtin flow. The
    value is written to the secretRef the AgentIdentity already declares.
  • The fallback applies only to shape: bearer providers and inline-prompt
    requirements. Other shapes fail as before. --non-interactive is still
    refused before the agent is tried.
  • The field uses tui.NewSecret, so input is hidden on a terminal. Existing
    builtin flows use tui.NewText, which echoes as typed; they are unchanged.
  • READMEs for setup and llmagent, and the comment in
    providers/anthropic-api-key.yaml, updated to match.

Known limit: with stdout on a terminal and stdin piped, the masked field
reads nothing, so echo <key> | oap agent setup-identity … from a terminal
fails with "no value was supplied" and stores nothing.

Alternatives considered

  • A dedicated anthropic-api-key builtin: a near copy of anthropic-oauth
    that adds nothing the provider YAML does not already declare, and leaves
    inline-prompt requirements and future builtin-less providers failing the
    same way. Still a reasonable follow-up, so this credential skips the LLM
    agent even when a key is present.
  • Registering the generic flow in the builtins registry: the registry is keyed
    by a provider's builtin: field with one provider per builtin, and
    inline-prompt requirements have no provider.
  • Probing the LLM factory before running the agent: calls the factory twice.

Provenance

  • Author (person, or model and version): Joseph Schorr
  • Harness or tooling, with version:
  • Person who read the diff:

Ship gate

  • mage test:unit
  • mage test:integration
  • mage test:e2e

Results:

Not run in full. Run so far:

go build ./...                                   ok
go vet ./pkg/platform/identity/setup/...         ok
go test -count=1 ./pkg/platform/identity/... ./providers/...
    ./cmd/oap/internal/identitycmd/... ./cmd/oap/internal/agentcmd/...
    ./cmd/oap/internal/directorycmd/...          all ok

Not exercised against a cluster or on a real terminal.

Regeneration

  • kubebuilder markers / CRD fields: n/a
  • config/**: n/a
  • cobra command or CRD schema: n/a (no help text changed)
  • mage fmt:all / mage fmt:check: oxfmt run on the two touched READMEs
    only; full mage fmt:check not run

Coverage

  • User-visible behavior added; no bronzethread bundle exercises it (unit
    tests in pkg/platform/identity/setup only)
  • Does not touch authorization, the SpiceDB schema, or the approver model

Before requesting review

  • The PR holds a single change.
  • A person has read every line of the diff.

… provider

A credential with no builtin setup flow is handed to the LLM-driven setup
agent, which needs a model API key in the environment. With none set, the
run failed with "LLM provider unavailable: anthropic: ANTHROPIC_API_KEY not
set" and offered no way to type the value, including when the credential
being set was that same API key.

llmagent.Run now reports a missing provider as ErrNoLLMProvider. On that
error the engine asks for the value itself, through the same presenter,
format gate, verify-then-store closure and Store chokepoint a builtin flow
uses, so the value lands in the secretRef the AgentIdentity already declares.
The fallback applies only to a bearer-shaped provider or an inline-prompt
requirement; other shapes fail as before, and a run told not to prompt is
still refused before the agent is tried.
@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
openagentprimitives Ignored Ignored Preview Dec 4, 2026 1:20am UTC

Request Review

This branch has not been deployed

No deployments
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