Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Report the evaluation run's project per trace, not from the reviewer's cwd

Lawrence Jones8c16ceef7469
diff --git a/cli/beacon/cmd/memory.go b/cli/beacon/cmd/memory.go
index ae805570..e280061c 100644
--- a/cli/beacon/cmd/memory.go
+++ b/cli/beacon/cmd/memory.go
@@ -173,9 +173,12 @@ var memorySkillsInstallCmd = &cobra.Command{
RunE: runMemorySkillsInstall,
}
+// evaluationRunResult reports one `evaluations run`. Project is set only when --project
+// pinned every trace to one project; otherwise each trace is scoped to its own
+// repository, and the project lives on each preview and evaluation instead.
type evaluationRunResult struct {
DryRun bool `json:"dry_run"`
- Project asymptoteobserve.LearningProjectV1 `json:"project"`
+ Project *asymptoteobserve.LearningProjectV1 `json:"project,omitempty"`
StorePath string `json:"store_path"`
TraceCount int `json:"trace_count"`
EstimatedCalls int `json:"estimated_calls"`
@@ -303,10 +306,6 @@ func runMemoryShow(cmd *cobra.Command, args []string) error {
}
func runMemoryEvaluationsRun(cmd *cobra.Command, args []string) error {
- project, err := learning.ResolveProject(memoryOpts.projectPath)
- if err != nil {
- return err
- }
store := memoryStore()
inputs, err := selectedEvaluationInputs()
if err != nil {
@@ -315,12 +314,18 @@ func runMemoryEvaluationsRun(cmd *cobra.Command, args []string) error {
evaluatorOpts := jevEvaluatorOptions()
result := evaluationRunResult{
DryRun: memoryOpts.dryRun,
- Project: project,
StorePath: store.Path(),
TraceCount: len(inputs),
EstimatedCalls: len(inputs),
EstimatedCostUSD: float64(len(inputs)) * memoryOpts.jevCost,
}
+ if strings.TrimSpace(memoryOpts.projectPath) != "" {
+ project, err := learning.ResolveProject(memoryOpts.projectPath)
+ if err != nil {
+ return err
+ }
+ result.Project = &project
+ }
for _, input := range inputs {
input.DryRun = memoryOpts.dryRun
if memoryOpts.dryRun {
@@ -352,7 +357,7 @@ func runMemoryEvaluationsRun(cmd *cobra.Command, args []string) error {
if result.DryRun {
fmt.Fprintf(cmd.OutOrStdout(), "Selected %d trace(s); estimated Jev calls: %d; estimated cost: $%.5f\n", result.TraceCount, result.EstimatedCalls, result.EstimatedCostUSD)
for _, preview := range result.Previews {
- fmt.Fprintf(cmd.OutOrStdout(), "%s\t%s\t$%.5f\n", preview.TraceID, preview.Title, preview.EstimatedCostUSD)
+ fmt.Fprintf(cmd.OutOrStdout(), "%s\t%s\t%s\t$%.5f\n", preview.TraceID, preview.Title, firstNonEmpty(preview.Project.Path, preview.Project.ID), preview.EstimatedCostUSD)
}
return nil
}
diff --git a/cli/beacon/cmd/memory_test.go b/cli/beacon/cmd/memory_test.go
index 6f48e988..2ea6499a 100644
--- a/cli/beacon/cmd/memory_test.go
+++ b/cli/beacon/cmd/memory_test.go
@@ -421,6 +421,40 @@ func TestMemoryEvaluationsRunSkipsSessionlessTraces(t *testing.T) {
if result.TraceCount != 1 || len(result.Previews) != 1 || result.Previews[0].TraceID != "session:cursor:s1" {
t.Fatalf("expected only the session trace to be selected, got %#v", result)
}
+ if result.Project == nil || result.Project.Path != project || result.Previews[0].Project.ID != result.Project.ID {
+ t.Fatalf("with --project the result and every preview should name it, got %#v", result)
+ }
+}
+
+// Without --project each trace is scoped to its own repository, so the result must
+// not claim a single project that the stored records may not belong to.
+func TestMemoryEvaluationsRunReportsProjectOnlyWhenPinned(t *testing.T) {
+ logPath, project := writeMemoryCommandFixture(t)
+ resetMemoryOpts(t)
+ memoryOpts.logPath = logPath
+ memoryOpts.dryRun = true
+ memoryOpts.jsonOutput = true
+
+ var out bytes.Buffer
+ cmd := &cobra.Command{}
+ cmd.SetOut(&out)
+ if err := runMemoryEvaluationsRun(cmd, nil); err != nil {
+ t.Fatalf("runMemoryEvaluationsRun returned error: %v", err)
+ }
+ var result evaluationRunResult
+ if err := json.Unmarshal(out.Bytes(), &result); err != nil {
+ t.Fatalf("decode result: %v\n%s", err, out.String())
+ }
+ if result.Project != nil {
+ t.Fatalf("result should not name a project without --project, got %#v", result.Project)
+ }
+ want, err := learning.ResolveProject(project)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(result.Previews) != 1 || result.Previews[0].Project.ID != want.ID {
+ t.Fatalf("preview should carry the trace's repository %s, got %#v", want.ID, result.Previews)
+ }
}
func TestMemoryCandidatesCreateScopesToTraceRepository(t *testing.T) {
diff --git a/cli/beacon/internal/learning/evaluator.go b/cli/beacon/internal/learning/evaluator.go
index e306cc38..94a89d5c 100644
--- a/cli/beacon/internal/learning/evaluator.go
+++ b/cli/beacon/internal/learning/evaluator.go
@@ -50,12 +50,13 @@ type EvaluationInput struct {
}
type EvaluationPreview struct {
- TraceID string `json:"trace_id"`
- Title string `json:"title,omitempty"`
- EventCount int `json:"event_count"`
- EstimatedCalls int `json:"estimated_calls"`
- EstimatedCostUSD float64 `json:"estimated_cost_usd"`
- Reason string `json:"reason,omitempty"`
+ TraceID string `json:"trace_id"`
+ Title string `json:"title,omitempty"`
+ EventCount int `json:"event_count"`
+ EstimatedCalls int `json:"estimated_calls"`
+ EstimatedCostUSD float64 `json:"estimated_cost_usd"`
+ Reason string `json:"reason,omitempty"`
+ Project asymptoteobserve.LearningProjectV1 `json:"project"`
}
type Projection struct {
@@ -176,6 +177,7 @@ func Preview(input EvaluationInput, opts EvaluatorOptions) EvaluationPreview {
EstimatedCalls: 1,
EstimatedCostUSD: costPerTrace(opts),
Reason: "explicit evaluation command; hooks and collectors do not call Jev",
+ Project: input.Project,
}
}