- Revised DESIGN_V2.md to clarify the `input` field's capabilities, allowing for string, single message, or message array formats for conversation context. - Updated the test case format to reflect the new `input` structure, ensuring compatibility with existing single-turn tests. - Enhanced TODO_V2.md to indicate the completion of message history support and outline remaining tasks, including options field support and JSONL output format updates. - Improved documentation to ensure clarity on the new input handling and its implications for agent-driven testing.
4.3 KiB
4.3 KiB
Agent Test Framework V2 - Implementation TODO
Format Rules Summary
| Context | Format | Example |
|---|---|---|
-i flag (CLI) |
Prefix required | agents:workers.test.gen, scripts:tests.gen |
JSONL assertion use |
Prefix required | "use": "agents:workers.test.validator" |
JSONL simulator.use |
No prefix (agent only) | "use": "workers.test.user-simulator" |
--simulator flag |
No prefix (agent only) | --simulator workers.test.user-simulator |
t.assert.Agent() |
No prefix (method-bound) | t.assert.Agent(resp, "workers.test.validator", {...}) |
Phase 1: Message History Support ✅ (Already Implemented)
The input field already supports:
string: Simple text inputobject: Single message{role, content}array: Message history[{role, content}, ...]
See input.go → ParseInputWithOptions() for implementation.
Remaining tasks:
- Add
optionsfield support (aligned withcontext.Options) - partially done viaCaseOptions - Support attachments in message content parts (file:// protocol)
- Update console output to show message count
- Update JSONL output format with
messages_count
Phase 2: Agent-Driven Input
- Parse
agents:prefix in-iflag - Parse
scripts:prefix in-iflag - Use standard
context.Optionsfor generator invocation - Pass
test_mode: "generator"inoptions.metadata - Pass target agent info (description, tools) in
options.metadata - Support query parameters (
?count=10&focus=...) → merged intooptions.metadata - Add
--dry-runflag to save generated cases without running - Create example generator agent with prompt template
Phase 3: Dynamic Mode (Checkpoints)
- Add
checkpointsarray to test case parser - Add
simulatorfield to test case parser - Implement checkpoint matching against agent responses
- Support
afterfield for order constraints - Track pending/reached checkpoints during execution
- Implement termination conditions:
- All checkpoints reached → PASSED
- Simulator signals goal_achieved but checkpoints missing → FAILED
- max_turns exceeded → FAILED
- timeout exceeded → FAILED
- Implement simulator invocation via
Assistant.Stream() simulator.useis direct agent ID (no prefix needed)- Pass
test_mode: "simulator"inoptions.metadata - Pass persona, goal, turn_count from
simulator.options.metadata - Pass conversation history as messages
- Create example simulator agent with prompt template
Phase 4: Agent-Driven Assertions
In JSONL Test Cases
- Add
agentassertion type to assertion parser - Support
optionsfield in assertion (aligned withcontext.Options) - Implement validator agent invocation via
Assistant.Stream() - Pass
test_mode: "validator"inoptions.metadata - Pass conversation context and criteria in
options.metadata - Support score-based pass/fail threshold (configurable in
options.metadata) - Add
suggestionsto assertion error output
In Script Tests
- Add
t.assert.Agent(response, agentID, options?)method agentIDis direct ID (e.g.,workers.test.validator), no prefix needed- Invoke validator agent with context
- Return
ValidatorResultobject to JavaScript - Support passing conversation history in options
Shared
- Create example validator agent with prompt template
- Document
ValidatorResultinterface
Phase 5: Error Handling & Reporting
- Implement test-level error handling
- Add detailed error messages with hints
- Support
--parallelflag for concurrent test execution - Support
--fail-fastflag to stop on first failure - Add verbose mode (
-v) for detailed output
Open Questions
-
Message Generation: Should we provide a helper to generate message history from a script?
-
Snapshot Testing: Should we support "golden file" comparison for responses?
-
Retry Logic: If a test fails, should we support automatic retry?