Skip to content

Commit 5bfe035

Browse files
[autofix.ci] apply automated fixes
1 parent f4c4fbf commit 5bfe035

139 files changed

Lines changed: 1206 additions & 835 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crates/forge_api/src/forge_api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ impl<
241241
}
242242

243243
async fn update_config(&self, ops: Vec<forge_domain::ConfigOperation>) -> anyhow::Result<()> {
244-
// Determine whether any op affects provider/model resolution before writing,
245-
// so we can invalidate the agent cache afterwards.
244+
// Determine whether any op affects provider/model resolution before
245+
// writing, so we can invalidate the agent cache afterwards.
246246
let needs_agent_reload = ops
247247
.iter()
248248
.any(|op| matches!(op, forge_domain::ConfigOperation::SetSessionConfig(_)));

crates/forge_app/src/agent.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ impl AgentExt for Agent {
130130

131131
// Apply workflow compact configuration to agents
132132
if let Some(ref workflow_compact) = config.compact {
133-
// Convert forge_config::Compact to forge_domain::Compact, then merge.
134-
// Agent settings take priority over workflow settings.
133+
// Convert forge_config::Compact to forge_domain::Compact, then
134+
// merge. Agent settings take priority over workflow
135+
// settings.
135136
let mut merged_compact = Compact {
136137
retention_window: workflow_compact.retention_window,
137138
eviction_window: workflow_compact.eviction_window.value(),
@@ -169,7 +170,8 @@ impl AgentExt for Agent {
169170
exclude: config_reasoning.exclude,
170171
enabled: config_reasoning.enabled,
171172
};
172-
// Start from the agent's own settings and fill unset fields from config.
173+
// Start from the agent's own settings and fill unset fields from
174+
// config.
173175
let mut merged = agent.reasoning.clone().unwrap_or_default();
174176
merged.merge(config_as_domain);
175177
// If the config explicitly disables reasoning, honour that override
@@ -302,8 +304,8 @@ mod tests {
302304

303305
// CURRENT BEHAVIOR: Due to merge order (workflow_compact merged with
304306
// agent.compact), agent's retention_window=0 overwrites workflow's 10
305-
// This is the documented behavior: "Agent settings take priority over workflow
306-
// settings"
307+
// This is the documented behavior: "Agent settings take priority over
308+
// workflow settings"
307309

308310
// Agent default has retention_window=0, which overwrites workflow's 10
309311
assert_eq!(

crates/forge_app/src/agent_executor.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ impl<S: Services + EnvironmentInfra<Config = forge_config::ForgeConfig>> AgentEx
6363
.await?
6464
.ok_or(Error::ConversationNotFound { id: conversation_id })?
6565
} else {
66-
// Create context with agent initiator since it's spawned by a parent agent
67-
// This is crucial for GitHub Copilot billing optimization
66+
// Create context with agent initiator since it's spawned by a
67+
// parent agent This is crucial for GitHub Copilot
68+
// billing optimization
6869
let context = forge_domain::Context::default().initiator("agent".to_string());
6970
let conversation = Conversation::generate()
7071
.title(task.clone())

crates/forge_app/src/agent_provider_resolver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ where
2828
// Load all agent definitions and find the one we need
2929

3030
if let Some(agent) = self.0.get_agent(&agent_id).await? {
31-
// If the agent definition has a provider, use it; otherwise use default
31+
// If the agent definition has a provider, use it; otherwise use
32+
// default
3233
agent.provider
3334
} else {
3435
// TODO: Needs review, should we throw an err here?

crates/forge_app/src/app.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ impl<S: Services + EnvironmentInfra<Config = forge_config::ForgeConfig>> ForgeAp
148148
let tracing_handler = TracingHandler::new();
149149
let title_handler = TitleGenerationHandler::new(services.clone());
150150

151-
// Build the on_end hook, conditionally adding PendingTodosHandler based on
152-
// config
151+
// Build the on_end hook, conditionally adding PendingTodosHandler based
152+
// on config
153153
let on_end_hook = if forge_config.verify_todos {
154154
tracing_handler
155155
.clone()
@@ -194,7 +194,8 @@ impl<S: Services + EnvironmentInfra<Config = forge_config::ForgeConfig>> ForgeAp
194194
let conversation = orch.get_conversation().clone();
195195
let save_result = services.upsert_conversation(conversation).await;
196196

197-
// Send any error to the stream (prioritize dispatch error over save error)
197+
// Send any error to the stream (prioritize dispatch error
198+
// over save error)
198199
#[allow(clippy::collapsible_if)]
199200
if let Some(err) = dispatch_result.err().or(save_result.err()) {
200201
if let Err(e) = tx.send(Err(err)).await {
@@ -306,7 +307,8 @@ impl<S: Services + EnvironmentInfra<Config = forge_config::ForgeConfig>> ForgeAp
306307
pub async fn get_all_provider_models(&self) -> Result<Vec<ProviderModels>> {
307308
let all_providers = self.services.get_all_providers().await?;
308309

309-
// Build one future per configured provider, preserving the error on failure.
310+
// Build one future per configured provider, preserving the error on
311+
// failure.
310312
let futures: Vec<_> = all_providers
311313
.into_iter()
312314
.filter_map(|any_provider| any_provider.into_configured())

crates/forge_app/src/command_generator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ mod tests {
229229
.map(|(path, is_dir)| File { path: path.clone(), is_dir: *is_dir })
230230
.collect();
231231

232-
// Sort: directories first (alphabetically), then files (alphabetically)
232+
// Sort: directories first (alphabetically), then files
233+
// (alphabetically)
233234
files.sort_by(|a, b| match (a.is_dir, b.is_dir) {
234235
(true, false) => std::cmp::Ordering::Less,
235236
(false, true) => std::cmp::Ordering::Greater,

crates/forge_app/src/compact.rs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ impl Compactor {
113113
// chains. After compaction, this consistency can break if the first
114114
// remaining assistant lacks reasoning.
115115
//
116-
// Solution: Extract the LAST reasoning from compacted messages and inject it
117-
// into the first assistant message after compaction. This preserves
118-
// chain continuity while preventing exponential accumulation across
119-
// multiple compactions.
116+
// Solution: Extract the LAST reasoning from compacted messages and
117+
// inject it into the first assistant message after compaction.
118+
// This preserves chain continuity while preventing exponential
119+
// accumulation across multiple compactions.
120120
//
121121
// Example: [U, A+r, U, A+r, U, A] → compact → [U-summary, A+r, U, A]
122122
// └─from last
@@ -133,8 +133,8 @@ impl Compactor {
133133
_ => None,
134134
});
135135

136-
// Accumulate usage from all messages in the compaction range before they are
137-
// destroyed
136+
// Accumulate usage from all messages in the compaction range before
137+
// they are destroyed
138138
let compacted_usage = context.messages.get(start..=end).and_then(|slice| {
139139
slice
140140
.iter()
@@ -143,7 +143,8 @@ impl Compactor {
143143
.reduce(|a, b| a.accumulate(&b))
144144
});
145145

146-
// Replace the range with the summary, transferring the accumulated usage
146+
// Replace the range with the summary, transferring the accumulated
147+
// usage
147148
let mut summary_entry = MessageEntry::from(ContextMessage::user(summary, None));
148149
summary_entry.usage = compacted_usage;
149150
context
@@ -289,7 +290,8 @@ mod tests {
289290

290291
let context = compactor.compress_single_sequence(context, (0, 2)).unwrap();
291292

292-
// Verify reasoning didn't accumulate - should still be just 1 reasoning block
293+
// Verify reasoning didn't accumulate - should still be just 1 reasoning
294+
// block
293295
let first_assistant = context
294296
.messages
295297
.iter()
@@ -318,7 +320,8 @@ mod tests {
318320
..Default::default()
319321
}];
320322

321-
// Most recent message in range has empty reasoning, earlier has non-empty
323+
// Most recent message in range has empty reasoning, earlier has
324+
// non-empty
322325
let context = Context::default()
323326
.add_message(ContextMessage::user("M1", None))
324327
.add_message(ContextMessage::assistant(
@@ -647,8 +650,9 @@ mod tests {
647650
"Summary message should carry accumulated usage from compacted messages"
648651
);
649652

650-
// accumulate_usage() must sum both the compacted range usage (on the summary
651-
// message) and the surviving outside_usage — total = inside + inside2 + outside
653+
// accumulate_usage() must sum both the compacted range usage (on the
654+
// summary message) and the surviving outside_usage — total =
655+
// inside + inside2 + outside
652656
let expected_total_usage = Usage {
653657
total_tokens: TokenCount::Actual(100000),
654658
prompt_tokens: TokenCount::Actual(90000),
@@ -855,17 +859,19 @@ mod tests {
855859
// - Safe threshold (89.6K): ~95K tokens, SHOULD compact (true)
856860
//
857861
// At turn 2:
858-
// - Unsafe threshold (100K): ~110K tokens, SHOULD compact (true) - but too
859-
// late!
862+
// - Unsafe threshold (100K): ~110K tokens, SHOULD compact (true) - but
863+
// too late!
860864
// - Safe threshold (89.6K): ~110K tokens, already compacted at turn 1
861865

862-
// Verify that safe threshold triggers at turn 1 (providing early warning)
866+
// Verify that safe threshold triggers at turn 1 (providing early
867+
// warning)
863868
let safe_token_count_turn1 = 95_000; // Approximate
864869
let safe_should_compact_turn1 =
865870
safe_compact.should_compact(&safe_context, safe_token_count_turn1);
866871

867-
// The key fix: safe threshold (89.6K) triggers at ~95K, while unsafe (100K)
868-
// doesn't This provides a safety margin before we hit the 128K limit
872+
// The key fix: safe threshold (89.6K) triggers at ~95K, while unsafe
873+
// (100K) doesn't This provides a safety margin before we hit
874+
// the 128K limit
869875
assert!(
870876
safe_should_compact_turn1 || safe_token_count_turn1 < 89_600,
871877
"Safe threshold (89.6K) should trigger compaction at ~95K tokens to provide safety margin"
@@ -876,8 +882,8 @@ mod tests {
876882
let final_unsafe = unsafe_context.token_count_approx();
877883
let final_safe = safe_context.token_count_approx();
878884

879-
// Both should be identical since we're just testing threshold logic, not actual
880-
// compaction
885+
// Both should be identical since we're just testing threshold logic,
886+
// not actual compaction
881887
assert_eq!(
882888
final_unsafe, final_safe,
883889
"Both contexts should have same token count"

crates/forge_app/src/dto/anthropic/request.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ impl TryFrom<forge_domain::Context> for Request {
129129
// a positive effort / `max_tokens` still emit reasoning on the wire.
130130
let reasoning_on = request.is_reasoning_supported();
131131
let (thinking, output_config) = if reasoning_on && let Some(reasoning) = request.reasoning {
132-
// Adaptive thinking on 4.7 hides reasoning content by default; opting
133-
// into reasoning should surface it unless the caller set `exclude`.
132+
// Adaptive thinking on 4.7 hides reasoning content by default;
133+
// opting into reasoning should surface it unless the
134+
// caller set `exclude`.
134135
let adaptive_display = if reasoning.exclude == Some(true) {
135136
Some(ThinkingDisplay::Omitted)
136137
} else {
@@ -185,7 +186,8 @@ impl TryFrom<forge_domain::Context> for Request {
185186
output_config,
186187
output_format: request.response_format.and_then(|rf| match rf {
187188
forge_domain::ResponseFormat::Text => {
188-
// Anthropic doesn't have a "text" output format, so we skip it
189+
// Anthropic doesn't have a "text" output format, so we skip
190+
// it
189191
None
190192
}
191193
forge_domain::ResponseFormat::JsonSchema(schema) => {
@@ -260,7 +262,8 @@ impl TryFrom<ContextMessage> for Message {
260262
forge_domain::Role::User => Message { role: Role::User, content },
261263
forge_domain::Role::Assistant => Message { role: Role::Assistant, content },
262264
forge_domain::Role::System => {
263-
// note: Anthropic doesn't support system role messages and they're already
265+
// note: Anthropic doesn't support system role messages
266+
// and they're already
264267
// filtered out. so this state is unreachable.
265268
return Err(
266269
forge_domain::Error::UnsupportedRole("System".to_string()).into()
@@ -285,7 +288,8 @@ impl Message {
285288
*content = std::mem::take(content).cached(false);
286289
}
287290

288-
// If enabling cache, set cache control on the last cacheable content item
291+
// If enabling cache, set cache control on the last cacheable content
292+
// item
289293
if enable_cache
290294
&& let Some(last_cacheable_idx) =
291295
self.content
@@ -592,7 +596,8 @@ mod tests {
592596

593597
#[test]
594598
fn test_reasoning_max_tokens_and_effort_emit_both() {
595-
// Effort and budget are independent knobs — neither should hide the other.
599+
// Effort and budget are independent knobs — neither should hide the
600+
// other.
596601
let fixture = Context::default().reasoning(ReasoningConfig {
597602
effort: Some(forge_domain::Effort::Low),
598603
enabled: Some(true),
@@ -735,9 +740,9 @@ mod tests {
735740

736741
#[test]
737742
fn test_reasoning_enabled_none_with_max_tokens_still_emits_thinking() {
738-
// Matches the domain's `is_reasoning_supported` rule: enabled: None with a
739-
// positive budget counts as on, so inherited/merged configs don't silently
740-
// disable reasoning on the wire.
743+
// Matches the domain's `is_reasoning_supported` rule: enabled: None
744+
// with a positive budget counts as on, so inherited/merged
745+
// configs don't silently disable reasoning on the wire.
741746
let fixture = Context::default().reasoning(ReasoningConfig {
742747
enabled: None,
743748
max_tokens: Some(8000),

crates/forge_app/src/dto/anthropic/response.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ impl From<Usage> for forge_domain::Usage {
164164
fn from(usage: Usage) -> Self {
165165
// Anthropic token breakdown:
166166
// - input_tokens: tokens NOT from cache (billed at full price)
167-
// - cache_creation_input_tokens: tokens written to cache (billed at full price
167+
// - cache_creation_input_tokens: tokens written to cache (billed at
168+
// full price
168169
// + write cost)
169-
// - cache_read_input_tokens: tokens read from cache (billed at 90% discount)
170+
// - cache_read_input_tokens: tokens read from cache (billed at 90%
171+
// discount)
170172
// Total input = input_tokens + cache_creation_input_tokens +
171173
// cache_read_input_tokens
172174

@@ -320,7 +322,8 @@ impl TryFrom<Event> for ChatCompletionMessage {
320322
ChatCompletionMessage::try_from(content_block)?
321323
}
322324
Event::MessageStart { message } => {
323-
// Extract usage from MessageStart - this contains input token counts
325+
// Extract usage from MessageStart - this contains input token
326+
// counts
324327
ChatCompletionMessage::assistant(Content::part("")).usage(message.usage)
325328
}
326329
Event::MessageDelta { delta, usage } => {
@@ -332,7 +335,8 @@ impl TryFrom<Event> for ChatCompletionMessage {
332335
return Err(error.into());
333336
}
334337
Event::Ping { cost: Some(cost) } => {
335-
// OpenCode Zen sends cost in a ping event at the end of the stream
338+
// OpenCode Zen sends cost in a ping event at the end of the
339+
// stream
336340
let cost_value = match cost {
337341
StringOrF64::Number(n) => n,
338342
StringOrF64::String(s) => s.parse().unwrap_or(0.0),
@@ -395,8 +399,9 @@ impl TryFrom<ContentBlock> for ChatCompletionMessage {
395399
)
396400
}
397401
ContentBlock::ToolUse { id, name, input } => {
398-
// note: We've to check if the input is empty or null. else we end up adding
399-
// empty object `{}` as prefix to tool args.
402+
// note: We've to check if the input is empty or null. else we
403+
// end up adding empty object `{}` as prefix to
404+
// tool args.
400405
let is_empty =
401406
input.is_null() || input.as_object().is_some_and(|map| map.is_empty());
402407
ChatCompletionMessage::assistant(Content::part("")).add_tool_call(ToolCallPart {
@@ -565,8 +570,8 @@ mod tests {
565570
let expected_prompt = TokenCount::Actual(100 + 200 + 300);
566571
assert_eq!(actual.prompt_tokens, expected_prompt);
567572

568-
// cached_tokens should only include cache reads (tokens that benefited from
569-
// caching)
573+
// cached_tokens should only include cache reads (tokens that benefited
574+
// from caching)
570575
let expected_cached = TokenCount::Actual(300);
571576
assert_eq!(actual.cached_tokens, expected_cached);
572577

crates/forge_app/src/dto/anthropic/transforms/enforce_schema.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ impl Transformer for EnforceStrictObjectSchema {
3737
if let Some(OutputFormat::JsonSchema { schema }) = request.output_format.take() {
3838
// Convert schema to JSON value for normalization
3939
if let Ok(mut schema_value) = serde_json::to_value(&schema) {
40-
// Use non-strict mode (false) for Anthropic - only adds additionalProperties
40+
// Use non-strict mode (false) for Anthropic - only adds
41+
// additionalProperties
4142
enforce_strict_schema(&mut schema_value, false);
4243

4344
// Convert back to RootSchema

0 commit comments

Comments
 (0)