code-agent: inherit child profile via env
This commit is contained in:
@@ -297,7 +297,7 @@ export async function submitAgentRunChatTurn({ params = {}, options = {}, traceI
|
||||
});
|
||||
let runnerJob = null;
|
||||
try {
|
||||
const runnerJobInput = buildAgentRunRunnerJobInput({ env, traceId, commandId, ownerApiKey, toolCapabilities });
|
||||
const runnerJobInput = buildAgentRunRunnerJobInput({ env, traceId, commandId, ownerApiKey, toolCapabilities, backendProfile });
|
||||
runnerJob = await agentRunJson(fetchImpl, managerUrl, `/api/v1/runs/${encodeURIComponent(reusable.mapping.runId)}/runner-jobs`, {
|
||||
method: "POST",
|
||||
body: runnerJobInput,
|
||||
@@ -395,7 +395,7 @@ export async function submitAgentRunChatTurn({ params = {}, options = {}, traceI
|
||||
message: "AgentRun command " + commandId + " created; hwlab-cloud-api will start a runner Job explicitly without relying on scheduler automation.",
|
||||
runId, commandId, backendProfile, waitingFor: "agentrun-runner-job-create", valuesPrinted: false,
|
||||
});
|
||||
const runnerJobInput = buildAgentRunRunnerJobInput({ env, traceId, commandId, ownerApiKey, toolCapabilities });
|
||||
const runnerJobInput = buildAgentRunRunnerJobInput({ env, traceId, commandId, ownerApiKey, toolCapabilities, backendProfile });
|
||||
try {
|
||||
runnerJob = await agentRunJson(fetchImpl, managerUrl, "/api/v1/runs/" + encodeURIComponent(runId) + "/runner-jobs", { method: "POST", body: runnerJobInput, timeoutMs });
|
||||
} catch (error) {
|
||||
@@ -933,8 +933,8 @@ async function resolveOwnerApiKey({ params, options, now }) {
|
||||
if (!key) return "";
|
||||
return text(key.displaySecret ?? "");
|
||||
}
|
||||
function buildAgentRunRunnerJobInput({ env, traceId, commandId, ownerApiKey, toolCapabilities = null }) {
|
||||
const baseTransient = buildAgentRunTransientEnv(env);
|
||||
function buildAgentRunRunnerJobInput({ env, traceId, commandId, ownerApiKey, toolCapabilities = null, backendProfile }) {
|
||||
const baseTransient = buildAgentRunTransientEnv(env, { providerProfile: backendProfile, parentTraceId: traceId });
|
||||
const hwpodAllowed = toolCapabilityAllowed(toolCapabilities, "hwpod");
|
||||
const transientEnv = ownerApiKey && hwpodAllowed
|
||||
? baseTransient.concat([{ name: "HWLAB_API_KEY", value: ownerApiKey, sensitive: true }])
|
||||
@@ -953,7 +953,9 @@ function buildAgentRunRunnerJobInput({ env, traceId, commandId, ownerApiKey, too
|
||||
};
|
||||
}
|
||||
|
||||
function buildAgentRunTransientEnv(env = process.env) {
|
||||
function buildAgentRunTransientEnv(env = process.env, options = {}) {
|
||||
const providerProfile = firstNonEmpty(options.providerProfile);
|
||||
const parentTraceId = firstNonEmpty(options.parentTraceId);
|
||||
const entries = [];
|
||||
for (const name of [
|
||||
"HWLAB_RUNTIME_API_URL",
|
||||
@@ -967,6 +969,8 @@ function buildAgentRunTransientEnv(env = process.env) {
|
||||
const value = firstNonEmpty(env[name]);
|
||||
if (value) entries.push({ name, value, sensitive: false });
|
||||
}
|
||||
if (providerProfile) entries.push({ name: "HWLAB_CODE_AGENT_PROVIDER_PROFILE", value: providerProfile, sensitive: false });
|
||||
if (parentTraceId) entries.push({ name: "HWLAB_CODE_AGENT_PARENT_TRACE_ID", value: parentTraceId, sensitive: false });
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user