Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(tinyagents): emit generation enrichment with provider id on model calls

Steven Enamakele3bb02f75fec
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
index 709da2c88e..3848a6acea 100644
--- a/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/observability/event_projection.rs
@@ -14,7 +14,7 @@ use super::event_bridge::OpenhumanEventBridge;
impl EventListener for OpenhumanEventBridge {
fn on_event(&self, record: &EventRecord) {
match &record.event {
- AgentEvent::ModelStarted { call_id, .. } => {
+ AgentEvent::ModelStarted { .. } => {
let iteration = tinyagents_harness::events::advance_iteration(&self.cursor);
match &self.scope {
None => self.send(AgentProgress::IterationStarted {
diff --git a/crates/openhuman-core/src/agent/tinyagents/routes.rs b/crates/openhuman-core/src/agent/tinyagents/routes.rs
index 1338d880f0..1918d12bee 100644
--- a/crates/openhuman-core/src/agent/tinyagents/routes.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/routes.rs
@@ -267,7 +267,21 @@ impl ModelMiddleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
let call_id = request
.correlation
.as_ref()
- .map(|correlation| correlation.call_id.clone());
+ .map(|correlation| correlation.call_id.clone())
+ .or_else(|| ctx.active_model_call.as_ref().map(|call_id| call_id.as_str().to_owned()));
+ if let Some(call_id) = &call_id {
+ let provider_id = valid_trace_provider_id(&self.provider_id)
+ .then(|| self.provider_id.clone());
+ if let Some(provider_id) = provider_id {
+ ctx.events.emit(AgentEvent::GenerationEnriched {
+ call_id: call_id.clone().into(),
+ enrichment: GenerationEnrichment {
+ provider_id: Some(provider_id),
+ ..Default::default()
+ },
+ });
+ }
+ }
let outcome = next.run(ctx, state, request).await?;
let response = outcome.into_response();
if let Some(route) = response.resolved_route.clone() {
diff --git a/crates/openhuman-core/src/agent/tinyagents/routes_tests.rs b/crates/openhuman-core/src/agent/tinyagents/routes_tests.rs
index 9d4408eb64..e93a0aea16 100644
--- a/crates/openhuman-core/src/agent/tinyagents/routes_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/routes_tests.rs
@@ -153,7 +153,7 @@ async fn resolved_route_enrichment_uses_actual_provider_model_and_call_identity(
)));
let host = crate::agent::tinyagents::host::OpenHumanRunContext::new();
- let mut ctx = host.into_tinyagents(RunConfig::new("route-enrichment"));
+ let ctx = host.into_tinyagents(RunConfig::new("route-enrichment"));
let recorder = Arc::new(RouteEventRecorder::default());
ctx.events.subscribe(recorder.clone());
harness
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 525b6ddb02..0fe06c2680 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 525b6ddb02f78e8dc5235683f20ae87344a06bed
+Subproject commit 0fe06c2680ed2a7b3d2f7479e1f34ae7e75bc588