Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: remove operating agents from variables#1484

Merged
tusharmath merged 4 commits into
mainfrom
refactor-operating-agent
Sep 4, 2025
Merged

refactor: remove operating agents from variables#1484
tusharmath merged 4 commits into
mainfrom
refactor-operating-agent

Conversation

@tusharmath

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions github-actions Bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Sep 4, 2025
@tusharmath tusharmath changed the title feat: add operating agent management to API and update related structures refactor: remove operating agents from variables Sep 4, 2025
Comment thread crates/forge_api/src/forge_api.rs Outdated
}

async fn set_operating_agent(&self, agent_id: AgentId) -> anyhow::Result<()> {
let mut config = self.services.read_app_config().await.unwrap_or_default();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be inconsistent error handling between the two methods. In get_operating_agent(), errors from read_app_config() are properly propagated using the ? operator, while in set_operating_agent(), errors are silently converted to a default value with unwrap_or_default().

This creates a potential issue where read operations might fail with proper errors, but write operations would silently proceed with a default configuration even when the underlying storage system is failing.

Consider using consistent error handling in both methods:

let mut config = self.services.read_app_config().await?;

This ensures that storage failures are handled consistently across both operations.

Suggested change
let mut config = self.services.read_app_config().await.unwrap_or_default();
let mut config = self.services.read_app_config().await?;

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment thread crates/forge_main/src/ui.rs Outdated

self.command.register_all(&base_workflow);
self.state = UIState::new(self.api.environment(), base_workflow).provider(provider);
let operating_agent = self.api.get_operating_agent().await.unwrap_or(None);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be an error in the error handling pattern here. The expression self.api.get_operating_agent().await.unwrap_or(None) is problematic because unwrap_or(None) is being applied to a Result<Option<AgentId>, Error>, not an Option.

This will panic if the API call returns an Err, rather than handling the error gracefully. Consider one of these alternatives:

// Option 1: Use unwrap_or_default() which works on Result<Option<T>, E>
self.api.get_operating_agent().await.unwrap_or_default()

// Option 2: Proper error handling with ? operator
let operating_agent = self.api.get_operating_agent().await?;

The second approach would require propagating the error up the call chain.

Suggested change
let operating_agent = self.api.get_operating_agent().await.unwrap_or(None);
let operating_agent = self.api.get_operating_agent().await.unwrap_or_default();

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@github-actions github-actions Bot added the type: chore Routine tasks like conversions, reorganization, and maintenance work. label Sep 4, 2025
@tusharmath tusharmath enabled auto-merge (squash) September 4, 2025 12:30
@tusharmath tusharmath merged commit aa2956c into main Sep 4, 2025
8 checks passed
@tusharmath tusharmath deleted the refactor-operating-agent branch September 4, 2025 12:33
@tusharmath tusharmath removed the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Sep 5, 2025
laststylebender14 pushed a commit that referenced this pull request Sep 11, 2025
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: chore Routine tasks like conversions, reorganization, and maintenance work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant