Route Bedrock through Rig and improve agent observability

This commit is contained in:
2026-08-22 12:02:45 -05:00
parent 1f1d0737a9
commit f291cfe803
28 changed files with 519 additions and 938 deletions
+1 -1
View File
@@ -163,7 +163,7 @@ impl RuntimeResponseTranslator {
let mut events = Vec::new();
match event {
AgentEvent::TurnStarted { .. } => self.initialize(&mut events),
AgentEvent::KeepAlive => {}
AgentEvent::KeepAlive | AgentEvent::ToolCallProgress { .. } => {}
AgentEvent::TextDelta { text } => {
self.initialize(&mut events);
self.add_or_append_text(&text, &mut events);
@@ -18,6 +18,8 @@ use instant::Instant;
use warpui::r#async::Timer;
use crate::ai::agent::conversation::AIConversationId;
#[cfg(not(target_family = "wasm"))]
use crate::ai::model_output_logging;
pub(crate) const BASE_PROVIDER_PROFILE: &str = "base";
pub(crate) const CLI_MONITOR_PROVIDER_PROFILE: &str = "cli-monitor";
@@ -597,6 +599,18 @@ impl ProviderRunCoordinator {
return Ok(());
}
};
#[cfg(not(target_family = "wasm"))]
model_output_logging::log(serde_json::json!({
"event": "model_output",
"source": "direct_provider",
"provider_run_id": call.work_id.run_id.as_str(),
"provider_epoch": call.work_id.epoch.get(),
"profile": call.profile.as_str(),
"runtime_id": runtime_id,
"model_id": model_id,
"retry_attempt": call.retry_attempt,
"payload": &event,
}));
match event {
AgentEvent::TurnStarted { runtime_request_id } => {
if buffer.started {
@@ -641,6 +655,36 @@ impl ProviderRunCoordinator {
}
}
AgentEvent::KeepAlive => {}
AgentEvent::ToolCallProgress {
call_id,
name,
arguments_bytes,
} => {
if !self
.ensure_model_started_acknowledged(
&call, &profile, started_at, &buffer, project,
)
.await?
{
return Ok(());
}
if !self
.project_or_fail_acknowledged(
ProviderRunProjection::ModelEvent {
work_id: call.work_id.clone(),
event: AgentEvent::ToolCallProgress {
call_id,
name,
arguments_bytes,
},
},
project,
)
.await?
{
return Ok(());
}
}
AgentEvent::TextDelta { text } => {
if !self
.ensure_model_started_acknowledged(
@@ -860,6 +904,18 @@ impl ProviderRunCoordinator {
where
F: FnMut(ProviderRunProjection) -> BoxFuture<'static, Result<(), String>>,
{
#[cfg(not(target_family = "wasm"))]
model_output_logging::log(serde_json::json!({
"event": "model_error",
"source": "direct_provider",
"provider_run_id": call.work_id.run_id.as_str(),
"provider_epoch": call.work_id.epoch.get(),
"profile": call.profile.as_str(),
"runtime_id": profile.runtime.descriptor().id,
"model_id": profile.request.model.as_str(),
"retry_attempt": call.retry_attempt,
"payload": &error,
}));
let error_message = error.message.clone();
let disposition = self
.run
+13 -8
View File
@@ -3,9 +3,10 @@ use std::sync::Arc;
use galaxy_agent_core::{AgentRuntime, ToolCall, TurnRequest};
use galaxy_agent_rig::{
AnthropicRuntime, AnthropicRuntimeConfig, ChatGPTSubscriptionRuntime,
ChatGPTSubscriptionRuntimeConfig, GeminiRuntime, GeminiRuntimeConfig, OpenAICompatibleRuntime,
OpenAICompatibleRuntimeConfig, VertexAiRuntime, VertexAiRuntimeConfig,
AnthropicRuntime, AnthropicRuntimeConfig, BedrockRigConfig, BedrockRuntime,
ChatGPTSubscriptionRuntime, ChatGPTSubscriptionRuntimeConfig, GeminiRuntime,
GeminiRuntimeConfig, OpenAICompatibleRuntime, OpenAICompatibleRuntimeConfig, VertexAiRuntime,
VertexAiRuntimeConfig,
};
use uuid::Uuid;
use warp_multi_agent_api::ToolType;
@@ -254,11 +255,15 @@ pub(crate) async fn provider_runtime_for_request(
let caching_config =
CachingConfig::from_external_config(&ExternalBedrockConfig::load());
let client = BedrockClient::from_config(config).await?;
Arc::new(client.agent_runtime(
model,
cross_region_inference,
max_output_tokens,
caching_config,
Arc::new(BedrockRuntime::from_aws_client(
client.runtime_client(),
BedrockRigConfig {
model,
region: client.region().to_string(),
cross_region_inference,
prompt_caching: caching_config.enabled,
max_output_tokens,
},
)?)
}
crate::ai::provider::ProviderConfig::None => {
+3
View File
@@ -646,6 +646,9 @@ fn build_system_prompt(
let mut prompt = String::from(
"You are Galaxy, a local-first software-engineering and terminal agent. Complete the user's task through inspection, implementation, and proportionate validation. Galaxy owns tool permissions and execution; use only the tools advertised in this request and treat every result as authoritative evidence.\n\n",
);
prompt.push_str(
"## Communication Style\nSpeak naturally, warmly, and directly, like a thoughtful collaborator working alongside the user. Default to short responses and expand only when complexity or the user's request warrants it. For nontrivial work, briefly tell the user what you are checking before the first tool call. Between dependent tool calls, add a concise update only when a result materially changes what you learned or what you will do next; ground it in specifics instead of generic activity narration. Do not narrate every routine read, repeat the plan, or end a turn with only a progress update when useful work can continue. In the final response, lead with the outcome and keep the handoff compact.\n\n",
);
prompt.push_str(
"## Execution Contract\nContinue until the user's requested outcome is complete and validated. Do not stop at an intermediate analysis, plan, status update, or promise of future work, and do not ask the user to say \"continue\". After each tool result, choose and perform the next necessary step. Stop only when the request is fulfilled or a concrete blocker requires user input; identify that blocker explicitly.\n\n",
);