Skip to content

Agent-grants (v1.44.0+) never inject: correctly published policy_rules_v2 grant still 401s credential_not_found #482

Description

@Idpar

Problem

A type: anthropic secret (Claude subscription OAuth token) granted to an agent via the dashboard's agent-grants UI (LLMs tab, toggle on) is never actually injected. Every call 401s with credential_not_found, even though the grant is correctly saved and shown as attached.

Steps to Reproduce

  1. onecli secrets create --name Anthropic --type anthropic --value sk-ant-oat01-... --host-pattern api.anthropic.com
  2. Dashboard → Agents → Default Agent → LLMs tab → toggle the secret on (confirmed via network tab: PUT /v1/agents/<id>/grants/secrets/<secretId> → 200 OK)
  3. onecli run -- claude -p "hi"

Expected Behaviour

Claude Code authenticates using the granted credential and responds normally.

Observed Behaviour

onecli: gateway connected. Starting claude...
Failed to authenticate. API Error: 401 No credentials configured for api.anthropic.com in OneCLI.

Also reproduces with a bare curl through the gateway (no onecli run, no Claude Code), using the agent's own access token:

curl -sS -x http://<agent-access-token>@localhost:10255 \
  --cacert /tmp/onecli-ca.pem \
  -X POST https://api.anthropic.com/v1/messages \
  -H "x-api-key: placeholder" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
  -d '{"model":"claude-sonnet-5","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'
# -> {"error":"credential_not_found", ...} HTTP 401

Reproduces identically for the Default Agent and a second, custom-created agent — not specific to one agent identity.

I checked the underlying data directly in Postgres (secret + agent share the same project_id, the policy_rules_v2 grant rule is published/enabled at the current max generation for the project, with matching policy_rule_identities/policy_rule_targets rows) — the grant looks correctly configured, but injection still never happens.

Environment

  • Self-hosted (curl -fsSL onecli.sh/install | sh), single-project local install
  • Gateway: pulled ghcr.io/onecli/onecli:1.36.0, but /api/health reports "version":"1.45.0"
  • onecli CLI 2.2.5
  • Credential: Claude Pro/Max subscription token via claude setup-token

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions