conversationSessionNetwork.test.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { describe, expect, it } from "vitest";
  2. import { readUpstreamToolResultFromRequest } from "./e2e/helpers/conversation-session-network.js";
  3. describe("conversation session provider capture", () => {
  4. it("reads the latest matching tool_result error instead of stale success", () => {
  5. const result = readUpstreamToolResultFromRequest(
  6. {
  7. messages: [
  8. {
  9. role: "user",
  10. content: [
  11. {
  12. type: "tool_result",
  13. tool_use_id: "toolu_browser_action",
  14. content: "stale success",
  15. },
  16. ],
  17. },
  18. {
  19. role: "user",
  20. content: [
  21. {
  22. type: "tool_result",
  23. tool_use_id: "toolu_other",
  24. content: "unrelated failure",
  25. is_error: true,
  26. },
  27. {
  28. type: "tool_result",
  29. tool_use_id: "toolu_browser_action",
  30. content: "E2E_INTENTIONAL_TOOL_FAILURE\n\nStructured content:\n",
  31. is_error: true,
  32. },
  33. ],
  34. },
  35. ],
  36. },
  37. "toolu_browser_action",
  38. );
  39. expect(result).toEqual({
  40. content: "E2E_INTENTIONAL_TOOL_FAILURE\n\nStructured content:\n",
  41. isError: true,
  42. toolCallId: "toolu_browser_action",
  43. });
  44. });
  45. });