Pull requests: unnamed, a pull request is its author's, not an agent's
A pull request opened through the API or MCP without `agent` was labelled "agent", so rules for agents only held for a person's script too. Left out, the label is now the author's username, and "agent" only when an agent's token opens it; the same in the work service for any caller. The rules guide and the parameter say so.
4 files+10−50/4 viewed
| 2180 | 2180 | }, | |
| 2181 | 2181 | "agent": { | |
| 2182 | 2182 | "type": "string", | |
| 2183 | − | "description": "A label for the agent doing the work, e.g. \"claude-code\".", | |
| 2183 | + | "description": "A label for the agent doing the work, e.g. \"claude-code\". Left out, the pull request is its author's (or \"agent\" when an agent's token opens it).", | |
| 2184 | 2184 | }, | |
| 2185 | 2185 | "base": { | |
| 2186 | 2186 | "type": "string", | |
| 3998 | 3998 | title: text(input, "title"), | |
| 3999 | 3999 | body: text(input, "body"), | |
| 4000 | 4000 | branch: optional_text(input, "branch"), | |
| 4001 | − | agent: optional_text(input, "agent").unwrap_or_else(|| "agent".into()), | |
| 4001 | + | // Unnamed, the change is its author's, unless an agent's token opened it. | |
| 4002 | + | agent: optional_text(input, "agent") | |
| 4003 | + | .unwrap_or_else(|| if g1t_contracts::rules::is_agent(&user) { "agent".into() } else { user.username.clone() }), | |
| 4002 | 4004 | runtime: Runtime::External, | |
| 4003 | 4005 | base: optional_text(input, "base"), | |
| 4004 | 4006 | }, |
| 117 | 117 | default. `applies_to` is `everyone` (the default), `agents` or `people`. | |
| 118 | 118 | ||
| 119 | 119 | A change counts as an agent's when it is pushed with an agent's token, or | |
| 120 | − | when its pull request was made by g1t or opened with an agent label through | |
| 121 | − | the API or MCP. A pull request a person opens on the site is a person's. | |
| 120 | + | when its pull request was made by g1t, opened with an agent's token, or opened | |
| 121 | + | naming an agent (`agent`) through the API or MCP. A pull request a person | |
| 122 | + | opens on the site, or through the API without naming an agent, is a person's. | |
| 122 | 123 | ||
| 123 | 124 | ### Branches and tags | |
| 124 | 125 |
Binary or large file; its contents are not shown.
| 1054 | 1054 | Err(message) => return Ok(Outcome::fail(FailureCode::Invalid, message)), | |
| 1055 | 1055 | }, | |
| 1056 | 1056 | }; | |
| 1057 | + | // Unnamed, the change is its author's, unless an agent opened it. | |
| 1057 | 1058 | let agent = match a.agent.trim() { | |
| 1058 | − | "" => "agent", | |
| 1059 | + | "" if g1t_contracts::rules::is_agent(&a.actor) => "agent", | |
| 1060 | + | "" => a.actor.username.as_str(), | |
| 1059 | 1061 | agent => agent, | |
| 1060 | 1062 | }; | |
| 1061 | 1063 | let runtime = match a.runtime { |