mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-25 14:53:34 +00:00
* feat: add AWS Bedrock LLM provider via native Converse API * fix: use JSON parsing for tool result error detection instead of brittle substring matching * refactor: extract duplicated inference config builder into helper function * fix: address review feedback — safe casts, input validation, and tests - Safe u32→i32 cast for max_tokens using try_from with clamp - Remove brittle string-based error detection fallback for tool results - Validate BEDROCK_CROSS_REGION against allowed values (us/eu/apac/global) - Validate message list is non-empty before Converse API call - Log when using default us-east-1 region - Update llm_backend doc comment to list all backends - Add tests for build_inference_config and empty message handling * fix: persist AWS_PROFILE for Bedrock named profile auth The wizard collected the profile name but only printed a hint to set it manually. Now it saves to settings and writes AWS_PROFILE to the bootstrap .env, consistent with how BEDROCK_REGION and other Bedrock settings are persisted. * feat: gate AWS Bedrock behind optional `bedrock` feature flag The AWS SDK dependencies (aws-config, aws-sdk-bedrockruntime, aws-smithy-types) require cmake and a C compiler to build aws-lc-sys. Gate them behind an opt-in `bedrock` feature flag so default builds are unaffected. Build with: cargo build --features bedrock All config, settings, and wizard code stays unconditional (no AWS deps) so users can configure Bedrock even without the feature compiled — they get a clear error at startup directing them to rebuild. * fix: address review feedback and adapt Bedrock provider to registry architecture (takeover #345) - Resolve merge conflicts with main's registry-based provider system - Add missing cache_creation_input_tokens/cache_read_input_tokens fields - Add missing content_parts field in test ChatMessage - Fix string literal type mismatches in wizard env_vars (.to_string()) - Remove non-functional bearer token auth (AWS_BEARER_TOKEN_BEDROCK) from wizard and documentation per reviewer feedback from @zmanian and @serrrfirat - Remove stale BEDROCK_ACCESS_KEY proxy entry from provider table - Update Bedrock provider to use is_bedrock string check (LlmBackend enum removed) - Add bedrock_profile fallback from settings in config resolution [skip-regression-check] Co-Authored-By: cgorski <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: use main's Cargo.lock as base to preserve dependency versions Regenerating Cargo.lock from scratch caused transitive dependency version drift that broke the html_to_markdown fixture test in CI. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: bedrock config bugs — spurious warning, alias normalization, profile fallback - Move is_bedrock check before unknown-backend warning to prevent spurious "unknown backend" log for bedrock users - Normalize backend aliases ("aws", "aws_bedrock") to "bedrock" so the provider factory matches correctly - Add settings.bedrock_profile fallback for AWS_PROFILE, consistent with region and cross_region resolution [skip-regression-check] Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: address Copilot review feedback — bearer token cleanup, stop_sequences, model dedup - Remove stale bearer token refs from setup README and CHANGELOG - Remove dead bedrock_api_key secret injection mapping - Pass stop_sequences through to Bedrock InferenceConfiguration - Remove "API key" from wizard menu description (bearer token removed) - Skip duplicate LLM_MODEL write for bedrock backend in wizard - Fix cargo fmt formatting [skip-regression-check] Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: address review feedback — async new(), remove LiteLLM entry, wizard fixes - Remove dead LiteLLM-based bedrock entry from providers.json (native Converse API intercepts before registry lookup) - Make BedrockProvider::new() async to avoid block_in_place panic in current_thread runtimes; propagate async to create_llm_provider, build_provider_chain, and init_llm - Document CMake build prerequisite in docs/LLM_PROVIDERS.md - Clear bedrock_profile when user selects "default credentials" in wizard - Fix selected_model clearing to match established pattern (conditional on provider switch, not unconditional) - Add regression tests for bedrock model preservation and profile clearing Addresses review feedback from @zmanian on PR #713. Streaming support tracked in #741. [skip-regression-check] Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: address remaining review comments — CLAUDE.md backends, wizard UX - Add `bedrock` to CLAUDE.md inline backend list (#10) - Skip full setup re-run when keeping existing Bedrock config (#11) - Clear stale bedrock_profile on empty named-profile input (#12) - Add regression test for empty profile clearing Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Chris Gorski <[email protected]> Co-authored-by: cgorski <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
124 lines
4.2 KiB
Rust
124 lines
4.2 KiB
Rust
#![cfg(feature = "postgres")]
|
|
//! Heartbeat integration test.
|
|
//!
|
|
//! Exercises the heartbeat system in isolation: connects to the real
|
|
//! database, reads the real HEARTBEAT.md, calls the real LLM, and prints
|
|
//! every step so you can see exactly where it breaks.
|
|
//!
|
|
//! Usage:
|
|
//! cargo test --test heartbeat_integration -- --ignored --nocapture
|
|
|
|
use std::sync::Arc;
|
|
|
|
use ironclaw::{
|
|
agent::HeartbeatRunner,
|
|
config::Config,
|
|
history::Store,
|
|
llm::{create_llm_provider, create_session_manager},
|
|
workspace::Workspace,
|
|
};
|
|
|
|
#[tokio::test]
|
|
#[ignore] // Requires running database and LLM credentials
|
|
async fn test_heartbeat_end_to_end() {
|
|
// Load .env and set up logging
|
|
let _ = dotenvy::dotenv();
|
|
let _ = tracing_subscriber::fmt()
|
|
.with_env_filter("ironclaw=debug")
|
|
.try_init();
|
|
|
|
println!("=== Heartbeat Integration Test ===\n");
|
|
|
|
// 1. Load config
|
|
let config = Config::from_env().await.expect("Failed to load config");
|
|
println!("[1/6] Config loaded");
|
|
println!(" heartbeat.enabled = {}", config.heartbeat.enabled);
|
|
println!(
|
|
" heartbeat.interval_secs = {}",
|
|
config.heartbeat.interval_secs
|
|
);
|
|
println!(
|
|
" heartbeat.notify_channel = {:?}",
|
|
config.heartbeat.notify_channel
|
|
);
|
|
println!(
|
|
" heartbeat.notify_user = {:?}",
|
|
config.heartbeat.notify_user
|
|
);
|
|
|
|
// 2. Connect to database
|
|
let store = Store::new(&config.database)
|
|
.await
|
|
.expect("Failed to connect to database");
|
|
store
|
|
.run_migrations()
|
|
.await
|
|
.expect("Failed to run migrations");
|
|
println!("[2/6] Database connected");
|
|
|
|
// 3. Create workspace
|
|
let workspace = Arc::new(Workspace::new("default", store.pool()));
|
|
println!("[3/6] Workspace created");
|
|
|
|
// 4. Read HEARTBEAT.md
|
|
let checklist = workspace.heartbeat_checklist().await;
|
|
match &checklist {
|
|
Ok(Some(content)) => {
|
|
let preview: String = content.chars().take(200).collect();
|
|
println!("[4/6] HEARTBEAT.md found ({} chars)", content.len());
|
|
println!(" Preview: {}...", preview);
|
|
}
|
|
Ok(None) => {
|
|
println!("[4/6] HEARTBEAT.md is None (no file, no seed fallback)");
|
|
println!(" Heartbeat will return Skipped.");
|
|
}
|
|
Err(e) => {
|
|
println!("[4/6] HEARTBEAT.md read error: {}", e);
|
|
}
|
|
}
|
|
|
|
// Check if the checklist would be considered "effectively empty"
|
|
if let Ok(Some(_)) = checklist {
|
|
println!(" (Will verify via runner below)");
|
|
}
|
|
|
|
// 5. Create LLM provider
|
|
let session = create_session_manager(config.llm.session.clone()).await;
|
|
let llm = create_llm_provider(&config.llm, session)
|
|
.await
|
|
.expect("Failed to create LLM provider");
|
|
println!("[5/6] LLM provider created (model: {})", llm.model_name());
|
|
|
|
// 6. Run heartbeat check
|
|
println!("[6/6] Running check_heartbeat()...\n");
|
|
|
|
let hb_config = ironclaw::agent::HeartbeatConfig::default();
|
|
let hygiene_config = ironclaw::workspace::hygiene::HygieneConfig::default();
|
|
let runner = HeartbeatRunner::new(hb_config, hygiene_config, workspace, llm);
|
|
|
|
let result = runner.check_heartbeat().await;
|
|
|
|
println!("=== Result ===\n");
|
|
match &result {
|
|
ironclaw::agent::HeartbeatResult::Ok => {
|
|
println!("HeartbeatResult::Ok");
|
|
println!(" LLM responded HEARTBEAT_OK, nothing needs attention.");
|
|
}
|
|
ironclaw::agent::HeartbeatResult::NeedsAttention(msg) => {
|
|
println!("HeartbeatResult::NeedsAttention");
|
|
println!(" Message:\n{}", msg);
|
|
}
|
|
ironclaw::agent::HeartbeatResult::Skipped => {
|
|
println!("HeartbeatResult::Skipped");
|
|
println!(" No checklist found, or checklist was effectively empty.");
|
|
println!(" This means the HEARTBEAT.md either:");
|
|
println!(" - Does not exist in the workspace database");
|
|
println!(" - Contains only headers, comments, and empty checkboxes");
|
|
}
|
|
ironclaw::agent::HeartbeatResult::Failed(err) => {
|
|
println!("HeartbeatResult::Failed");
|
|
println!(" Error: {}", err);
|
|
}
|
|
}
|
|
}
|