Skip to content

Support for TrueFoundry AI Gateway as model provider - #483

Merged
thesujai merged 1 commit into
mainfrom
cj-truefoundry-ai-gateway-models
Sep 1, 2026
Merged

Support for TrueFoundry AI Gateway as model provider#483
thesujai merged 1 commit into
mainfrom
cj-truefoundry-ai-gateway-models

Conversation

@chiragjn

@chiragjn chiragjn commented Aug 27, 2026

Copy link
Copy Markdown
Member

Summary

Support for TrueFoundry AI Gateway as model provider

How was this tested?

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

High Risk
Changes authentication (per-caller gateway tokens, OIDC mutual exclusion), routes all model listing and inference through external ServiceFoundry/Gateway, and passes caller tokens into LLM config—security- and availability-sensitive paths.

Overview
Adds TrueFoundry mode when TRUEFOUNDRY_SERVICEFOUNDRY_SERVER_URL is set: chat models are discovered from the ServiceFoundry server (caller Bearer/access cookie) and LLM calls go to the tenant’s default AI Gateway using that token. Startup rejects enabling OIDC alongside this mode.

Introduces a read-only truefoundry model provider (TrueFoundryModelProviderStore + TrueFoundryServiceFoundryServerClient), optional internal mTLS (TRUEFOUNDRY_MTLS_ENABLED / TRUEFOUNDRY_MTLS_CERTS_DIR), and resolveModelProviderStore(c) so HTTP handlers get a token-bound store while background jobs keep the DB store. Settings create/replace model provider returns 424 when resources are TrueFoundry-managed; OpenAPI/SDK gain TrueFoundryModelProvider, 401 on list models / create turn, and 424 on provider writes.

VercelAILLM treats truefoundry like other OpenAI-compatible providers (requires baseUrl). Auth middleware adds requireAccessToken and accessToken cookie reading; optional ACCESS_LOGS request logging. UI catalog typing excludes truefoundry from user-savable presets.

Reviewed by Cursor Bugbot for commit 08fc847. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 08fc847

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@truefoundry/trueforge-sdk Patch
@truefoundry/trueforge Minor
@truefoundry/trueforge-core Minor
@truefoundry/trueforge-ui Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chiragjn
chiragjn force-pushed the cj-truefoundry-ai-gateway-models branch from f15030a to dd10940 Compare August 27, 2026 21:36
Comment thread packages/trueforge/src/truefoundry/tenantCache.ts Outdated
Comment thread packages/trueforge/src/model-registry/ModelRegistry.ts Outdated
Comment thread .changeset/20260827213832-regenerate-sdk-from-openapi.md
@chiragjn chiragjn self-assigned this Aug 28, 2026
@chiragjn
chiragjn force-pushed the cj-truefoundry-ai-gateway-models branch 3 times, most recently from 8304e17 to 663fe55 Compare August 31, 2026 12:40
Comment thread packages/trueforge/src/config.ts
Comment thread packages/trueforge/src/runtime/sessionResources.ts Outdated
Comment thread packages/trueforge-core/src/core/llm/VercelAILLM.ts
@thesujai

thesujai commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
Agent Creations Payload: {
    "name": "tfy-managedagent",
    "manifest": {
        "model": {
            "name": "anthropic-gateway/claude-opus-4-7",
            "params": {}
        },
        "config": {
            "iteration_limit": 100,
            "sandbox": {
                "enabled": true,
                "file_downloads": true
            },
            "dynamic_sub_agents": {
                "enabled": true
            },
            "context_management": {
                "compaction": {
                    "enabled": true
                },
                "large_tool_response": {
                    "enabled": true
                }
            },
            "generative_ui": {
                "enabled": true
            },
            "ask_user_questions": {
                "enabled": true
            }
        },
        "instructions": "you are dude",
        "mcp_servers": [],
        "skills": []
    }
}

Repose Agent creation: {
    "data": {
        "id": "01m1dpgezn9dphkbj5bcjtybzg",
        "name": "tfy-managedagent",
        "manifest": {
            "model": {
                "name": "anthropic-gateway/claude-opus-4-7",
                "params": {}
            },
            "instructions": "you are dude",
            "mcp_servers": [],
            "skills": [],
            "config": {
                "iteration_limit": 100,
                "sandbox": {
                    "enabled": true,
                    "file_downloads": true
                },
                "dynamic_sub_agents": {
                    "enabled": true
                },
                "context_management": {
                    "compaction": {
                        "enabled": true
                    },
                    "large_tool_response": {
                        "enabled": true
                    }
                },
                "generative_ui": {
                    "enabled": true
                },
                "ask_user_questions": {
                    "enabled": true
                }
            }
        }
    }
}

Session Creation(Inline): {
    "agent": {
        "spec": {
            "model": {
                "name": "agent-harness-anthropic/claude-opus-4-5",
                "params": {
                    "reasoning_effort": "low"
                }
            },
            "instructions": "you are dude",
            "config": {
                "iteration_limit": 100,
                "sandbox": {
                    "enabled": true,
                    "file_downloads": true
                },
                "dynamic_sub_agents": {
                    "enabled": true
                },
                "context_management": {
                    "compaction": {
                        "enabled": true
                    },
                    "large_tool_response": {
                        "enabled": true
                    }
                },
                "generative_ui": {
                    "enabled": true
                },
                "ask_user_questions": {
                    "enabled": true
                }
            },
            "mcp_servers": [],
            "skills": []
        }
    }
}
Response:
{
    "data": {
        "id": "01m1dttsfv058xht2tra7zgjj4",
        "agent": {
            "type": "inline",
            "spec": {
                "model": {
                    "name": "agent-harness-anthropic/claude-opus-4-5",
                    "params": {
                        "reasoning_effort": "low"
                    }
                },
                "instructions": "you are dude",
                "mcp_servers": [],
                "skills": [],
                "config": {
                    "iteration_limit": 100,
                    "sandbox": {
                        "enabled": true,
                        "file_downloads": true
                    },
                    "dynamic_sub_agents": {
                        "enabled": true
                    },
                    "context_management": {
                        "compaction": {
                            "enabled": true
                        },
                        "large_tool_response": {
                            "enabled": true
                        }
                    },
                    "generative_ui": {
                        "enabled": true
                    },
                    "ask_user_questions": {
                        "enabled": true
                    }
                }
            }
        },
        "title": null,
        "created_by": "trueforge-default",
        "created_at": "2026-09-01T06:34:50.730Z",
        "updated_at": "2026-09-01T06:34:50.730Z"
    }
}



Get models:
{
    "data": [
        {
            "name": "agent-harness-anthropic/claude-opus-4-5",
            "model_id": "agent-harness-anthropic/claude-opus-4-5",
            "provider": {
                "name": "agent-harness-anthropic"
            },
            "properties": {
                "context_length": 200000,
                "max_output_tokens": 64000,
                "reasoning_efforts": [
                    "low",
                    "medium",
                    "high"
                ]
            }
        }
        ...
    ]
}



Without Tfy Registry, Get models:
{
    "data": [
        {
            "name": "google-gemini/gemini-3-6-flash",
            "model_id": "gemini-3.6-flash",
            "provider": {
                "name": "google-gemini"
            },
            "properties": {
                "context_length": 1048576,
                "max_output_tokens": 65536,
                "reasoning_efforts": [
                    "minimal",
                    "low",
                    "medium",
                    "high"
                ]
            }
        }
    ]
}



These is no diff at all

cc @debajyoti-truefoundry @chiragjn

Comment thread packages/trueforge/src/apis/turns.ts Outdated
Comment thread packages/trueforge-ui/src/server/modelProviderSettings.ts Outdated
Comment thread packages/trueforge/src/schemas/modelProvider.ts
Comment thread packages/trueforge/package.json Outdated
Comment thread packages/frontend/src/App.tsx Outdated
Comment thread .changeset/truefoundry-servicefoundry-server-model-store.md Outdated
@thesujai thesujai changed the title [WIP] Support for TrueFoundry AI Gateway as model provider Support for TrueFoundry AI Gateway as model provider Sep 1, 2026
Comment thread packages/trueforge/src/apis/capabilities.ts Outdated
Comment thread packages/trueforge/src/apis/modelProviders.ts Outdated
Comment thread packages/trueforge/src/apis/modelProviders.ts Outdated
Comment thread packages/trueforge/src/apis/modelProviders.ts Outdated
Comment thread charts/trueforge/values.yaml Outdated
Comment thread charts/trueforge/values.yaml Outdated
Comment thread charts/trueforge/values.yaml Outdated
Comment thread packages/trueforge/src/main.ts Outdated
Comment thread packages/trueforge/package.json Outdated
Comment thread charts/trueforge/values.yaml Outdated
Comment thread packages/trueforge/src/main.ts
Comment thread packages/trueforge/src/routes/modelProviderRoutes.ts Outdated
Comment thread packages/trueforge/src/routes/capabilityRoutes.ts Outdated
Comment thread packages/trueforge/src/routes/turnRoutes.ts Outdated
Comment thread charts/trueforge/values.yaml Outdated
Comment thread packages/trueforge/src/db/modelProviderStore.ts Outdated
Comment thread packages/trueforge/src/truefoundry/TrueFoundryModelProviderStore.ts
Comment thread packages/trueforge/src/main.ts Outdated
Comment thread packages/trueforge/src/main.ts Outdated
Comment thread packages/trueforge/src/truefoundry/mapEnabledModels.ts Outdated
Comment thread packages/trueforge/src/truefoundry/mapEnabledModels.ts Outdated
Comment thread packages/trueforge/src/truefoundry/mapEnabledModels.ts Outdated
Comment thread packages/trueforge/src/truefoundry/mapEnabledModels.ts Outdated
Comment thread packages/trueforge/src/truefoundry/mapEnabledModels.ts Outdated
Comment thread packages/trueforge/src/truefoundry/TrueFoundryModelProviderStore.ts Outdated
Comment thread packages/trueforge/src/truefoundry/trueFoundryManaged.ts
Comment thread packages/trueforge/src/auth/middleware.ts Outdated
Comment thread packages/trueforge/src/truefoundry/mapEnabledModels.ts Outdated
Comment thread packages/trueforge/src/truefoundry/mapEnabledModels.ts
@thesujai
thesujai force-pushed the cj-truefoundry-ai-gateway-models branch from a2c6b6e to 53dba13 Compare September 1, 2026 17:17
@thesujai
thesujai enabled auto-merge (squash) September 1, 2026 17:18
Add TrueFoundry mode: models are sourced from the ServiceFoundry
provider-integrations API and invoked through the TrueFoundry AI gateway,
resolved per request from the caller's token.

- Per-request model provider store: `resolveModelProviderStore(c?)` returns a
  token-bound TrueFoundry store when a request context is present, and the DB
  persistence store otherwise (e.g. the scheduler).
- TrueFoundry provider manifest carries base_url + auth; auth is redacted from
  API responses and the store is the source of truth at runtime.
- mTLS support for ServiceFoundry calls (TRUEFOUNDRY_MTLS_ENABLED /
  TRUEFOUNDRY_MTLS_CERTS_DIR); no caching of tokens, gateway URLs, or model
  properties; request timings are logged.
- TrueFoundry-managed resources reject writes with a standardized 424; reads
  behave normally.

Co-authored-by: Cursor <cursoragent@cursor.com>
@thesujai
thesujai force-pushed the cj-truefoundry-ai-gateway-models branch from 58b98df to 08fc847 Compare September 1, 2026 17:32

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 08fc847. Configure here.

Comment thread packages/trueforge/src/auth/middleware.ts
@thesujai
thesujai merged commit 8f1a2dc into main Sep 1, 2026
12 checks passed
@thesujai
thesujai deleted the cj-truefoundry-ai-gateway-models branch September 1, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants