Skip to content

fix(cli): show agent list before setting a session model#2910

Merged
tusharmath merged 6 commits intomainfrom
bug-command-list
Apr 9, 2026
Merged

fix(cli): show agent list before setting a session model#2910
tusharmath merged 6 commits intomainfrom
bug-command-list

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 9, 2026

Summary

Introduce AgentInfo — a lightweight agent metadata type — so the command list, agent switching, and agent listing no longer require a fully configured provider/model session to work.

Context

Previously, fetching agents for the command autocomplete list (/agent, /switch, etc.) called get_agents(), which internally resolved the default provider and model from the active session. This meant the command list would fail or be empty whenever no session was configured — a common state when a user first opens a fresh workspace or hasn't yet set a default model. The branch name bug-command-list reflects this: colon-command autocomplete was broken because listing agents required a session that didn't always exist.

Changes

  • Added AgentInfo struct to forge_domain with only id, title, and description — the fields needed for listing, no provider/model required
  • Added get_agent_infos() to AgentRepository, AgentRegistry, and the API trait alongside the existing get_agents()
  • Moved provider/model resolution into ForgeAgentRepository::get_agents() so it happens only when a full Agent is truly needed (e.g., running the agent)
  • Replaced all UI-layer calls that only needed agent names/titles (command list, agent switch, show agents, register_agent_commands) to use the new get_agent_infos()
  • Removed the services_url parameter from ForgeAPI::init and ForgeInfra::new — the URL is now read directly from config at construction time, eliminating the early URL-validation step in main.rs
  • Changed GrpcInfra::channel() to return anyhow::Result<Channel> instead of panicking, propagating URL-parse errors properly
  • Updated ForgeGrpcClient to store the server URL as a String (parsed lazily when a channel is first needed) and return Result from channel()

Key Implementation Details

AgentInfo is derived from AgentDefinition before any provider/model injection, so get_agent_infos() never touches the session config. get_agents() still resolves the session in the repository layer (ForgeAgentRepository), keeping that concern out of the service layer (AgentRegistryService).

Use Cases

  • Command autocomplete (/agent:, /switch) works immediately on startup even when no default session/provider is configured
  • The agents subcommand (/agents listing) no longer errors out on unconfigured workspaces
  • Agent registration for slash-command routing uses lightweight metadata, avoiding unnecessary session lookups

Testing

# Run all tests
cargo insta test --accept

# Verify the command list works without a configured session
# Start forge in a fresh directory with no .forge.toml session block and type ":"

Links

@tusharmath tusharmath changed the title bug command list fix: : command autocomplete not working Apr 9, 2026
@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 9, 2026
@tusharmath tusharmath changed the title fix: : command autocomplete not working fix: colon command autocomplete not working Apr 9, 2026
@tusharmath tusharmath enabled auto-merge (squash) April 9, 2026 15:10
@tusharmath tusharmath changed the title fix: colon command autocomplete not working feat(agent): introduce AgentInfo for lightweight agent listing, fix command autocomplete without session Apr 9, 2026
@tusharmath tusharmath merged commit dc67ca7 into main Apr 9, 2026
13 checks passed
@tusharmath tusharmath deleted the bug-command-list branch April 9, 2026 15:11
@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 9, 2026
@tusharmath tusharmath changed the title feat(agent): introduce AgentInfo for lightweight agent listing, fix command autocomplete without session fix(cli): show agent list before setting a session model Apr 9, 2026
@tusharmath tusharmath removed the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant