Skip to content

feat: add repeat wildcard flag for greedy input matching #31

Description

@rowan-stein

User Request

The E2E pipeline test in agynio/agents-orchestrator (PR #56) fails because Codex SDK sends a variable number of context messages (environment context, developer instructions, AGENTS.md) before the actual user prompt. The simple-hello test suite expects a fixed number of input items, causing sequence_exhausted errors.

Specification

Problem

The matchInput() function in src/lib/responses/matching.ts does strict 1:1 positional matching between test sequence items and actual input items. When Codex sends [env_context, "hi"] (2 items) but the test defines only ["hi"] (1 input item), the boundary check expectedItems.length === input.length fails.

Solution: Add repeat flag to wildcard message items

Add a repeat: boolean optional field to StoredMessageContentSchema. When repeat: true is set on a wildcard item (with any_role: true AND any_content: true), the matching algorithm treats it as matching 1 or more consecutive input items of any type, greedily consuming items until the next expected item matches.

Changes Required

1. src/lib/responses/matching.ts

  • Add repeat: z.boolean().optional() to StoredMessageContentSchema
  • Update matchInput() to handle repeat wildcards using greedy backtracking:
    • Before finding the output boundary, collect input segments with their repeat flag
    • For non-repeat segments: match exactly 1 input item (current behavior)
    • For repeat segments: try consuming N items (greedy, max→1), then recursively match remaining segments against remaining input
    • Repeat wildcard must consume at least 1 item

2. src/lib/responses/__tests__/matching.test.ts

Add tests for:

  • Repeat wildcard absorbing multiple input items before exact match
  • Repeat wildcard absorbing single input item
  • Repeat wildcard requiring at least 1 match (fails with 0)
  • Mixed repeat + non-repeat segments

3. Create simple-hello test suite

After the matching logic change, create the test via API:

{
  "name": "simple-hello",
  "items": [
    {"type": "message", "content": {"role": "user", "content": "ignored", "any_role": true, "any_content": true, "repeat": true}},
    {"type": "message", "content": {"role": "user", "content": "hi"}},
    {"type": "message", "content": {"role": "assistant", "content": "Hi! How are you?"}}
  ]
}

This absorbs Codex's variable-length context prefix, matches the user prompt "hi", and returns "Hi! How are you?".

Context

  • Related: agynio/agents-orchestrator#54 (E2E pipeline test)
  • The simple-hello model name is used via MODEL_OVERRIDE=simple-hello in agynd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions