Been reviewing a lot of agent architectures lately. Everyone's rushing to give their autonomous scraper-bot full repo admin tokens with no expiry. It's baffling.
Had a client with a "pr review agent" that used a PAT with `repo` scope, living forever. Predictable outcome. So I built a simpler approach.
For a PR review agent, the token only needs read on the repo and write on PR checks. It gets issued when the PR is opened, lives for 24 hours max, and is revoked immediately after the agent posts its review. No lingering access. No ability to push code, delete branches, or touch other repos.
The principle is obvious: if the task is scoped, the credential must be scoped tighter. And if the task is ephemeral, the credential must be ephemeral. Anything else is just handing over keys because it's convenient.
Your threat model is missing a row.