Files
penguin-harness/packages/web/test/example-tasks.test.ts
T

106 lines
4.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from "vitest";
import { EXAMPLE_TASKS } from "../src/features/chat/example-tasks";
import { buildSkillsMessage } from "../src/features/chat/skill-use";
import { en } from "../src/lib/strings-en";
import { zh } from "../src/lib/strings";
describe("draft example tasks", () => {
it.each(["agentBenchmarkBuild", "agentOptimization"] as const)(
"submits the %s prompt without an implicit Skill block",
(id) => {
const task = EXAMPLE_TASKS.find((candidate) => candidate.id === id);
expect(task).toBeDefined();
expect(task?.skills).toEqual([]);
expect(buildSkillsMessage([...(task?.skills ?? [])], zh.chat.exampleTasks[id].prompt)).toBe(
zh.chat.exampleTasks[id].prompt,
);
},
);
it.each([
{
locale: "zh",
buildPrompt: zh.chat.exampleTasks.agentBenchmarkBuild.prompt,
optimizationPrompt: zh.chat.exampleTasks.agentOptimization.prompt,
buildMarkers: [
"依次使用 `agent-creation` 和 `benchmark-design`",
"id:`finite_choice_agent`",
"installed_skills:`[]`",
"id:`contextual-choice-adaptation`",
"desired_baseline_score:`<75`",
"pilot_iteration_limit:`5`",
"足球投注决策",
"售后政策与工单事实",
"投资策略、历史市场与当前指标",
],
buildForbiddenMarkers: ["thinking_level", "provider", "model_id"],
optimizationMarkers: [
"使用 `agent-optimization`",
"test_agent_id:`finite_choice_agent`",
"benchmark_id:`contextual-choice-adaptation`",
"提高信息不完整、规则冲突和有限选项决策中的稳定性",
"desired_score:`>=95`",
"candidate_round_limit:`5`",
],
},
{
locale: "en",
buildPrompt: en.chat.exampleTasks.agentBenchmarkBuild.prompt,
optimizationPrompt: en.chat.exampleTasks.agentOptimization.prompt,
buildMarkers: [
"Use `agent-creation` followed by `benchmark-design`",
"id: `finite_choice_agent`",
"installed_skills: `[]`",
"id: `contextual-choice-adaptation`",
"desired_baseline_score: `<75`",
"pilot_iteration_limit: `5`",
"football betting decisions",
"policy and ticket facts",
"strategy, historical markets, and current indicators",
],
buildForbiddenMarkers: ["thinking_level", "provider", "model_id"],
optimizationMarkers: [
"Use `agent-optimization`",
"test_agent_id: `finite_choice_agent`",
"benchmark_id: `contextual-choice-adaptation`",
"improve stability under incomplete information, conflicting rules, and finite choices",
"desired_score: `>=95`",
"candidate_round_limit: `5`",
],
},
])(
"$locale preserves the two-session agent evolution contract",
({
buildPrompt,
optimizationPrompt,
buildMarkers,
buildForbiddenMarkers,
optimizationMarkers,
}) => {
const normalizedBuild = buildPrompt.replace(/\s+/g, " ");
const normalizedOptimization = optimizationPrompt.replace(/\s+/g, " ");
for (const marker of buildMarkers) {
expect(normalizedBuild).toContain(marker);
}
for (const marker of buildForbiddenMarkers) {
expect(normalizedBuild).not.toContain(marker);
}
for (const marker of optimizationMarkers) {
expect(normalizedOptimization).toContain(marker);
}
expect(normalizedBuild).not.toContain("penguin run");
expect(normalizedOptimization).not.toContain("penguin run");
expect(normalizedBuild).not.toContain("run_subagent");
expect(normalizedOptimization).not.toContain("run_subagent");
expect(normalizedBuild).not.toContain("Scoreboard");
expect(normalizedOptimization).not.toContain("Scoreboard");
expect(normalizedBuild.length).toBeLessThan(1600);
expect(normalizedOptimization.length).toBeLessThan(600);
expect(normalizedBuild).not.toContain("Phase 1");
expect(normalizedOptimization).not.toContain("Phase 3");
},
);
});