Repository navigation
agents: delegate model connection use for start-run runs - #1186
Merged
Merged
Conversation
A run admitted through the start-run/v1 action kept the caller's proxied identity on its context, so resolving the agent's ModelProviderConnection asked the caller for `use`. The caller of start-run is an App Studio Project's workload identity, which the hub never grants `use`, so every model-backed run started from an app failed at once with "use permission is required". Found on railgrid-dev with the first live App Studio -> Agents integration call. start-run is an automation grant (consent-gated, risk medium), so its runs now use the agent's configured models under the same delegation as Schedule, Trigger and Webhook runs. The caller is still authorized for agents/start-run and gated on `get` for the agent; only the connection use check stops asking about it. The `run` verb is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
/approve |
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cwilhit The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Review of the first fix found that a context flag on the start-run request was the wrong altitude: an inbox approval resumed the run under the approver's identity without the flag (so an approver without `use` failed it), crash recovery behaved differently, and the exported helper that switched off the check was ambient authority. The delegation is now a fact of the run: - store.Run.ModelUseDelegated (column model_use_delegated), written at admission by start-run/v1 only and never cleared by a rewrite (memory and Postgres). - runTurn, the one path every start, resume, recovery and sub-agent turn takes, runs a delegated run with no attending caller, via the new dataplane.WithoutProxiedIdentity. Rebuilt runs (resume, background) and configured delegates carry the field. - Harness admission resolves the credential the same way for a delegated run, so an agent with a configured reasoning effort is not refused at start-run time. - agentsclient.WithDelegatedModelUse is removed. Tests: - The unit regression now goes through the production admission path (provider view, vwSecrets) and asserts the configured model was called and the run Succeeded; the run verb is still refused with no model call. - A resume test: a delegated run resumed under an approver without `use` reaches the model; the same run undelegated is refused. - Store round-trip for the flag, memory and Postgres. - New real-kcp e2e case in agentsprovider: a tenant ServiceAccount with get + agents/run + agents/start-run and no `use`, a real ModelProviderConnection, a fake model in the test process. Verified to fail with the railgrid-dev message when the fix is switched off. Docs no longer overclaim: anyone with RBAC on agents/start-run spends the agent's configured models, Agents does not check consent itself, and the delegation covers configured delegates and resumes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The first live App Studio → Agents call on railgrid-dev failed. The
prospectingProject'sresearcherintegration calledstart-run/v1on a model-backed agent. The action admitted the run, and the run failed 40 ms later:invokeRunstarts the run withcontext.WithoutCancel(r.Context()), which keeps the shard-stamped caller. When the run resolves the agent'sModelProviderConnection,AuthorizeModelProviderConnectionUsetreats the run as attended and asks the caller foruse. The caller is the Project's workload identity, which holds exactly its granted actions, and the hub's identity policy has no clause foruseon a connection. So, as #1181 shipped, no model-backed agent can serve an App Studio app.What
Runs admitted through
start-run/v1spend the agent's configured models under the delegation that Schedule, Trigger and Webhook runs already use (docs/agents-model-provider-connections.md, "Access").The delegation is a fact of the run, not of the request:
store.Run.ModelUseDelegated(new columnmodel_use_delegated) is written at admission, only bystart-run, and never cleared by a rewrite. Both the memory and Postgres stores are covered.runTurnis the one path every start, resume, recovery and sub-agent turn takes. It runs a delegated run with no attending caller, using the new SDK helperdataplane.WithoutProxiedIdentity.use, and crash recovery behaves the same way.delegatesinherit the delegation. Configuring them is the same trusted delegation as configuring the parent's models.start-runis called.runverb is unchanged and still requiresusefrom its caller.Trade-off, now stated plainly in the docs: anyone with RBAC on
agents/start-run(plusgeton the agent) can spend the agent's configured models withoutuse. Anyone who can create a Schedule for the agent can already do that. Agents does not check consent itself; App Studio's grant flow does.Docs updated: the model-connection design doc's Access section,
docs/provider-actions.md, the Agents README, theskills/railgridagents reference, and the AGENTS.md e2e table.Testing
serve.New, on the production admission path (provider view andvwSecrets):start-runreaches the configured model and the run Succeeds.runverb from the same caller is refused at the use check, with no model call.usereaches the model. The same run without delegation is refused.TestNStartRunDelegatesModelConnectionUseinagentsprovider):geton agents andcreateonagents/runandagents/start-run, nouse; a realModelProviderConnection; a fake model served from the test process.make e2e-agents-provider: all 15 tests pass.providers/agentsgo test ./...: all packages pass, with Postgres.provider-sdk/dataplanetests pass.golangci-lint: 0 issues on both modules and the e2e suite.hack/verify-provider-contract.mjs: 0 violations.make verify-boilerplate: passes.Not yet verified: the live call on railgrid-dev after deploy.
🤖 Generated with Claude Code