telemetry.test.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { describe, expect, it } from "vitest";
  2. import { resolveModelApiCallObservation } from "../src/telemetry/index.js";
  3. describe("model API operation registry", () => {
  4. it.each([
  5. ["main_turn", "agent_step", "main"],
  6. ["subagent", "agent_step", "subagent"],
  7. ["workflow_child", "agent_step", "workflow_child"],
  8. ["compact", "context_compaction", "system"],
  9. ["session_title", "session_title_generation", "system"],
  10. ["goal_summary_title", "goal_title_generation", "system"],
  11. ["target_completion_verification", "goal_completion_verification", "system"],
  12. ["git_commit_message", "workspace_git_commit_message", "system"],
  13. ["web_search_tool", "web_search", "tool"],
  14. ["web_fetch_processing", "web_fetch_processing", "tool"],
  15. ["project_memory_extract", "project_memory_extract", "system"],
  16. ["project_memory_dream", "project_memory_dream", "system"],
  17. ["project_memory_recall", "project_memory_recall", "system"],
  18. ["future_source", "tool_internal_model_call", "system"],
  19. ] as const)("maps %s to a bounded operation/actor", (querySource, operation, actorKind) => {
  20. expect(resolveModelApiCallObservation(querySource, undefined)).toMatchObject({
  21. actorKind,
  22. logicalCallId: expect.any(String),
  23. operation,
  24. });
  25. });
  26. it("lets an explicit operation phase override the legacy query source", () => {
  27. expect(
  28. resolveModelApiCallObservation("web_fetch_processing", {
  29. actorKind: "tool",
  30. operation: "web_search",
  31. }),
  32. ).toMatchObject({
  33. actorKind: "tool",
  34. operation: "web_search",
  35. });
  36. });
  37. });