Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

2.0 KB
Raw Blame
import { SEARCH_TOOL } from "@eve-e2e/config/catalog-tools";
import { defineEval } from "eve/evals";
import { satisfies } from "eve/evals/expect";

import { noCallRejectedWholesale } from "./first-try";

const ADD_PET_TOOL = "petstore__addPet";

export default defineEval({
  tags: ["real-model"],
  description:
    "A real model builds a nested connection tool input from the TypeScript signature search returns.",

  async test(t) {
    const turn = await t.send(
      [
        "Alice runs the Maple Street pet store, whose store id is `maple-street`.",
        "This morning she took in a golden retriever named Biscuit. He is ready for adoption,",
        "belongs in the Dogs category, and his photo is at https://example.com/photos/biscuit.jpg.",
        "Please add Biscuit to the store's catalog through the petstore connection,",
        "then tell Alice the id the store assigns to him.",
      ].join(" "),
    );

    turn.expectOk();
    t.toolOrder([SEARCH_TOOL, ADD_PET_TOOL]);
    t.calledTool(ADD_PET_TOOL, { output: isStoredBiscuit });
    t.messageIncludes("4217");

    // Tracked, not gated: no step had every tool call rejected, a proxy for building
    // the nested input right on the first try.
    t.check(
      noCallRejectedWholesale(turn),
      satisfies((firstTry: boolean) => firstTry, "every step that requested tools ran one").soft(),
    );
  },
});

function isStoredBiscuit(value: unknown): boolean {
  if (typeof value !== "object" || value === null) return false;
  const { status, body } = value as { status?: unknown; body?: Record<string, unknown> };
  const category = body?.category as { name?: unknown } | undefined;
  return (
    status === 200 &&
    body?.id === 4217 &&
    body.storeId === "maple-street" &&
    body.name === "Biscuit" &&
    body.status === "available" &&
    typeof category?.name === "string" &&
    /dog/iu.test(category.name) &&
    Array.isArray(body.photoUrls) &&
    body.photoUrls.includes("https://example.com/photos/biscuit.jpg")
  );
}