Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

fix(coding-agent): treat a set-but-empty credential env var as missing (#1513)

Sebastian Müller91b5c6191c00
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index aab2e32ad8..a2be789465 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -2,6 +2,7 @@
## [Unreleased]
+- Fixed credentials configured as env var names resolving to the literal variable name when the variable is set but empty; an empty env var now reports a missing credential ([#1468](https://github.com/PrimeIntellect-ai/prime-agent/discussions/1468)).
- Fixed ACP rejecting an immediate follow-up prompt when injected work restarted the session; follow-ups now queue behind in-flight work, and cancellation drops queued follow-ups before they start.
- Added correlated ACP terminal-quiescence metadata, resident session settlement, and fail-closed daemon input fencing; prevented recovery state from persisting runtime credentials or model configuration.
- Fixed explicit RLM child deletion leaving hidden unsettled work after runtime teardown, including reporting cleanup failures and notifying the parent when deletion completes.
diff --git a/packages/coding-agent/src/core/resolve-config-value.ts b/packages/coding-agent/src/core/resolve-config-value.ts
index ffff420893..8db0821cc0 100644
--- a/packages/coding-agent/src/core/resolve-config-value.ts
+++ b/packages/coding-agent/src/core/resolve-config-value.ts
@@ -17,8 +17,16 @@ export function resolveConfigValue(config: string): string | undefined {
if (config.startsWith("!")) {
return executeCommand(config);
}
+ return resolveEnvOrLiteral(config);
+}
+
+/** Unset env var: fall back to the literal string. Set-but-empty: missing credential, never the var name. */
+function resolveEnvOrLiteral(config: string): string | undefined {
const envValue = process.env[config];
- return envValue || config;
+ if (envValue !== undefined) {
+ return envValue || undefined;
+ }
+ return config;
}
function executeWithConfiguredShell(command: string): { executed: boolean; value: string | undefined } {
@@ -91,8 +99,7 @@ export function resolveConfigValueUncached(config: string): string | undefined {
if (config.startsWith("!")) {
return executeCommandUncached(config);
}
- const envValue = process.env[config];
- return envValue || config;
+ return resolveEnvOrLiteral(config);
}
export function resolveConfigValueOrThrow(config: string, description: string): string {
diff --git a/packages/coding-agent/test/resolve-config-value.test.ts b/packages/coding-agent/test/resolve-config-value.test.ts
new file mode 100644
index 0000000000..dd249c7ea9
--- /dev/null
+++ b/packages/coding-agent/test/resolve-config-value.test.ts
@@ -0,0 +1,35 @@
+import { afterEach, beforeEach, describe, expect, it } from "vitest";
+import {
+ resolveConfigValue,
+ resolveConfigValueOrThrow,
+ resolveConfigValueUncached,
+} from "../src/core/resolve-config-value.js";
+
+const VAR = "PRIME_AGENT_TEST_CREDENTIAL_VAR";
+
+describe("resolveConfigValue env fallback", () => {
+ beforeEach(() => {
+ delete process.env[VAR];
+ });
+ afterEach(() => {
+ delete process.env[VAR];
+ });
+
+ it("uses the env var value when set", () => {
+ process.env[VAR] = "secret-value";
+ expect(resolveConfigValue(VAR)).toBe("secret-value");
+ expect(resolveConfigValueUncached(VAR)).toBe("secret-value");
+ });
+
+ it("falls back to the literal string when the env var is unset", () => {
+ expect(resolveConfigValue(VAR)).toBe(VAR);
+ expect(resolveConfigValue("sk-literal-key")).toBe("sk-literal-key");
+ });
+
+ it("treats a set-but-empty env var as a missing credential, not the literal name", () => {
+ process.env[VAR] = "";
+ expect(resolveConfigValue(VAR)).toBeUndefined();
+ expect(resolveConfigValueUncached(VAR)).toBeUndefined();
+ expect(() => resolveConfigValueOrThrow(VAR, "test credential")).toThrow("Failed to resolve test credential");
+ });
+});