Skip to content

Commit 75f2bca

Browse files
authored
feat: add --proxy-only flag for stateless proxying (#99)
## Summary - Add `--proxy-only` CLI flag that proxies unmatched requests to upstream providers without saving fixtures to disk or caching them in memory - Every unmatched request always hits the real provider — no stale recorded responses - Matched fixtures still work normally - Adds `proxyOnly` field to `RecordConfig` type for programmatic usage ## Use case Demo/live environments where aimock sits in front of real LLM providers with local fixtures for known scenarios, but unmatched traffic should always go upstream rather than getting cached after the first call. ## Files changed - `src/types.ts` — `proxyOnly?: boolean` on `RecordConfig` - `src/cli.ts` — `--proxy-only` flag parsing and help text - `src/recorder.ts` — skip disk write + memory push when `proxyOnly` is set - `src/__tests__/proxy-only.test.ts` — 8 tests covering proxy-only and contrast with record mode ## Test plan - [x] 8 new tests covering all proxy-only behaviors - [x] All 2214 tests pass - [x] Build passes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 227eae0 + d3e2cb1 commit 75f2bca

File tree

10 files changed

+510
-42
lines changed

10 files changed

+510
-42
lines changed

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"source": {
1010
"source": "npm",
1111
"package": "@copilotkit/aimock",
12-
"version": "^1.9.0"
12+
"version": "^1.10.0"
1313
},
1414
"description": "Fixture authoring skill for @copilotkit/aimock — match fields, response types, embeddings, structured output, sequential responses, streaming physics, agent loop patterns, gotchas, and debugging"
1515
}

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "llmock",
3-
"version": "1.9.0",
3+
"version": "1.10.0",
44
"description": "Fixture authoring guidance for @copilotkit/aimock",
55
"author": {
66
"name": "CopilotKit"

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @copilotkit/aimock
22

3+
## 1.10.0
4+
5+
### Minor Changes
6+
7+
- Add `--proxy-only` flag — proxy unmatched requests to upstream providers without saving fixtures to disk or caching in memory. Every unmatched request always hits the real provider, preventing stale recorded responses in demo/live environments (#99)
8+
39
## 1.9.0
410

511
### Minor Changes

charts/aimock/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ name: aimock
33
description: Mock infrastructure for AI application testing (OpenAI, Anthropic, Gemini, MCP, A2A, vector)
44
type: application
55
version: 0.1.0
6-
appVersion: "1.9.0"
6+
appVersion: "1.10.0"

docs/record-replay/index.html

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,72 @@ <h2>How It Works</h2>
7070
<li>Subsequent identical requests match the newly recorded fixture</li>
7171
</ol>
7272

73+
<h2>Proxy-Only Mode</h2>
74+
<p>
75+
Use <code>--proxy-only</code> instead of <code>--record</code> when you want unmatched
76+
requests to always reach the real provider &mdash; no fixture files are written to disk
77+
and no responses are cached in memory. Matched fixtures still work normally.
78+
</p>
79+
<p>
80+
This is ideal for <strong>demos and live environments</strong> where you have canned
81+
fixtures for repeatable demo scenarios you want to show off, but also want regular
82+
interactions to work normally by proxying to the real provider. Without
83+
<code>--proxy-only</code>, the first real API call would get recorded and cached, and
84+
subsequent identical requests would get the stale recorded response instead of hitting the
85+
live provider.
86+
</p>
87+
88+
<div class="cli-docker-tabs">
89+
<div class="tab-cli">
90+
<div class="code-block">
91+
<div class="code-block-header">
92+
Proxy-only mode <span class="lang-tag">shell</span>
93+
</div>
94+
<pre><code>$ npx aimock --fixtures ./fixtures \
95+
--proxy-only \
96+
--provider-openai https://api.openai.com</code></pre>
97+
</div>
98+
</div>
99+
<div class="tab-docker">
100+
<div class="code-block">
101+
<div class="code-block-header">
102+
Proxy-only mode <span class="lang-tag">shell</span>
103+
</div>
104+
<pre><code>$ docker run -d -p 4010:4010 \
105+
-v ./fixtures:/fixtures \
106+
ghcr.io/copilotkit/aimock \
107+
npx aimock -f /fixtures \
108+
--proxy-only \
109+
--provider-openai https://api.openai.com</code></pre>
110+
</div>
111+
</div>
112+
</div>
113+
114+
<table class="endpoint-table">
115+
<thead>
116+
<tr>
117+
<th>Mode</th>
118+
<th>Unmatched request</th>
119+
<th>Writes to disk</th>
120+
<th>Caches in memory</th>
121+
</tr>
122+
</thead>
123+
<tbody>
124+
<tr>
125+
<td><code>--record</code></td>
126+
<td>Proxy &rarr; save &rarr; replay next time</td>
127+
<td>Yes</td>
128+
<td>Yes</td>
129+
</tr>
130+
<tr>
131+
<td><code>--proxy-only</code></td>
132+
<td>Proxy &rarr; relay &rarr; proxy again next time</td>
133+
<td>No</td>
134+
<td>No</td>
135+
</tr>
136+
</tbody>
137+
</table>
138+
73139
<h2>Quick Start</h2>
74140

75141
<div class="cli-docker-tabs">
@@ -107,7 +173,11 @@ <h2>CLI Flags</h2>
107173
<tbody>
108174
<tr>
109175
<td><code>--record</code></td>
110-
<td>Enable record mode (proxy-on-miss)</td>
176+
<td>Enable record mode (proxy, save, and cache on miss)</td>
177+
</tr>
178+
<tr>
179+
<td><code>--proxy-only</code></td>
180+
<td>Proxy mode (forward on miss, no saving or caching)</td>
111181
</tr>
112182
<tr>
113183
<td><code>--strict</code></td>
@@ -166,6 +236,7 @@ <h2>Programmatic API</h2>
166236
<span class="prop">anthropic</span>: <span class="str">"https://api.anthropic.com"</span>,
167237
},
168238
<span class="prop">fixturePath</span>: <span class="str">"./fixtures/recorded"</span>,
239+
<span class="prop">proxyOnly</span>: <span class="kw">true</span>, <span class="cmt">// omit to record fixtures</span>
169240
});
170241

171242
<span class="cmt">// Make requests — unmatched ones are proxied and recorded</span>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@copilotkit/aimock",
3-
"version": "1.9.0",
3+
"version": "1.10.0",
44
"description": "Mock infrastructure for AI application testing — LLM APIs, MCP tools, A2A agents, vector databases, search, and more. Zero dependencies.",
55
"license": "MIT",
66
"repository": {

0 commit comments

Comments
 (0)