Repository navigation
fix(sdk): log the CodeAF missing-key warning once, and count the harness config's env - #1132
Merged
Merged
Conversation
The shared contract and the provider docs said a refused call warns once and an Agent warns once at construction, so a keyless agent logged the same warning twice. They now say the warning is logged once per process, at construction when the effective environment (the process environment plus the harness config's env map) has no key, otherwise at the first refused call. Every refused call still fails with the not-configured error. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…arness config's env Agent construction and refused calls kept separate once-flags, so a keyless agent logged the warning twice. The construction check also read the process environment only, so a key passed through HarnessConfig.env drew a false "harness calls will fail" warning, and a config env that blanks the key drew none. Both paths now share one flag, and construction builds the environment through the same _child_environment call the harness calls use. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nfig.Env The agent package had its own sync.Once beside the harness package's, so a keyless agent logged the warning at construction and again at the first refused call, and the construction check ignored HarnessConfig.Env. One Once in package harness now serves both paths through WarnCodeAFMissingKeyOnce, and construction checks CodeAFHasCredentials with the config's Env. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…arnessConfig.env Construction and refused calls kept separate flags, so a keyless agent warned twice, and the construction check ignored harnessConfig.env. Both paths now share one flag, and construction passes the config's env through the same childEnvironment call the harness calls use. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
Performance
⚠ Regression detected:
|
Contributor
📊 Coverage gateThresholds from
✅ Gate passedNo surface regressed past the allowed threshold and the aggregate stayed above the floor. |
Contributor
📐 Patch coverage gateThreshold: 80% on lines this PR touches vs
✅ Patch gate passedEvery surface whose lines were touched by this PR has patch coverage at or above the threshold. |
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
Follow-up to #1130. The v0.1.144 release sweep found that the CodeAF missing-key warning misfired in three ways, all in all three SDKs:
envmap (calls work)envblanks it (calls are refused)No call outcome changes: keyless calls are still refused before CodeAF is resolved, downloaded or launched, with the same
HarnessProviderNotConfigured/ProviderUnavailableError{NotConfigured: true}error and message, and keyed calls are untouched. Only when the warning line is logged changes.Root cause
_construction_warning_logged/_missing_key_logged, TSconstructionWarningLogged/missingKeyLogged, Goagent.codeAFConfigWarning/harness.codeAFMissingKeyOnce).envmap is applied to every call it makes (Python runnerenv, TS runnerenv, Goopts.Env = hc.Env). The construction check read only the process environment, while the call path read the process environment plus that map.Changes
sync.Oncein packageharness, exposed asharness.WarnCodeAFMissingKeyOnceso the agent package prints through its configured logger)._child_environment/childEnvironment/CodeAFHasCredentialswithOptions{Env: cfg.HarnessConfig.Env}), with the config's env map as the overlay.sdk/codeaf-auth-contract.jsonnow describe the shared budget and the effective environment. All 42 cases are unchanged.docs/harness-providers.mdand the agentfield skill snapshot say the same thing; the embedded mirror is kept byte-identical.Validation contract
overlaysupplied as the harness config's env map, construction warns if and only if the case is not allowed.New tests are named after the W item they prove, in
test_harness_codeaf_auth.py,harness_codeaf_auth.test.ts,codeaf_auth_test.goandagent/harness_auth_test.go. The Go agent tests run each W1/W3 case in a fresh test process, so the sharedsync.Oncestarts unspent without an exported reset.Test plan
ruff check .(0.15.22),mypy --config-file mypy.ini agentfield/,./scripts/run_pytest.sh(full suite) — all cleango mod tidy(no change),go build ./...,go vet ./...,go test ./...— 8 packages oknpm ci,npm run lint,npm test— 98 files, 1380 passed, 1 skippedscripts/sync-embedded-skills.sh --checkand control-planeTestSkillCatalogAndEmbeddedMirrorsStayAlignedHarnessProviderNotConfigured, no network); a key only inHarnessConfig.envlogs 1 false warning before and 0 after; a process key blanked byHarnessConfig.envlogs 0 before and 1 after.🤖 Generated with Claude Code