Loading VIBA…

Credentials Are Not Context: Managing Secrets in Multi-Agent AI Workflows

Credentials Are Not Context: Managing Secrets in Multi-Agent AI Workflows

The fastest way to debug an AI tool is to hand it everything it needs: the error message, the failing test, and the environment variable the service reads at boot. It works. It also means the credential is now part of a transcript.

That transcript may be stored by the model provider, cached by your tooling, exported for review, or pasted into the next session by a teammate trying to reproduce the bug. Multi-agent collaboration makes this worse, not better. When several models share one session — one writing tests, one reviewing a diff, one summarising results — anything pasted once is visible to all of them, for the rest of the run.

Imagine a repo testing agent that needs to reach a staging database to reproduce a failure. The lazy version is a connection string in the prompt. The better version is an agent that never sees the string at all.

Give Every Agent Its Own Identity

The first structural fix is to stop treating credentials as session-wide. In a multi-agent setup, each agent has a role, and a role should map to a distinct identity with the narrowest access that lets it do its job.

For example, you could run ChatGPT as the test author, Claude as the adversarial reviewer, and Gemini as the documentation writer, each with different needs:

- The test author needs read access to the repository and the ability to run a test suite in a sandbox. - The reviewer needs read access to the diff and nothing else. - The writer needs neither.

If all three authenticate as the same service account, a prompt injection in one of them inherits every permission the others have. Separate identities turn a single blast radius into three small ones. Prefer short-lived tokens issued per run over long-lived keys, and treat any credential that survives a run as a finding to fix rather than a convenience to keep.

Let the Runner Hold the Secret, Not the Model

Agents should describe what they want to do; the execution layer should decide whether they may. That separation is where most of the safety lives.

Concretely: an agent proposes a command, a human approves it at a step you control, and the runner injects the credential at execution time. The secret is resolved from a vault into the process environment and never enters the model context, the conversation history, or the cost dashboard. The agent sees the output — the test results, the ranked repair report — not the key that produced them.

This is also the cleanest place to enforce scope. A developer QA agent verifying a UI flow does not need write access to production. A beta testing run against a staging build does not need a production deploy token. For teams doing software testing with AI tools, the runner is the natural place to keep fixtures, seed data and connection details out of the prompt as well. If the approval step is the only door to a secret, then every use of that secret has a human decision in front of it, and the decision is recorded.

Two habits make this work in practice. First, keep credentials out of prompts even when it is inconvenient — pass a reference, never a value. Second, make the failure mode safe: if the runner cannot resolve a credential, the step should fail closed and report why, rather than falling back to an ambient credential that happens to be lying around.

Audit Who Touched What, and Watch the Spend

Rotation and least privilege only help if you can answer a simple question after the fact: which agent used which credential, when, and for what?

Log the identity, the resource, the decision and the approver for every credential use. Keep that log outside the model context so an agent cannot rewrite its own history. Then read it. Patterns show up quickly — an agent retrying authentication far more often than the work requires is usually a loop, not a legitimate need, and it is worth cutting off before it burns through a rate limit or a budget.

Cost visibility helps here too. Per-agent cost reporting is a useful signal in a credential context because authentication failures are noisy: a stuck agent will happily spend tokens re-attempting the same denied call. If one agent's cost curve spikes while its output stays flat, investigate the tool calls before you investigate the prompt.

A Workflow You Can Start With

None of this requires a rewrite. Start with the smallest change that removes secrets from context: pass references instead of values. Then split identities per role, even if two agents share the same underlying provider. Then put an approval step in front of anything that writes, deploys or reaches production data. Then review the audit log weekly until it is boring.

The goal is not to make AI tools powerless. It is to make their access legible — so that when a multi-agent session produces a change, you can say exactly what it could touch, what it did touch, and who said yes. That is the same standard you would hold a new contractor to in their first week, and it scales better than trusting a transcript.

VIBA is built around that idea: several models in one shared session, each with a role, with key steps approved by you and cost reported per agent, alongside UI testing, repo testing, beta testing and ranked repair reports. If you want to see how role-scoped agents and human approval gates fit together in practice, start at https://www.viba.guru.

See VIBA: https://www.viba.guru