feat: add runtime llm facade#54
Merged
Merged
Conversation
This was referenced Jun 22, 2026
Closed
d552c95 to
17a6d61
Compare
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
17a6d61 to
3273e6d
Compare
ensureSessionClaudeLLMFacadeConfig tolerated a missing model whenever any Anthropic key was present, including keys that only live in per-session env. Request-time provider resolution runs without session env, so such a token can never resolve a provider and every runtime request fails. Restrict the tolerance to daemon-level keys (global/os/config), which can bootstrap a provider from the request's model at call time; a session-only key without a model now fails fast at config time instead of injecting an unbound token. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Remove the now-unused (*LLMClient).resolveAPIKey, orphaned when Generate switched to provider-target header resolution (staticcheck U1000). - Drop the redundant http.CanonicalHeaderKey wrap in providerForwardHeaders; http.Header.Set canonicalizes its key internally (staticcheck S1035). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Session provider keys live only in the non-persisted Session.ProviderEnvItems and in the llm_provider row written at creation; the session env persisted to the store has the keys filtered out. After stop/resume, resolution saw only the key-filtered env, so it skipped the session-env provider (selected only with an explicit id) and could even overwrite its key with the empty env, leaving the session without working LLM credentials. Pin the persisted session-env provider id during resolution when the env can no longer supply a key for the family, so the durable llm_provider row (the intended authority for the key) is reused instead of skipped or clobbered. An env that still carries a key keeps re-bootstrapping, so key rotation is unaffected. Keeps raw keys out of the persisted session surface. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Author
|
Regression update for the runtime LLM facade PR: Validated:
Compatibility finding:
Result:
Merge stance:
|
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.
Summary
Adds a daemon-side Runtime LLM Facade so guest runtimes no longer receive upstream provider keys directly. The daemon now owns provider/model resolution, session-scoped facade tokens, key/header injection, and OpenAI/Anthropic protocol conversion through
ai-api-protocol-bridge.What changed
LLM_API_KEY,LLM_API_ENDPOINT, provider-specific key aliases, and facade base URLs.secret=trueenv vars.Token lifecycle & resolution hardening
run_idin the facade token scope for auditability.x-api-keyvsAuthorization: Bearer) from the same env source the provider key is resolved from, so a session-scoped provider never mixes a key from one scope with a header decided by another.Compatibility
Related issues
Fixes #27
Related but not closed: #14, #20, #22, #31.
Validation
Rebased onto latest
main(incl. #61 agent system prompt convention); both feature sets coexist.go test ./pkg/agentcompose ./pkg/driver(full packages, all green)go test ./pkg/agentcompose -run 'TestRuntimeLLM|TestEnsureSessionLLMFacadeConfig|TestEnsureSessionAnthropicEnvProviderAuthUsesSessionEnvOnly|TestRevokeLLMFacadeTokensForSessionPrunesDeadRows|TestDeleteLLMFacadeToken|TestResolveRuntimeLLMTargetByExistingProviderID|TestManagedRuntimeEnvMapKeepsFacadeKeyAliases|TestCreateSessionFiltersLLMProviderKeysFromPersistedEnv|TestAnthropicProvider|TestProviderForwardHeaders'go build ./...,go vet ./pkg/agentcompose ./pkg/driver,gofmtclean