@bluecopa/harness 0.1.0-snapshot.14 → 0.1.0-snapshot.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluecopa/harness",
3
- "version": "0.1.0-snapshot.14",
3
+ "version": "0.1.0-snapshot.15",
4
4
  "description": "Provider-agnostic TypeScript agent framework",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {
@@ -170,6 +170,9 @@ export interface VercelAgentLoopConfig {
170
170
  export class VercelAgentLoop implements AgentLoop {
171
171
  private readonly model: string;
172
172
  private readonly systemPrompt: string;
173
+ /** System prompt as array with Anthropic cache_control for prompt caching. */
174
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
175
+ private readonly cachedSystemPrompt: any;
173
176
  private readonly tools: Record<string, AnyTool>;
174
177
  private readonly validToolNames: Set<string>;
175
178
 
@@ -189,6 +192,13 @@ export class VercelAgentLoop implements AgentLoop {
189
192
  'When the task is fully complete, respond with a brief text summary (no tool call).',
190
193
  ].join(' ');
191
194
 
195
+ // Wrap system prompt with Anthropic cache_control for prompt caching
196
+ this.cachedSystemPrompt = [{
197
+ type: 'text',
198
+ text: this.systemPrompt,
199
+ providerOptions: { anthropic: { cacheControl: { type: 'ephemeral' } } },
200
+ }];
201
+
192
202
  if (config.apiKey) {
193
203
  process.env.ANTHROPIC_API_KEY = config.apiKey;
194
204
  }
@@ -204,7 +214,7 @@ export class VercelAgentLoop implements AgentLoop {
204
214
  model: anthropic(this.model),
205
215
  tools: this.tools,
206
216
  toolChoice: 'auto',
207
- system: this.systemPrompt,
217
+ system: this.cachedSystemPrompt,
208
218
  messages: toModelMessages(messages),
209
219
  stopWhen: stepCountIs(1),
210
220
  });
@@ -253,7 +263,7 @@ export class VercelAgentLoop implements AgentLoop {
253
263
  model: anthropic(this.model),
254
264
  tools: this.tools,
255
265
  toolChoice: 'auto',
256
- system: this.systemPrompt,
266
+ system: this.cachedSystemPrompt,
257
267
  messages: toModelMessages(messages),
258
268
  stopWhen: stepCountIs(1),
259
269
  });