mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-05 08:10:39 +00:00
parent
6be42e7bff
commit
5cee60a84c
6 changed files with 307 additions and 18 deletions
|
|
@ -1,46 +1,51 @@
|
|||
{
|
||||
"timestamp": "2026-03-20T01:30:26.419646Z",
|
||||
"current_node": "implement",
|
||||
"timestamp": "2026-03-20T01:33:18.645444Z",
|
||||
"current_node": "simplify_opus",
|
||||
"completed_nodes": [
|
||||
"start",
|
||||
"toolchain",
|
||||
"preflight_compile",
|
||||
"preflight_lint",
|
||||
"implement"
|
||||
"implement",
|
||||
"simplify_opus"
|
||||
],
|
||||
"node_retries": {
|
||||
"start": 1,
|
||||
"preflight_compile": 1,
|
||||
"preflight_lint": 1,
|
||||
"simplify_opus": 1,
|
||||
"toolchain": 1,
|
||||
"implement": 1
|
||||
},
|
||||
"context_values": {
|
||||
"graph.model_stylesheet": "\n * { backend: api; model: claude-opus-4-6;}\n ",
|
||||
"internal.retry_count.toolchain": 1,
|
||||
"command.stderr": "",
|
||||
"command.output": "",
|
||||
"last_stage": "implement",
|
||||
"last_response": "All tests pass and clippy is clean. \n\n**Summary: The code is already clean — no changes needed.**\n\nThe three review agents found:\n- **No code reuse issues** — the one-liner JSON mapping is appropr",
|
||||
"response.implement": "All 390 tests pass and clippy is clean with zero warnings.\n\n## Summary\n\nImplemented the mapping of `reasoning_effort` to Anthropic's `output_config.effort` in three TDD steps:\n\n1. **Added two failing tests** — `build_api_request_maps_reasoning_effort_to_output_config` (asserts `output_config == Some({\"effort\": \"medium\"})`) and `build_api_request_omits_output_config_when_no_reasoning_effort` (asserts `output_config.is_none()`).\n\n2. **Added `output_config: Option<serde_json::Value>` field** to the `ApiRequest` struct (with `skip_serializing_if`), and set it to `None` in all existing construction sites. At this point Test B passed and Test A failed, proving the bug.\n\n3. **Mapped `reasoning_effort` → `output_config`** in `build_api_request` by computing `output_config` from `request.reasoning_effort` (mirroring the OpenAI provider pattern) and wiring it into the `ApiRequest` construction. Both tests now pass.",
|
||||
"internal.retry_count.preflight_compile": 1,
|
||||
"internal.thread_id": "implement",
|
||||
"internal.retry_count.preflight_lint": 1,
|
||||
"graph.goal": "# Plan: Map `reasoning_effort` to Anthropic `output_config.effort`\n\n## Context\n\nThe Anthropic Messages API now supports `output_config: { effort: \"low\" | \"medium\" | \"high\" | \"max\" }` as the recommended way to control thinking depth for Claude Opus 4.6 and Sonnet 4.6 (replacing deprecated `budget_tokens`). Fabro's unified `Request` already carries `reasoning_effort: Option<String>` and workflow nodes default it to `\"high\"`, but the Anthropic provider silently drops this field — it never appears in the API request. The OpenAI provider correctly maps it to `reasoning: { effort }`, but the Anthropic provider has no equivalent.\n\n## Single file to modify\n\n`lib/crates/fabro-llm/src/providers/anthropic.rs`\n\n## Step 1: Add failing tests\n\nAdd tests at the end of the `#[cfg(test)] mod tests` block (before line 2043's `}`). These tests reference a new `output_config` field on `ApiRequest` that doesn't exist yet, so they won't compile until Step 2.\n\n**Test A** — `build_api_request_maps_reasoning_effort_to_output_config`: Build a `Request` with `reasoning_effort: Some(\"medium\")`, call `build_api_request`, assert `api_request.output_config == Some(json!({\"effort\": \"medium\"}))`. Pattern: follows existing `build_api_request_omits_whitespace_only_system_prompt` test (line 1592).\n\n**Test B** — `build_api_request_omits_output_config_when_no_reasoning_effort`: Same but with `reasoning_effort: None`, assert `api_request.output_config.is_none()`.\n\n## Step 2: Add `output_config` field to `ApiRequest` struct\n\nAt line 108 (after `thinking`), add:\n\n```rust\n#[serde(skip_serializing_if = \"Option::is_none\")]\noutput_config: Option<serde_json::Value>,\n```\n\nUpdate every existing `ApiRequest` construction to include `output_config: None`:\n- line 1566 (serialization test)\n- line 1962 (merge_provider_options test)\n- line 1993 (merge_provider_options test)\n\nAt this point: code compiles, Test B passes, **Test A fails** (proving the bug exists).\n\n## Step 3: Map `reasoning_effort` → `output_config` in `build_api_request`\n\nAt line 1073 (next to the `thinking` extraction), add:\n\n```rust\nlet output_config = request\n .reasoning_effort\n .as_ref()\n .map(|effort| serde_json::json!({\"effort\": effort}));\n```\n\nAdd `output_config,` to the `ApiRequest` construction at line 1075.\n\nThis mirrors the OpenAI provider pattern at `openai.rs:385-388`.\n\nAll tests pass.\n\n## Verification\n\n```sh\ncargo test -p fabro-llm -- anthropic::tests::build_api_request_maps_reasoning_effort\ncargo test -p fabro-llm -- anthropic::tests::build_api_request_omits_output_config\ncargo test -p fabro-llm # all provider tests still pass\ncargo clippy --workspace -- -D warnings\n```\n",
|
||||
"current_node": "simplify_opus",
|
||||
"thread.start.current_node": "toolchain",
|
||||
"thread.preflight_compile.current_node": "preflight_lint",
|
||||
"internal.run_id": "01KM4DM88SB66SKQGPV0PE5TNJ",
|
||||
"graph.model_stylesheet": "\n * { backend: api; model: claude-opus-4-6;}\n ",
|
||||
"internal.retry_count.toolchain": 1,
|
||||
"last_stage": "simplify_opus",
|
||||
"internal.retry_count.simplify_opus": 1,
|
||||
"thread.implement.current_node": "simplify_opus",
|
||||
"failure_class": "",
|
||||
"thread.toolchain.current_node": "preflight_compile",
|
||||
"internal.retry_count.implement": 1,
|
||||
"response.implement": "All 390 tests pass and clippy is clean with zero warnings.\n\n## Summary\n\nImplemented the mapping of `reasoning_effort` to Anthropic's `output_config.effort` in three TDD steps:\n\n1. **Added two failing tests** — `build_api_request_maps_reasoning_effort_to_output_config` (asserts `output_config == Some({\"effort\": \"medium\"})`) and `build_api_request_omits_output_config_when_no_reasoning_effort` (asserts `output_config.is_none()`).\n\n2. **Added `output_config: Option<serde_json::Value>` field** to the `ApiRequest` struct (with `skip_serializing_if`), and set it to `None` in all existing construction sites. At this point Test B passed and Test A failed, proving the bug.\n\n3. **Mapped `reasoning_effort` → `output_config`** in `build_api_request` by computing `output_config` from `request.reasoning_effort` (mirroring the OpenAI provider pattern) and wiring it into the `ApiRequest` construction. Both tests now pass.",
|
||||
"internal.retry_count.preflight_compile": 1,
|
||||
"internal.node_visit_count": 1,
|
||||
"internal.thread_id": "preflight_lint",
|
||||
"internal.retry_count.preflight_lint": 1,
|
||||
"response.simplify_opus": "All tests pass and clippy is clean. \n\n**Summary: The code is already clean — no changes needed.**\n\nThe three review agents found:\n- **No code reuse issues** — the one-liner JSON mapping is appropriately inline in each provider\n- **No efficiency issues** — trivial cost on a network-bound code path \n- **One pre-existing quality observation** (stringly-typed `reasoning_effort`) that is out of scope for this change — it's a codebase-wide pattern that would require a multi-crate refactor to address properly",
|
||||
"internal.retry_count.start": 1,
|
||||
"internal.fidelity": "compact",
|
||||
"thread.preflight_lint.current_node": "implement",
|
||||
"last_response": "All 390 tests pass and clippy is clean with zero warnings.\n\n## Summary\n\nImplemented the mapping of `reasoning_effort` to Anthropic's `output_config.effort` in three TDD steps:\n\n1. **Added two failing ",
|
||||
"graph.goal": "# Plan: Map `reasoning_effort` to Anthropic `output_config.effort`\n\n## Context\n\nThe Anthropic Messages API now supports `output_config: { effort: \"low\" | \"medium\" | \"high\" | \"max\" }` as the recommended way to control thinking depth for Claude Opus 4.6 and Sonnet 4.6 (replacing deprecated `budget_tokens`). Fabro's unified `Request` already carries `reasoning_effort: Option<String>` and workflow nodes default it to `\"high\"`, but the Anthropic provider silently drops this field — it never appears in the API request. The OpenAI provider correctly maps it to `reasoning: { effort }`, but the Anthropic provider has no equivalent.\n\n## Single file to modify\n\n`lib/crates/fabro-llm/src/providers/anthropic.rs`\n\n## Step 1: Add failing tests\n\nAdd tests at the end of the `#[cfg(test)] mod tests` block (before line 2043's `}`). These tests reference a new `output_config` field on `ApiRequest` that doesn't exist yet, so they won't compile until Step 2.\n\n**Test A** — `build_api_request_maps_reasoning_effort_to_output_config`: Build a `Request` with `reasoning_effort: Some(\"medium\")`, call `build_api_request`, assert `api_request.output_config == Some(json!({\"effort\": \"medium\"}))`. Pattern: follows existing `build_api_request_omits_whitespace_only_system_prompt` test (line 1592).\n\n**Test B** — `build_api_request_omits_output_config_when_no_reasoning_effort`: Same but with `reasoning_effort: None`, assert `api_request.output_config.is_none()`.\n\n## Step 2: Add `output_config` field to `ApiRequest` struct\n\nAt line 108 (after `thinking`), add:\n\n```rust\n#[serde(skip_serializing_if = \"Option::is_none\")]\noutput_config: Option<serde_json::Value>,\n```\n\nUpdate every existing `ApiRequest` construction to include `output_config: None`:\n- line 1566 (serialization test)\n- line 1962 (merge_provider_options test)\n- line 1993 (merge_provider_options test)\n\nAt this point: code compiles, Test B passes, **Test A fails** (proving the bug exists).\n\n## Step 3: Map `reasoning_effort` → `output_config` in `build_api_request`\n\nAt line 1073 (next to the `thinking` extraction), add:\n\n```rust\nlet output_config = request\n .reasoning_effort\n .as_ref()\n .map(|effort| serde_json::json!({\"effort\": effort}));\n```\n\nAdd `output_config,` to the `ApiRequest` construction at line 1075.\n\nThis mirrors the OpenAI provider pattern at `openai.rs:385-388`.\n\nAll tests pass.\n\n## Verification\n\n```sh\ncargo test -p fabro-llm -- anthropic::tests::build_api_request_maps_reasoning_effort\ncargo test -p fabro-llm -- anthropic::tests::build_api_request_omits_output_config\ncargo test -p fabro-llm # all provider tests still pass\ncargo clippy --workspace -- -D warnings\n```\n",
|
||||
"current_node": "implement",
|
||||
"current.preamble": "Goal: # Plan: Map `reasoning_effort` to Anthropic `output_config.effort`\n\n## Context\n\nThe Anthropic Messages API now supports `output_config: { effort: \"low\" | \"medium\" | \"high\" | \"max\" }` as the recommended way to control thinking depth for Claude Opus 4.6 and Sonnet 4.6 (replacing deprecated `budget_tokens`). Fabro's unified `Request` already carries `reasoning_effort: Option<String>` and workflow nodes default it to `\"high\"`, but the Anthropic provider silently drops this field — it never appears in the API request. The OpenAI provider correctly maps it to `reasoning: { effort }`, but the Anthropic provider has no equivalent.\n\n## Single file to modify\n\n`lib/crates/fabro-llm/src/providers/anthropic.rs`\n\n## Step 1: Add failing tests\n\nAdd tests at the end of the `#[cfg(test)] mod tests` block (before line 2043's `}`). These tests reference a new `output_config` field on `ApiRequest` that doesn't exist yet, so they won't compile until Step 2.\n\n**Test A** — `build_api_request_maps_reasoning_effort_to_output_config`: Build a `Request` with `reasoning_effort: Some(\"medium\")`, call `build_api_request`, assert `api_request.output_config == Some(json!({\"effort\": \"medium\"}))`. Pattern: follows existing `build_api_request_omits_whitespace_only_system_prompt` test (line 1592).\n\n**Test B** — `build_api_request_omits_output_config_when_no_reasoning_effort`: Same but with `reasoning_effort: None`, assert `api_request.output_config.is_none()`.\n\n## Step 2: Add `output_config` field to `ApiRequest` struct\n\nAt line 108 (after `thinking`), add:\n\n```rust\n#[serde(skip_serializing_if = \"Option::is_none\")]\noutput_config: Option<serde_json::Value>,\n```\n\nUpdate every existing `ApiRequest` construction to include `output_config: None`:\n- line 1566 (serialization test)\n- line 1962 (merge_provider_options test)\n- line 1993 (merge_provider_options test)\n\nAt this point: code compiles, Test B passes, **Test A fails** (proving the bug exists).\n\n## Step 3: Map `reasoning_effort` → `output_config` in `build_api_request`\n\nAt line 1073 (next to the `thinking` extraction), add:\n\n```rust\nlet output_config = request\n .reasoning_effort\n .as_ref()\n .map(|effort| serde_json::json!({\"effort\": effort}));\n```\n\nAdd `output_config,` to the `ApiRequest` construction at line 1075.\n\nThis mirrors the OpenAI provider pattern at `openai.rs:385-388`.\n\nAll tests pass.\n\n## Verification\n\n```sh\ncargo test -p fabro-llm -- anthropic::tests::build_api_request_maps_reasoning_effort\ncargo test -p fabro-llm -- anthropic::tests::build_api_request_omits_output_config\ncargo test -p fabro-llm # all provider tests still pass\ncargo clippy --workspace -- -D warnings\n```\n\n\n## Completed stages\n- **toolchain**: success\n - Script: `command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1`\n - Stdout:\n ```\n cargo 1.94.0 (85eff7c80 2026-01-15)\n ```\n - Stderr: (empty)\n- **preflight_compile**: success\n - Script: `cargo check -q --workspace 2>&1`\n - Stdout: (empty)\n - Stderr: (empty)\n- **preflight_lint**: success\n - Script: `cargo clippy -q --workspace -- -D warnings 2>&1`\n - Stdout: (empty)\n - Stderr: (empty)\n",
|
||||
"current.preamble": "Goal: # Plan: Map `reasoning_effort` to Anthropic `output_config.effort`\n\n## Context\n\nThe Anthropic Messages API now supports `output_config: { effort: \"low\" | \"medium\" | \"high\" | \"max\" }` as the recommended way to control thinking depth for Claude Opus 4.6 and Sonnet 4.6 (replacing deprecated `budget_tokens`). Fabro's unified `Request` already carries `reasoning_effort: Option<String>` and workflow nodes default it to `\"high\"`, but the Anthropic provider silently drops this field — it never appears in the API request. The OpenAI provider correctly maps it to `reasoning: { effort }`, but the Anthropic provider has no equivalent.\n\n## Single file to modify\n\n`lib/crates/fabro-llm/src/providers/anthropic.rs`\n\n## Step 1: Add failing tests\n\nAdd tests at the end of the `#[cfg(test)] mod tests` block (before line 2043's `}`). These tests reference a new `output_config` field on `ApiRequest` that doesn't exist yet, so they won't compile until Step 2.\n\n**Test A** — `build_api_request_maps_reasoning_effort_to_output_config`: Build a `Request` with `reasoning_effort: Some(\"medium\")`, call `build_api_request`, assert `api_request.output_config == Some(json!({\"effort\": \"medium\"}))`. Pattern: follows existing `build_api_request_omits_whitespace_only_system_prompt` test (line 1592).\n\n**Test B** — `build_api_request_omits_output_config_when_no_reasoning_effort`: Same but with `reasoning_effort: None`, assert `api_request.output_config.is_none()`.\n\n## Step 2: Add `output_config` field to `ApiRequest` struct\n\nAt line 108 (after `thinking`), add:\n\n```rust\n#[serde(skip_serializing_if = \"Option::is_none\")]\noutput_config: Option<serde_json::Value>,\n```\n\nUpdate every existing `ApiRequest` construction to include `output_config: None`:\n- line 1566 (serialization test)\n- line 1962 (merge_provider_options test)\n- line 1993 (merge_provider_options test)\n\nAt this point: code compiles, Test B passes, **Test A fails** (proving the bug exists).\n\n## Step 3: Map `reasoning_effort` → `output_config` in `build_api_request`\n\nAt line 1073 (next to the `thinking` extraction), add:\n\n```rust\nlet output_config = request\n .reasoning_effort\n .as_ref()\n .map(|effort| serde_json::json!({\"effort\": effort}));\n```\n\nAdd `output_config,` to the `ApiRequest` construction at line 1075.\n\nThis mirrors the OpenAI provider pattern at `openai.rs:385-388`.\n\nAll tests pass.\n\n## Verification\n\n```sh\ncargo test -p fabro-llm -- anthropic::tests::build_api_request_maps_reasoning_effort\ncargo test -p fabro-llm -- anthropic::tests::build_api_request_omits_output_config\ncargo test -p fabro-llm # all provider tests still pass\ncargo clippy --workspace -- -D warnings\n```\n\n\n## Completed stages\n- **toolchain**: success\n - Script: `command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1`\n - Stdout:\n ```\n cargo 1.94.0 (85eff7c80 2026-01-15)\n ```\n - Stderr: (empty)\n- **preflight_compile**: success\n - Script: `cargo check -q --workspace 2>&1`\n - Stdout: (empty)\n - Stderr: (empty)\n- **preflight_lint**: success\n - Script: `cargo clippy -q --workspace -- -D warnings 2>&1`\n - Stdout: (empty)\n - Stderr: (empty)\n- **implement**: success\n - Model: claude-opus-4-6, 10.2k tokens in / 3.8k out\n - Files: /home/daytona/workspace/lib/crates/fabro-llm/src/providers/anthropic.rs\n",
|
||||
"outcome": "success",
|
||||
"thread.start.current_node": "toolchain",
|
||||
"failure_signature": "",
|
||||
"thread.preflight_compile.current_node": "preflight_lint",
|
||||
"internal.run_id": "01KM4DM88SB66SKQGPV0PE5TNJ",
|
||||
"graph.rankdir": "LR"
|
||||
},
|
||||
"logs": [],
|
||||
|
|
@ -85,6 +90,25 @@
|
|||
],
|
||||
"duration_ms": 125244
|
||||
},
|
||||
"simplify_opus": {
|
||||
"status": "success",
|
||||
"context_updates": {
|
||||
"last_stage": "simplify_opus",
|
||||
"last_response": "All tests pass and clippy is clean. \n\n**Summary: The code is already clean — no changes needed.**\n\nThe three review agents found:\n- **No code reuse issues** — the one-liner JSON mapping is appropr",
|
||||
"response.simplify_opus": "All tests pass and clippy is clean. \n\n**Summary: The code is already clean — no changes needed.**\n\nThe three review agents found:\n- **No code reuse issues** — the one-liner JSON mapping is appropriately inline in each provider\n- **No efficiency issues** — trivial cost on a network-bound code path \n- **One pre-existing quality observation** (stringly-typed `reasoning_effort`) that is out of scope for this change — it's a codebase-wide pattern that would require a multi-crate refactor to address properly"
|
||||
},
|
||||
"notes": "Stage completed: simplify_opus",
|
||||
"usage": {
|
||||
"model": "claude-opus-4-6",
|
||||
"input_tokens": 13217,
|
||||
"output_tokens": 4066,
|
||||
"cache_read_tokens": 78581,
|
||||
"cache_write_tokens": 18388,
|
||||
"reasoning_tokens": 291,
|
||||
"cost": 0.503205
|
||||
},
|
||||
"duration_ms": 166668
|
||||
},
|
||||
"start": {
|
||||
"status": "success",
|
||||
"duration_ms": 0
|
||||
|
|
@ -99,9 +123,10 @@
|
|||
"duration_ms": 69458
|
||||
}
|
||||
},
|
||||
"next_node_id": "simplify_opus",
|
||||
"next_node_id": "simplify_gpt",
|
||||
"node_visits": {
|
||||
"implement": 1,
|
||||
"simplify_opus": 1,
|
||||
"preflight_lint": 1,
|
||||
"toolchain": 1,
|
||||
"preflight_compile": 1,
|
||||
|
|
|
|||
113
nodes/implement/diff.patch
Normal file
113
nodes/implement/diff.patch
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
diff --git a/lib/crates/fabro-llm/src/providers/anthropic.rs b/lib/crates/fabro-llm/src/providers/anthropic.rs
|
||||
index 38dd9712..c40d5081 100644
|
||||
--- a/lib/crates/fabro-llm/src/providers/anthropic.rs
|
||||
+++ b/lib/crates/fabro-llm/src/providers/anthropic.rs
|
||||
@@ -107,6 +107,8 @@ struct ApiRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
thinking: Option<serde_json::Value>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
+ output_config: Option<serde_json::Value>,
|
||||
+ #[serde(skip_serializing_if = "Option::is_none")]
|
||||
metadata: Option<std::collections::HashMap<String, String>>,
|
||||
#[serde(skip_serializing_if = "std::ops::Not::not")]
|
||||
stream: bool,
|
||||
@@ -1072,6 +1074,11 @@ fn build_api_request(
|
||||
|
||||
let thinking = extract_thinking_config(request.provider_options.as_ref());
|
||||
|
||||
+ let output_config = request
|
||||
+ .reasoning_effort
|
||||
+ .as_ref()
|
||||
+ .map(|effort| serde_json::json!({"effort": effort}));
|
||||
+
|
||||
let api_request = ApiRequest {
|
||||
model: request.model.clone(),
|
||||
messages: api_messages,
|
||||
@@ -1088,6 +1095,7 @@ fn build_api_request(
|
||||
tools: api_tools,
|
||||
tool_choice: tool_choice_json,
|
||||
thinking,
|
||||
+ output_config,
|
||||
metadata: request.metadata.clone(),
|
||||
stream,
|
||||
};
|
||||
@@ -1577,6 +1585,7 @@ mod tests {
|
||||
tools: None,
|
||||
tool_choice: None,
|
||||
thinking: None,
|
||||
+ output_config: None,
|
||||
metadata: None,
|
||||
stream: false,
|
||||
};
|
||||
@@ -1973,6 +1982,7 @@ mod tests {
|
||||
tools: None,
|
||||
tool_choice: None,
|
||||
thinking: None,
|
||||
+ output_config: None,
|
||||
metadata: None,
|
||||
stream: false,
|
||||
};
|
||||
@@ -2004,6 +2014,7 @@ mod tests {
|
||||
tools: None,
|
||||
tool_choice: None,
|
||||
thinking: None,
|
||||
+ output_config: None,
|
||||
metadata: None,
|
||||
stream: false,
|
||||
};
|
||||
@@ -2026,6 +2037,55 @@ mod tests {
|
||||
assert_eq!(body["top_k"], 40);
|
||||
}
|
||||
|
||||
+ #[test]
|
||||
+ fn build_api_request_maps_reasoning_effort_to_output_config() {
|
||||
+ let adapter = Adapter::new("test-key");
|
||||
+ let request = Request {
|
||||
+ model: "claude-sonnet-4-20250514".to_string(),
|
||||
+ messages: vec![Message::user("Hello")],
|
||||
+ provider: Some("anthropic".to_string()),
|
||||
+ tools: None,
|
||||
+ tool_choice: None,
|
||||
+ response_format: None,
|
||||
+ temperature: None,
|
||||
+ top_p: None,
|
||||
+ max_tokens: Some(128),
|
||||
+ stop_sequences: None,
|
||||
+ reasoning_effort: Some("medium".to_string()),
|
||||
+ metadata: None,
|
||||
+ provider_options: None,
|
||||
+ };
|
||||
+
|
||||
+ let (api_request, _req_builder) = build_api_request(&adapter, &request, false);
|
||||
+ assert_eq!(
|
||||
+ api_request.output_config,
|
||||
+ Some(serde_json::json!({"effort": "medium"}))
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ #[test]
|
||||
+ fn build_api_request_omits_output_config_when_no_reasoning_effort() {
|
||||
+ let adapter = Adapter::new("test-key");
|
||||
+ let request = Request {
|
||||
+ model: "claude-sonnet-4-20250514".to_string(),
|
||||
+ messages: vec![Message::user("Hello")],
|
||||
+ provider: Some("anthropic".to_string()),
|
||||
+ tools: None,
|
||||
+ tool_choice: None,
|
||||
+ response_format: None,
|
||||
+ temperature: None,
|
||||
+ top_p: None,
|
||||
+ max_tokens: Some(128),
|
||||
+ stop_sequences: None,
|
||||
+ reasoning_effort: None,
|
||||
+ metadata: None,
|
||||
+ provider_options: None,
|
||||
+ };
|
||||
+
|
||||
+ let (api_request, _req_builder) = build_api_request(&adapter, &request, false);
|
||||
+ assert!(api_request.output_config.is_none());
|
||||
+ }
|
||||
+
|
||||
#[test]
|
||||
fn audio_produces_text_fallback() {
|
||||
let part = ContentPart::Audio(crate::types::AudioData {
|
||||
132
nodes/simplify_opus/prompt.md
Normal file
132
nodes/simplify_opus/prompt.md
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
Goal: # Plan: Map `reasoning_effort` to Anthropic `output_config.effort`
|
||||
|
||||
## Context
|
||||
|
||||
The Anthropic Messages API now supports `output_config: { effort: "low" | "medium" | "high" | "max" }` as the recommended way to control thinking depth for Claude Opus 4.6 and Sonnet 4.6 (replacing deprecated `budget_tokens`). Fabro's unified `Request` already carries `reasoning_effort: Option<String>` and workflow nodes default it to `"high"`, but the Anthropic provider silently drops this field — it never appears in the API request. The OpenAI provider correctly maps it to `reasoning: { effort }`, but the Anthropic provider has no equivalent.
|
||||
|
||||
## Single file to modify
|
||||
|
||||
`lib/crates/fabro-llm/src/providers/anthropic.rs`
|
||||
|
||||
## Step 1: Add failing tests
|
||||
|
||||
Add tests at the end of the `#[cfg(test)] mod tests` block (before line 2043's `}`). These tests reference a new `output_config` field on `ApiRequest` that doesn't exist yet, so they won't compile until Step 2.
|
||||
|
||||
**Test A** — `build_api_request_maps_reasoning_effort_to_output_config`: Build a `Request` with `reasoning_effort: Some("medium")`, call `build_api_request`, assert `api_request.output_config == Some(json!({"effort": "medium"}))`. Pattern: follows existing `build_api_request_omits_whitespace_only_system_prompt` test (line 1592).
|
||||
|
||||
**Test B** — `build_api_request_omits_output_config_when_no_reasoning_effort`: Same but with `reasoning_effort: None`, assert `api_request.output_config.is_none()`.
|
||||
|
||||
## Step 2: Add `output_config` field to `ApiRequest` struct
|
||||
|
||||
At line 108 (after `thinking`), add:
|
||||
|
||||
```rust
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
output_config: Option<serde_json::Value>,
|
||||
```
|
||||
|
||||
Update every existing `ApiRequest` construction to include `output_config: None`:
|
||||
- line 1566 (serialization test)
|
||||
- line 1962 (merge_provider_options test)
|
||||
- line 1993 (merge_provider_options test)
|
||||
|
||||
At this point: code compiles, Test B passes, **Test A fails** (proving the bug exists).
|
||||
|
||||
## Step 3: Map `reasoning_effort` → `output_config` in `build_api_request`
|
||||
|
||||
At line 1073 (next to the `thinking` extraction), add:
|
||||
|
||||
```rust
|
||||
let output_config = request
|
||||
.reasoning_effort
|
||||
.as_ref()
|
||||
.map(|effort| serde_json::json!({"effort": effort}));
|
||||
```
|
||||
|
||||
Add `output_config,` to the `ApiRequest` construction at line 1075.
|
||||
|
||||
This mirrors the OpenAI provider pattern at `openai.rs:385-388`.
|
||||
|
||||
All tests pass.
|
||||
|
||||
## Verification
|
||||
|
||||
```sh
|
||||
cargo test -p fabro-llm -- anthropic::tests::build_api_request_maps_reasoning_effort
|
||||
cargo test -p fabro-llm -- anthropic::tests::build_api_request_omits_output_config
|
||||
cargo test -p fabro-llm # all provider tests still pass
|
||||
cargo clippy --workspace -- -D warnings
|
||||
```
|
||||
|
||||
|
||||
## Completed stages
|
||||
- **toolchain**: success
|
||||
- Script: `command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1`
|
||||
- Stdout:
|
||||
```
|
||||
cargo 1.94.0 (85eff7c80 2026-01-15)
|
||||
```
|
||||
- Stderr: (empty)
|
||||
- **preflight_compile**: success
|
||||
- Script: `cargo check -q --workspace 2>&1`
|
||||
- Stdout: (empty)
|
||||
- Stderr: (empty)
|
||||
- **preflight_lint**: success
|
||||
- Script: `cargo clippy -q --workspace -- -D warnings 2>&1`
|
||||
- Stdout: (empty)
|
||||
- Stderr: (empty)
|
||||
- **implement**: success
|
||||
- Model: claude-opus-4-6, 10.2k tokens in / 3.8k out
|
||||
- Files: /home/daytona/workspace/lib/crates/fabro-llm/src/providers/anthropic.rs
|
||||
|
||||
|
||||
# Simplify: Code Review and Cleanup
|
||||
|
||||
Review all changed files for reuse, quality, and efficiency. Fix any issues found.
|
||||
|
||||
## Phase 1: Identify Changes
|
||||
|
||||
Run git diff (or git diff HEAD if there are staged changes) to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that you edited earlier in this conversation.
|
||||
|
||||
## Phase 2: Launch Three Review Agents in Parallel
|
||||
|
||||
Use the Agent tool to launch all three agents concurrently in a single message. Pass each agent the full diff so it has the complete context.
|
||||
|
||||
### Agent 1: Code Reuse Review
|
||||
|
||||
For each change:
|
||||
|
||||
1. Search for existing utilities and helpers that could replace newly written code. Use Grep to find similar patterns elsewhere in the codebase — common locations are utility directories, shared modules, and files adjacent to the changed ones.
|
||||
2. Flag any new function that duplicates existing functionality. Suggest the existing function to use instead.
|
||||
3. Flag any inline logic that could use an existing utility — hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, and similar patterns are common candidates.
|
||||
|
||||
Note: This is a greenfield app, so focus on maximizing simplicity and don't worry about changing things to achieve it.
|
||||
|
||||
### Agent 2: Code Quality Review
|
||||
|
||||
Review the same changes for hacky patterns:
|
||||
|
||||
1. Redundant state: state that duplicates existing state, cached values that could be derived, observers/effects that could be direct calls
|
||||
2. Parameter sprawl: adding new parameters to a function instead of generalizing or restructuring existing ones
|
||||
3. Copy-paste with slight variation: near-duplicate code blocks that should be unified with a shared abstraction
|
||||
4. Leaky abstractions: exposing internal details that should be encapsulated, or breaking existing abstraction boundaries
|
||||
5. Stringly-typed code: using raw strings where constants, enums (string unions), or branded types already exist in the codebase
|
||||
|
||||
Note: This is a greenfield app, so be aggressive in optimizing quality.
|
||||
|
||||
### Agent 3: Efficiency Review
|
||||
|
||||
Review the same changes for efficiency:
|
||||
|
||||
1. Unnecessary work: redundant computations, repeated file reads, duplicate network/API calls, N+1 patterns
|
||||
2. Missed concurrency: independent operations run sequentially when they could run in parallel
|
||||
3. Hot-path bloat: new blocking work added to startup or per-request/per-render hot paths
|
||||
4. Unnecessary existence checks: pre-checking file/resource existence before operating (TOCTOU anti-pattern) — operate directly and handle the error
|
||||
5. Memory: unbounded data structures, missing cleanup, event listener leaks
|
||||
6. Overly broad operations: reading entire files when only a portion is needed, loading all items when filtering for one
|
||||
|
||||
## Phase 3: Fix Issues
|
||||
|
||||
Wait for all three agents to complete. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on — do not argue with the finding, just skip it.
|
||||
|
||||
When done, briefly summarize what was fixed (or confirm the code was already clean).
|
||||
5
nodes/simplify_opus/provider_used.json
Normal file
5
nodes/simplify_opus/provider_used.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"mode": "agent",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-opus-4-6"
|
||||
}
|
||||
8
nodes/simplify_opus/response.md
Normal file
8
nodes/simplify_opus/response.md
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
All tests pass and clippy is clean.
|
||||
|
||||
**Summary: The code is already clean — no changes needed.**
|
||||
|
||||
The three review agents found:
|
||||
- **No code reuse issues** — the one-liner JSON mapping is appropriately inline in each provider
|
||||
- **No efficiency issues** — trivial cost on a network-bound code path
|
||||
- **One pre-existing quality observation** (stringly-typed `reasoning_effort`) that is out of scope for this change — it's a codebase-wide pattern that would require a multi-crate refactor to address properly
|
||||
6
nodes/simplify_opus/status.json
Normal file
6
nodes/simplify_opus/status.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"status": "success",
|
||||
"notes": "Stage completed: simplify_opus",
|
||||
"failure_reason": null,
|
||||
"timestamp": "2026-03-20T01:33:18.644825+00:00"
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue