From edb1c86667deaf958ae55d70e4e5a52972b52900 Mon Sep 17 00:00:00 2001 From: Jorge Vidaurre Date: Sat, 28 Mar 2026 19:07:02 -0300 Subject: [PATCH] fix(obs): normalize agent name from full path to short name When agents are invoked with full file paths (e.g. via batch runs), the agentName was written as-is to observability records, breaking analytics queries that group/filter by agent name. Strip path prefix and extension at the entry point of runAgent() so all downstream code (obs, state, logs) receives the short name. Closes #653 --- src/lib/agent-runner.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/agent-runner.ts b/src/lib/agent-runner.ts index df2f62d..5f38f86 100644 --- a/src/lib/agent-runner.ts +++ b/src/lib/agent-runner.ts @@ -4,7 +4,7 @@ */ import ora from 'ora'; -import { join } from 'path'; +import { join, basename, extname } from 'path'; import { existsSync, readFileSync } from 'fs'; import { findSquadsDir, @@ -80,6 +80,10 @@ export async function runAgent( squadName: string, options: RunOptions & { execute?: boolean } ): Promise { + // Normalize: strip path prefix and extension if a full file path was passed + if (agentName.includes('/') || agentName.includes('\\')) { + agentName = basename(agentName, extname(agentName)); + } const spinner = ora(`Running agent: ${agentName}`).start(); const startMs = Date.now(); const startTime = new Date(startMs).toISOString();