mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:48:38 +00:00
refactor: share session send context lines
This commit is contained in:
@@ -70,13 +70,13 @@ export function resolveAnnounceTargetFromKey(sessionKey: string): AnnounceTarget
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildAgentToAgentMessageContext(params: {
|
function buildAgentSessionLines(params: {
|
||||||
requesterSessionKey?: string;
|
requesterSessionKey?: string;
|
||||||
requesterChannel?: string;
|
requesterChannel?: string;
|
||||||
targetSessionKey: string;
|
targetSessionKey: string;
|
||||||
}) {
|
targetChannel?: string;
|
||||||
const lines = [
|
}): string[] {
|
||||||
"Agent-to-agent message context:",
|
return [
|
||||||
params.requesterSessionKey
|
params.requesterSessionKey
|
||||||
? `Agent 1 (requester) session: ${params.requesterSessionKey}.`
|
? `Agent 1 (requester) session: ${params.requesterSessionKey}.`
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -84,7 +84,18 @@ export function buildAgentToAgentMessageContext(params: {
|
|||||||
? `Agent 1 (requester) channel: ${params.requesterChannel}.`
|
? `Agent 1 (requester) channel: ${params.requesterChannel}.`
|
||||||
: undefined,
|
: undefined,
|
||||||
`Agent 2 (target) session: ${params.targetSessionKey}.`,
|
`Agent 2 (target) session: ${params.targetSessionKey}.`,
|
||||||
].filter(Boolean);
|
params.targetChannel ? `Agent 2 (target) channel: ${params.targetChannel}.` : undefined,
|
||||||
|
].filter((line): line is string => Boolean(line));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAgentToAgentMessageContext(params: {
|
||||||
|
requesterSessionKey?: string;
|
||||||
|
requesterChannel?: string;
|
||||||
|
targetSessionKey: string;
|
||||||
|
}) {
|
||||||
|
const lines = ["Agent-to-agent message context:", ...buildAgentSessionLines(params)].filter(
|
||||||
|
Boolean,
|
||||||
|
);
|
||||||
return lines.join("\n");
|
return lines.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,14 +114,7 @@ export function buildAgentToAgentReplyContext(params: {
|
|||||||
"Agent-to-agent reply step:",
|
"Agent-to-agent reply step:",
|
||||||
`Current agent: ${currentLabel}.`,
|
`Current agent: ${currentLabel}.`,
|
||||||
`Turn ${params.turn} of ${params.maxTurns}.`,
|
`Turn ${params.turn} of ${params.maxTurns}.`,
|
||||||
params.requesterSessionKey
|
...buildAgentSessionLines(params),
|
||||||
? `Agent 1 (requester) session: ${params.requesterSessionKey}.`
|
|
||||||
: undefined,
|
|
||||||
params.requesterChannel
|
|
||||||
? `Agent 1 (requester) channel: ${params.requesterChannel}.`
|
|
||||||
: undefined,
|
|
||||||
`Agent 2 (target) session: ${params.targetSessionKey}.`,
|
|
||||||
params.targetChannel ? `Agent 2 (target) channel: ${params.targetChannel}.` : undefined,
|
|
||||||
`If you want to stop the ping-pong, reply exactly "${REPLY_SKIP_TOKEN}".`,
|
`If you want to stop the ping-pong, reply exactly "${REPLY_SKIP_TOKEN}".`,
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
return lines.join("\n");
|
return lines.join("\n");
|
||||||
@@ -127,14 +131,7 @@ export function buildAgentToAgentAnnounceContext(params: {
|
|||||||
}) {
|
}) {
|
||||||
const lines = [
|
const lines = [
|
||||||
"Agent-to-agent announce step:",
|
"Agent-to-agent announce step:",
|
||||||
params.requesterSessionKey
|
...buildAgentSessionLines(params),
|
||||||
? `Agent 1 (requester) session: ${params.requesterSessionKey}.`
|
|
||||||
: undefined,
|
|
||||||
params.requesterChannel
|
|
||||||
? `Agent 1 (requester) channel: ${params.requesterChannel}.`
|
|
||||||
: undefined,
|
|
||||||
`Agent 2 (target) session: ${params.targetSessionKey}.`,
|
|
||||||
params.targetChannel ? `Agent 2 (target) channel: ${params.targetChannel}.` : undefined,
|
|
||||||
`Original request: ${params.originalMessage}`,
|
`Original request: ${params.originalMessage}`,
|
||||||
params.roundOneReply
|
params.roundOneReply
|
||||||
? `Round 1 reply: ${params.roundOneReply}`
|
? `Round 1 reply: ${params.roundOneReply}`
|
||||||
|
|||||||
Reference in New Issue
Block a user