feat: apply per-chat master-agent execution config
This commit is contained in:
@@ -38,6 +38,28 @@ type QueuedMasterAgentReplyEnvelope = {
|
||||
};
|
||||
};
|
||||
|
||||
export async function resolveMasterAgentExecutionConfig(projectId: string) {
|
||||
const runtime = await getMasterAgentRuntimeAccount();
|
||||
if (!runtime?.account) {
|
||||
throw new Error("NO_MASTER_AGENT_RUNTIME_ACCOUNT");
|
||||
}
|
||||
|
||||
const agentControls = await getProjectAgentControls(projectId);
|
||||
const reasoningEffort =
|
||||
agentControls?.reasoningEffortOverride ||
|
||||
(runtime.account as typeof runtime.account & { reasoningEffort?: ReasoningEffort }).reasoningEffort ||
|
||||
"medium";
|
||||
|
||||
return {
|
||||
runtime,
|
||||
account: runtime.account,
|
||||
agentControls,
|
||||
provider: runtime.account.provider,
|
||||
model: agentControls?.modelOverride || runtime.account.model || "gpt-5.4",
|
||||
reasoningEffort,
|
||||
};
|
||||
}
|
||||
|
||||
function buildAgentControlsDigest(agentControls?: ProjectAgentControls | null) {
|
||||
if (!agentControls) {
|
||||
return "当前对话覆盖:无";
|
||||
@@ -1129,7 +1151,6 @@ export async function replyToMasterAgentUserMessage(params: {
|
||||
mode?: "wait" | "enqueue";
|
||||
}) {
|
||||
const runtime = await getMasterAgentRuntimeAccount();
|
||||
const agentControls = await getProjectAgentControls("master-agent");
|
||||
|
||||
if (!runtime?.account) {
|
||||
await appendMasterAgentSystemReply(
|
||||
@@ -1138,6 +1159,9 @@ export async function replyToMasterAgentUserMessage(params: {
|
||||
return { ok: false as const, reason: "NO_AI_ACCOUNT" };
|
||||
}
|
||||
|
||||
const executionConfig = await resolveMasterAgentExecutionConfig("master-agent");
|
||||
const agentControls = executionConfig.agentControls;
|
||||
|
||||
if (params.mode === "enqueue") {
|
||||
if (runtime.account.provider === "master_codex_node") {
|
||||
const state = await readState();
|
||||
@@ -1221,8 +1245,8 @@ export async function replyToMasterAgentUserMessage(params: {
|
||||
requestedByAccount: params.requestedByAccount,
|
||||
currentSessionExpiresAt: params.currentSessionExpiresAt,
|
||||
apiKey: runtime.account.apiKey,
|
||||
model: agentControls?.modelOverride || runtime.account.model || "gpt-5.4",
|
||||
reasoningEffort: agentControls?.reasoningEffortOverride || "medium",
|
||||
model: executionConfig.model,
|
||||
reasoningEffort: executionConfig.reasoningEffort,
|
||||
agentControls,
|
||||
});
|
||||
}
|
||||
@@ -1338,8 +1362,8 @@ export async function replyToMasterAgentUserMessage(params: {
|
||||
try {
|
||||
const generated = await generateOpenAiReply({
|
||||
apiKey: runtime.account.apiKey,
|
||||
model: agentControls?.modelOverride || runtime.account.model || "gpt-5.4",
|
||||
reasoningEffort: agentControls?.reasoningEffortOverride || "medium",
|
||||
model: executionConfig.model,
|
||||
reasoningEffort: executionConfig.reasoningEffort,
|
||||
requestText: params.requestText,
|
||||
currentSessionExpiresAt: params.currentSessionExpiresAt,
|
||||
agentControls,
|
||||
|
||||
Reference in New Issue
Block a user