fix(openclaw): upsert and attach inference provider at AgentHarness sandbox creation#1964
Draft
nloke wants to merge 2 commits into
Draft
fix(openclaw): upsert and attach inference provider at AgentHarness sandbox creation#1964nloke wants to merge 2 commits into
nloke wants to merge 2 commits into
Conversation
…FIED When the openclaw backend returns phase=UNSPECIFIED, the controller would never surface Ready=True to the AgentHarness. Fall back to checking status.conditions[Ready=True] in that case. See: kagent-dev#1958
AgentHarness with openclaw backend fails all LLM calls because the OpenShell inference provider is never attached to the sandbox. The openclaw proxy resolves 'openshell:resolve:env:OPENAI_API_KEY' by looking up credentials from the sandbox's attached provider — if none is attached, the proxy closes the connection. Fix: wire upsertInferenceProviderForHarness into EnsureAgentHarness. It reads the ModelConfig, resolves the API key from the referenced k8s secret, upserts the provider via OpenShell gRPC, and passes it into attachMessagingProviders so the sandbox is created with the provider attached. The sandbox process never holds the real key — credential resolution happens in the proxy at request time, preserving the security model.
Author
|
Fixes #1965 |
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.
Problem
When deploying an
AgentHarnessusing theopenclawbackend, the agent starts and Slack connects successfully, but all LLM calls fail with aConnection error.Root Cause
openclaw uses an HTTP proxy (
HTTPS_PROXY=http://10.200.0.1:3128) to resolve credentials at request time. Theopenclaw.jsonconfig stores an unresolved placeholder:When openclaw (running as UID 998) makes an LLM call, the proxy intercepts the
Bearer openshell:resolve:env:OPENAI_API_KEYheader, looks upOPENAI_API_KEYfrom the sandbox's attached inference provider, and replaces it with the real key before forwarding to the upstream LLM gateway.ClawBackend.EnsureAgentHarnesscallsattachMessagingProvidersto attach Slack providers but never creates or attaches an inference provider. The sandbox is created without one — the proxy has nothing to resolve and closes the connection.Fix
Added
upsertInferenceProviderForHarnesswired intoEnsureAgentHarness:ModelConfigreferenced by theAgentHarnessUpsertInferenceProvideron the OpenShell gRPC API with{OPENAI_API_KEY, OPENAI_BASE_URL}attachMessagingProvidersso the sandbox is created with the provider attachedThe sandbox process never holds the real key — credential resolution happens in the proxy at request time, preserving the OpenShell security model.
Files Changed
openclaw.go—EnsureAgentHarnesswired to callupsertInferenceProviderForHarnessand pass provider into sandbox specproviders.go— newUpsertInferenceProvidermethodopenclaw/modelconfig.go—InferenceProviderNamehelperopenclaw/provider.go— exportedBootstrapProviderBaseURLwrappertranslate.go— phase fallback fix (related: AgentHarness: phaseToCondition should fall back to status.conditions when phase=UNSPECIFIED #1958)Testing
Validated end-to-end on a local kind cluster with a Slack bot (
socket mode) backed by an OpenAI-compatible LiteLLM gateway. Bot receives messages and returns LLM responses after this fix.Notes
translate.gophase fix is bundled here but tracked separately in AgentHarness: phaseToCondition should fall back to status.conditions when phase=UNSPECIFIED #1958