Skip to content

Commit 335a22f

Browse files
committed
docs: add multi-turn fixture examples with matcher selection guide
1 parent a2e8ca5 commit 335a22f

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

docs/examples/index.html

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,82 @@ <h3>Complete Config</h3>
493493
<span class="key">"rerank"</span>: <span class="kw">true</span>,
494494
<span class="key">"moderate"</span>: <span class="kw">true</span>
495495
}
496+
}</code></pre>
497+
</div>
498+
499+
<!-- ─── Multi-Turn Conversations ───────────────────────────── -->
500+
501+
<h2>Multi-Turn Conversations</h2>
502+
503+
<h3>Choosing a multi-turn matcher</h3>
504+
<p>
505+
aimock provides four match fields for multi-turn fixtures, each suited to a different
506+
scenario. <strong><code>turnIndex</code></strong> matches by conversation depth (how many
507+
assistant replies precede this request) and is stateless, so it works with concurrent
508+
clients. <strong><code>hasToolResult</code></strong> is a boolean that distinguishes the
509+
initial request from the follow-up after a tool executes &mdash; ideal for simple two-step
510+
tool rounds. <strong><code>toolCallId</code></strong> matches a specific tool call by its
511+
ID, useful when the agent calls multiple tools and you need to respond to exactly one.
512+
<strong><code>sequenceIndex</code></strong> is a stateful counter (&ldquo;first request
513+
gets A, second gets B&rdquo;) but is not safe for concurrent requests to the same fixture.
514+
See the <a href="/multi-turn">Multi-Turn Conversations</a> reference for the full details.
515+
</p>
516+
517+
<h3>Multi-turn conversation with turnIndex</h3>
518+
<p>
519+
Use <code>turnIndex</code> to give different responses at each conversational turn.
520+
Combine with <code>hasToolResult</code> to handle the post-tool-execution follow-up.
521+
</p>
522+
<div class="code-block">
523+
<div class="code-block-header">
524+
fixtures/examples/llm/multi-turn-turnindex.json <span class="lang-tag">json</span>
525+
</div>
526+
<pre><code>{
527+
<span class="key">"fixtures"</span>: [
528+
{
529+
<span class="key">"match"</span>: { <span class="key">"userMessage"</span>: <span class="str">"plan a trip"</span>, <span class="key">"turnIndex"</span>: <span class="num">0</span> },
530+
<span class="key">"response"</span>: { <span class="key">"content"</span>: <span class="str">"I'd love to help plan your trip! Where would you like to go?"</span> }
531+
},
532+
{
533+
<span class="key">"match"</span>: { <span class="key">"userMessage"</span>: <span class="str">"plan a trip"</span>, <span class="key">"turnIndex"</span>: <span class="num">1</span> },
534+
<span class="key">"response"</span>: {
535+
<span class="key">"content"</span>: <span class="str">"Great choice! Let me search for flights."</span>,
536+
<span class="key">"toolCalls"</span>: [{ <span class="key">"name"</span>: <span class="str">"search_flights"</span>, <span class="key">"arguments"</span>: <span class="str">"{\"destination\": \"Tokyo\"}"</span> }]
537+
}
538+
},
539+
{
540+
<span class="key">"match"</span>: { <span class="key">"userMessage"</span>: <span class="str">"plan a trip"</span>, <span class="key">"turnIndex"</span>: <span class="num">2</span>, <span class="key">"hasToolResult"</span>: <span class="kw">true</span> },
541+
<span class="key">"response"</span>: { <span class="key">"content"</span>: <span class="str">"I found several flights to Tokyo. The best option is..."</span> }
542+
}
543+
]
544+
}</code></pre>
545+
</div>
546+
547+
<h3>Tool-call cycle with hasToolResult</h3>
548+
<p>
549+
For a simple tool round-trip, <code>hasToolResult</code> is the most concise matcher:
550+
<code>false</code> on the initial request, <code>true</code> after the tool result comes
551+
back.
552+
</p>
553+
<div class="code-block">
554+
<div class="code-block-header">
555+
fixtures/examples/llm/tool-cycle-hastoolresult.json
556+
<span class="lang-tag">json</span>
557+
</div>
558+
<pre><code>{
559+
<span class="key">"fixtures"</span>: [
560+
{
561+
<span class="key">"match"</span>: { <span class="key">"userMessage"</span>: <span class="str">"what's the weather?"</span>, <span class="key">"hasToolResult"</span>: <span class="kw">false</span> },
562+
<span class="key">"response"</span>: {
563+
<span class="key">"content"</span>: <span class="kw">null</span>,
564+
<span class="key">"toolCalls"</span>: [{ <span class="key">"name"</span>: <span class="str">"get_weather"</span>, <span class="key">"arguments"</span>: <span class="str">"{\"city\": \"San Francisco\"}"</span> }]
565+
}
566+
},
567+
{
568+
<span class="key">"match"</span>: { <span class="key">"userMessage"</span>: <span class="str">"what's the weather?"</span>, <span class="key">"hasToolResult"</span>: <span class="kw">true</span> },
569+
<span class="key">"response"</span>: { <span class="key">"content"</span>: <span class="str">"It's 72°F and sunny in San Francisco!"</span> }
570+
}
571+
]
496572
}</code></pre>
497573
</div>
498574
</main>

0 commit comments

Comments
 (0)