Skip to content

Unit-test assertExpectation in scripts/aichat-matrix.ts #1630

Closed

Description

@malibio

Overview

scripts/aichat-matrix.ts (added in #1364 / PR #1627) asserts agent behavior via a pure function, assertExpectation(expect: Expectation, toolsCalled: string[]). This function is the entire enforcement mechanism for the eval — a bug in its subsequence-matching (toolSequence) or run-length logic (noRetry) would silently make the eval pass when it shouldn't, with no signal that the harness itself is broken.

Raised as a non-blocking suggestion in the PR #1627 review.

Problem Statement

  • assertExpectation has no direct unit test coverage.
  • scripts/routing-eval.ts's equivalent (assertFixture) also has none — there's no existing pattern for testing these harness scripts in isolation.
  • Both are pure functions (no daemon/socket/DB needed), which makes them cheap to test directly without any live-agent scaffolding.

Proposed Solution

Add a small test file (e.g. scripts/aichat-matrix.test.ts, run via bun run test conventions used elsewhere, or a lightweight bun test-compatible script if scripts/ doesn't participate in the Vitest suite) covering:

  • noTools: passes with no action tools, fails with any action tool present, tolerates search_skills.
  • toolOnce: passes with exactly one call, fails with zero or multiple.
  • toolSequence: passes when the sequence appears as a subsequence (including with other tools interleaved), fails when out of order or missing.
  • noRetry: passes with no back-to-back repeats, fails on a repeated call, tolerates non-adjacent repeats.
  • noExtraTypes: passes with exactly one create_schema, fails with zero or multiple.

Acceptance Criteria

  • assertExpectation has direct unit test coverage for all five Expectation kinds, including edge cases (empty tool list, search_skills interleaved).
  • Tests run via the project's standard test command (documented in the test file or PR description).
  • Code passes bun run quality:fix.

Related Issues

Activity

  1. malibio commented on Jul 11, 2026

    @malibio
    CollaboratorAuthor

    Baseline (Happy-DOM): 158 test files passed, 1 failed (Test Files: 1 failed | 158 passed). Frontend: 4030 passed, 1 failed. The 1 failure is architecture-benchmarks.test.ts > bulk structural operations <25ms target (41.8ms actual) — known machine-load-flaky perf threshold, unrelated to this issue's scope.

  2. self-assigned this
    on Jul 11, 2026
  3. added a commit that references this issue on Jul 11, 2026
    c4b9d3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions