feat(build): wire the model provider's API key into generated secrets#152
Merged
initializ-mk merged 1 commit intoJun 11, 2026
Merged
Conversation
The provider's APIKeyEnvVar (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY) is defined in forge-core/catalog but was never referenced at build time, so it never became a secrets.yaml placeholder or a Deployment secretKeyRef env entry. A deployed agent therefore had no way to receive its provider key and the LLM client fell back to a stub at runtime. Add ModelProviderStage: it looks up the configured model provider in the catalog and adds its APIKeyEnvVar to Spec.Requirements.EnvOptional — optional, because a provider may authenticate via OAuth and local providers (e.g. Ollama) need no key at all. The existing secrets.yaml / deployment.yaml templates then emit the placeholder and the secretKeyRef env entry, so an operator-supplied key reaches the running agent. Runs after ChannelsStage; de-dups against skill/channel-declared env vars.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a build stage that includes the model provider's API-key env var (e.g.
OPENAI_API_KEY) in the generatedsecrets.yamlanddeployment.yaml, so a deployed agent can actually receive its provider key.Why
The provider's
APIKeyEnvVaris defined inforge-core/catalog/providers.go(OPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY) but is never referenced at build time. The secret-placeholder set (Spec.Requirements.EnvRequired/EnvOptional) is populated only from skills (RequirementsStage) and channels (ChannelsStage). As a result:OPENAI_API_KEYplaceholder insecrets.yaml,secretKeyRefenv entry indeployment.yaml,no OpenAI API key … using stuband falls back to a stub LLM.Change
ModelProviderStage(runs afterChannelsStage): looks upConfig.Model.Providerin the catalog and appends itsAPIKeyEnvVartoSpec.Requirements.EnvOptional.APIKeyEnvVar) need no key. An unset optional secret key is ignored at runtime.The existing
secrets.yaml.tmpl/deployment.yaml.tmplalready iterateOptionalEnvVars, so no template changes are needed.Test
model_provider_stage_test.go): adds the key as optional, populatesRequirementswhen nil, skips when already declared, and adds nothing for keyless/unknown providers.gofmtclean;go build ./...clean.forge buildon anopenaiagent now emitsOPENAI_API_KEY: ""insecrets.yamland anOPENAI_API_KEYsecretKeyRef(optional) indeployment.yaml.Impact
Operators (or the initializ build/deploy pipeline's
SECRET_VARS) can now populate the provider key into the agent's<id>-secretsand it flows through to the pod — enabling real inference instead of the stub.