Skip to content

fix(agent): fall back to an available project agent#59

Open
khrypchenko wants to merge 1 commit intogrinev:mainfrom
khrypchenko:fix/project-agent-fallback
Open

fix(agent): fall back to an available project agent#59
khrypchenko wants to merge 1 commit intogrinev:mainfrom
khrypchenko:fix/project-agent-fallback

Conversation

@khrypchenko
Copy link
Copy Markdown

Summary

  • validate the stored agent against the selected project's available primary agents before opening a session, sending a prompt, or refreshing the keyboard
  • fall back to build (or the first available primary agent) and persist that choice so project switches do not send unsupported agent names to OpenCode
  • add regression coverage for project-specific agent fallback behavior and update command tests for the new resolver

Verification

  • npm run build
  • npm run lint
  • npm test

Keep the stored agent in sync with the selected project so switching worktrees does not send unsupported agent names to OpenCode.
@grinev
Copy link
Copy Markdown
Owner

grinev commented Mar 25, 2026

@khrypchenko thanks for the fix - the new agent resolver looks good, and the regression tests around project-specific fallback are useful.

I found one blocking gap before merge: the existing session selection flow still does not validate the stored agent against the selected project. In src/bot/commands/sessions.ts, the keyboard is initialized and sent after switching to an existing session, but this path does not call resolveProjectAgent() or otherwise refresh the agent state for the current project.
Because of that, if the user has an agent saved from another project, the bot can still show an unsupported agent in the reply keyboard after opening an existing session. This seems to be part of the behavior described in the PR ("before opening a session" / "refreshing the keyboard"), so I think this path should be covered as well.

Could you please apply the same normalization here as you already did in /new, project switching, prompt sending, model change, and variant change? It would also be good to add a regression test for the existing-session flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants