You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feat: Automatically run aws sso login when credentials need to be refreshed #1934
I get this about twice a day, because my job enforces a pretty fast expiration for AWS login credentials:
Error: AWS credential provider failed: The SSO session associated with this profile has expired. To refresh this SSO session run aws sso login with the corresponding profile.. Please ensure your credential provider returns valid AWS credentials with accessKeyId and secretAccessKey properties.
Should opencode automatically run aws sso login when this is encountered?
Reacted by jake, Falko, Andrew Enger, Luke Jennings, Ravi Dayabhai, Simon, Théophile Wallez, Luke Secomb, Adrian Cristea, Uladzimir Palkhouski and 6 more
hey @markjaquith i have never written a plugin but i gave it a shot.
originally tried handling the error in tool.execute.after but thats pretty brittle and it still results in the agent reporting the error and having to manually retry.
went with going in the before hook and it required some sort of timer otherwise it may get spammed.
i think this will work:
importtype{Plugin}from"@opencode-ai/plugin";// TODO: set this to your login frequencyconstLOGIN_INTERVAL_SECONDS=60*20;// TODO: set command name to watch forconstCOMMAND_NAME='aws';// TODO: set login commandconstLOGIN_COMMAND=`${COMMAND_NAME} sso login`;// start this as 0 to do a guaranteed initial login first time plugin is runletlastLoginTimestamp=0;constisLoginStale=(lastLoginTimestamp: number,currentTimestamp: number,staleTimeSeconds: number)=>{constdiffSeconds=((currentTimestamp-lastLoginTimestamp)/1000);returndiffSeconds>=staleTimeSeconds;}exportconstAutoLoginPlugin: Plugin=async({ app, client, $ })=>{return{"tool.execute.before": async(input,output)=>{constisBashTool=input.tool==="bash";constisTargetCommand=isBashTool&&output.args.command.startsWith(COMMAND_NAME);constcurrentTimestamp=Date.now();constshouldLogInAgain=isLoginStale(lastLoginTimestamp,currentTimestamp,LOGIN_INTERVAL_SECONDS);if(isTargetCommand&&shouldLogInAgain){console.log(`[${currentTimestamp}] Refreshing [${COMMAND_NAME}] login with command [${LOGIN_COMMAND}]`);await$`${LOGIN_COMMAND}`;lastLoginTimestamp=currentTimestamp;}},}}
it would be nice to have the agent report "hey i took an auto-action" and i went down quite a rabbithole trying to find a way to do that. i dont believe its possible to send messages from plugins.
Activity
the-vampiire commentedon Aug 15, 2025
hey @markjaquith i have never written a plugin but i gave it a shot.
originally tried handling the error in
tool.execute.afterbut thats pretty brittle and it still results in the agent reporting the error and having to manually retry.went with going in the before hook and it required some sort of timer otherwise it may get spammed.
i think this will work:
it would be nice to have the agent report "hey i took an auto-action" and i went down quite a rabbithole trying to find a way to do that. i dont believe its possible to send messages from plugins.
the-vampiire commentedon Aug 15, 2025
heres a more generalized one that can handle multiple commands
rekram1-node commentedon Dec 28, 2025
[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
itahol commentedon Jan 10, 2026
Hey @rekram1-node , I would still like this very much!
anenger commentedon Jan 23, 2026
Would be awesome if this was built into opencode cc: @thdxr
theophile-wallez commentedon Jun 4, 2026
Same here, would love this feature!
LLuque-twilio commentedon Jul 8, 2026
Hi there! Any movement on this? Would love to see this feature ✨
github-actions commentedon Sep 7, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
primeapple commentedon Sep 7, 2026
Still interested