Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

fix: add compatible and ephemeral cache control options for truefoundry provider (#673)

Heer Ambaviafe816e73621
diff --git a/.changeset/truefoundry-cache-control-ephemeral.md b/.changeset/truefoundry-cache-control-ephemeral.md
new file mode 100644
index 000000000..bdf986aaf
--- /dev/null
+++ b/.changeset/truefoundry-cache-control-ephemeral.md
@@ -0,0 +1,5 @@
+---
+'@truefoundry/trueforge-core': patch
+---
+
+Default `cache_control` to `{ type: 'ephemeral' }` for `truefoundry` provider model calls (overridable via request body).
diff --git a/packages/trueforge-core/src/core/llm/VercelAILLM.ts b/packages/trueforge-core/src/core/llm/VercelAILLM.ts
index e3b0ce495..da7e1a3b6 100644
--- a/packages/trueforge-core/src/core/llm/VercelAILLM.ts
+++ b/packages/trueforge-core/src/core/llm/VercelAILLM.ts
@@ -544,6 +544,11 @@ export function buildProviderOptions({
} else if (config.provider.type === 'alibaba') {
const alibaba = alibabaProviderOptions(rawBody);
return alibaba !== undefined ? { alibaba } : {};
+ } else if (config.provider.type === 'truefoundry') {
+ // Prompt caching defaults on for the TFY gateway. Callers can override.
+ const cache_control = readBodyField({ rawBody, key: 'cache_control' }) ?? { type: 'ephemeral' };
+ const compatible = compatibleProviderOptions({ strictJsonSchema, reasoningEffort, rawBody }) ?? {};
+ return { truefoundry: { ...compatible, cache_control } };
} else {
// The remaining providers all share the compatible adapter, which reads its options from a key
// matching the `name` it was built with — the provider type itself.
diff --git a/packages/trueforge-core/tests/core/llm/VercelAILLM.output.test.ts b/packages/trueforge-core/tests/core/llm/VercelAILLM.output.test.ts
index 180855ade..6c9a784f3 100644
--- a/packages/trueforge-core/tests/core/llm/VercelAILLM.output.test.ts
+++ b/packages/trueforge-core/tests/core/llm/VercelAILLM.output.test.ts
@@ -370,6 +370,30 @@ describe('buildProviderOptions', () => {
});
});
+ describe('truefoundry provider', () => {
+ const config = makeConfig({ provider: 'truefoundry', baseUrl: 'https://gateway.example/v1' });
+
+ it('defaults cache_control to ephemeral when omitted', () => {
+ const opts = buildProviderOptions({
+ config,
+ reasoningEffort: undefined,
+ structuredOutputSpec: textSpec,
+ rawBody: {},
+ });
+ expect(opts).toEqual({ truefoundry: { cache_control: { type: 'ephemeral' } } });
+ });
+
+ it('forwards a caller-supplied cache_control', () => {
+ const opts = buildProviderOptions({
+ config,
+ reasoningEffort: undefined,
+ structuredOutputSpec: textSpec,
+ rawBody: { cache_control: { type: 'ephemeral', ttl: '1h' } },
+ });
+ expect(opts).toEqual({ truefoundry: { cache_control: { type: 'ephemeral', ttl: '1h' } } });
+ });
+ });
+
describe('moonshot provider', () => {
const config = makeConfig({ provider: 'moonshot' });