-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: make agent provider and model fields required #1901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ssddOnTop
wants to merge
22
commits into
main
Choose a base branch
from
refactor/agent-definition
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,135
−789
Open
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
20c2674
refactor: make agent provider and model fields required
ssddOnTop 710f195
[autofix.ci] apply automated fixes
autofix-ci[bot] f74119d
refactor(agent): introduce AgentOrchestrator for agent lifecycle mana…
ssddOnTop 520465a
refactor(agent): introduce AgentOrchestrator for agent lifecycle mana…
ssddOnTop edb160e
[autofix.ci] apply automated fixes
autofix-ci[bot] d421767
refactor(agent): extract AgentDefinition into separate module
ssddOnTop 1d37cde
refactor(agent): consolidate AgentDefinition into Agent domain type
ssddOnTop f5a6f08
[autofix.ci] apply automated fixes
autofix-ci[bot] 4e7117e
refactor(agent): replace AgentOrchestrator with AgentRepository pattern
ssddOnTop a4dd594
[autofix.ci] apply automated fixes
autofix-ci[bot] 97bc2fc
refactor(api): separate default and agent-specific provider methods
ssddOnTop abcf363
refactor(agent): remove ForgeAgentRepository from public exports
ssddOnTop 9f38bfc
refactor(info): expand agent display with provider and model details
ssddOnTop 1df638f
refactor(agent): remove caching layer from agent repository
ssddOnTop ee5ea0c
refactor(info): add agent id field and model to agent display
ssddOnTop a0058ae
refactor(ui): display model names instead of ids in agent info
ssddOnTop ea1e2d9
refactor(ui): display model names instead of ids in agent info
ssddOnTop 75262bf
Revert "refactor(ui): display model names instead of ids in agent info"
ssddOnTop e4b303a
Revert "refactor(ui): display model names instead of ids in agent info"
ssddOnTop 5f12e40
refactor(ui): display model names instead of model ids in agent list
ssddOnTop a6d6c97
refactor(ui): align agent list layout with fixed-width columns
ssddOnTop 3a5eab5
Merge branch 'main' into refactor/agent-definition
ssddOnTop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| use std::sync::Arc; | ||
|
|
||
| use anyhow::Result; | ||
| use forge_domain::{Agent, AgentId}; | ||
|
|
||
| use crate::Services; | ||
| use crate::services::{AgentLoader, AgentRegistry, AppConfigService}; | ||
|
|
||
| /// Orchestrates agent operations including loading definitions, converting to | ||
| /// runtime agents, and managing the agent registry. | ||
| pub struct AgentOrchestrator<S> { | ||
| services: Arc<S>, | ||
| } | ||
|
|
||
| impl<S: Services> AgentOrchestrator<S> { | ||
| /// Creates a new AgentOrchestrator with the provided services | ||
| pub fn new(services: Arc<S>) -> Self { | ||
| Self { services } | ||
| } | ||
|
|
||
| /// Gets all agents, converting AgentDefinitions to Agents with default | ||
| /// provider and model. Uses cached agents from registry if available, | ||
| /// otherwise loads definitions and populates the registry. | ||
| pub async fn get_agents(&self) -> Result<Vec<Agent>> { | ||
| // try to get from registry | ||
| let cached_agents = AgentRegistry::get_agents(&*self.services).await?; | ||
| if !cached_agents.is_empty() { | ||
| return Ok(cached_agents); | ||
| } | ||
|
|
||
| // load definitions from AgentLoader, convert, and cache | ||
| let agent_defs = AgentLoader::get_agents(&*self.services).await?; | ||
| let default_provider = self.services.get_default_provider().await?; | ||
| let default_model = self | ||
| .services | ||
| .get_default_model(&default_provider.id) | ||
| .await?; | ||
|
|
||
| let agents: Vec<Agent> = agent_defs | ||
| .into_iter() | ||
| .map(|def| def.into_agent(default_provider.id, default_model.clone())) | ||
| .collect(); | ||
|
|
||
| // Populate the runtime registry so other parts of the app can query | ||
| // agents by id efficiently. | ||
| self.services.set_agents(agents.clone()).await?; | ||
|
|
||
| Ok(agents) | ||
| } | ||
|
|
||
| /// Gets a specific agent by ID, converting AgentDefinition to Agent with | ||
| /// default provider and model | ||
| pub async fn get_agent(&self, agent_id: &AgentId) -> Result<Option<Agent>> { | ||
| // First try to get from registry (fast path) | ||
| if let Some(agent) = AgentRegistry::get_agent(&*self.services, agent_id).await? { | ||
| return Ok(Some(agent)); | ||
| } | ||
|
|
||
| // Fallback: load all agents and find the one we need | ||
| // This will also populate the cache for future requests | ||
| let agents = self.get_agents().await?; | ||
| Ok(agents.into_iter().find(|a| &a.id == agent_id)) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.