AkurAI Build
Menu

popagent

public

Latest change 49bebb71b99af5912570045725ca987dc2837af7 - Harden autonomous workflow execution by AkurAI Build

import { beforeAll, describe, expect, test } from "bun:test";
import { runtimeModelId } from "./api-types";
import { AgentRuntimeSettingsStore } from "./agent-runtime-settings";

const store = new AgentRuntimeSettingsStore();

beforeAll(() => store.init());

describe("AgentRuntimeSettingsStore", () => {
  test("persists every configurable execution bound", async () => {
    const original = await store.get();
    const input = {
      defaultModel: original.defaultModel,
      modelSource: original.modelSource === "local" ? "openrouter-free" as const : "local" as const,
      supervisorMaxSteps: original.supervisorMaxSteps === 23 ? 24 : 23,
      specialistMaxSteps: original.specialistMaxSteps === 11 ? 12 : 11,
      toolConcurrency: original.toolConcurrency === 2 ? 3 : 2,
      delegationContextMessages: original.delegationContextMessages === 9 ? 10 : 9,
      delegationResultCharacters: original.delegationResultCharacters === 12_345 ? 12_346 : 12_345,
      maxProcessorRetries: original.maxProcessorRetries === 2 ? 3 : 2,
      finalResponseFeedback: `Configured final response ${crypto.randomUUID()}`,
      delegationFailureFeedback: `Configured failure for {{agentId}}: {{error}} ${crypto.randomUUID()}`,
      delegationResultTruncationMarker: `\n[configured truncation ${crypto.randomUUID()}]`,
      taskConcurrency: original.taskConcurrency === 2 ? 3 : 2,
      taskPollIntervalMs: original.taskPollIntervalMs === 2_500 ? 3_000 : 2_500,
      taskTimeoutMs: original.taskTimeoutMs === 120_000 ? 180_000 : 120_000,
      taskStaleAfterMs: original.taskStaleAfterMs === 7_200_000 ? 10_800_000 : 7_200_000,
    };
    const expected = {
      ...input,
      defaultModel: runtimeModelId(input.defaultModel, input.modelSource),
    };
    try {
      expect(await store.update(input)).toMatchObject(expected);
      expect(await new AgentRuntimeSettingsStore().get()).toMatchObject(expected);
    } finally {
      await store.update(original);
    }
  });
});