Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cli/src/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export default {
'toolDisplayName.TaskStop': 'toolDisplayName.TaskStop',
'toolDisplayName.TeamCreate': 'toolDisplayName.TeamCreate',
'toolDisplayName.TeamDelete': 'toolDisplayName.TeamDelete',
'toolDisplayName.TeamPlanApproval': 'toolDisplayName.TeamPlanApproval',
'toolDisplayName.SendMessage': 'toolDisplayName.SendMessage',
'toolDisplayName.StructuredOutput': 'toolDisplayName.StructuredOutput',
'toolDisplayName.Monitor': 'toolDisplayName.Monitor',
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/i18n/locales/zh-TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export default {
'toolDisplayName.TaskStop': '停止任務',
'toolDisplayName.TeamCreate': '建立團隊',
'toolDisplayName.TeamDelete': '刪除團隊',
'toolDisplayName.TeamPlanApproval': '團隊計畫審批',
'toolDisplayName.SendMessage': '傳送訊息',
'toolDisplayName.StructuredOutput': '結構化輸出',
'toolDisplayName.Monitor': '監控',
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/i18n/locales/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export default {
'toolDisplayName.TaskStop': '停止任务',
'toolDisplayName.TeamCreate': '创建团队',
'toolDisplayName.TeamDelete': '删除团队',
'toolDisplayName.TeamPlanApproval': '团队计划审批',
'toolDisplayName.SendMessage': '发送消息',
'toolDisplayName.StructuredOutput': '结构化输出',
'toolDisplayName.Monitor': '监控',
Expand Down
19 changes: 19 additions & 0 deletions packages/core/src/agents/arena/ArenaManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ArenaManager } from './ArenaManager.js';
import { ArenaEventType } from './arena-events.js';
import { ArenaSessionStatus, ARENA_MAX_AGENTS } from './types.js';
import { AgentStatus } from '../runtime/agent-types.js';
import { ApprovalMode } from '../../config/config.js';

const hoistedMockSetupWorktrees = vi.hoisted(() => vi.fn());
const hoistedMockCleanupSession = vi.hoisted(() => vi.fn());
Expand Down Expand Up @@ -348,6 +349,24 @@ describe('ArenaManager', () => {
});

describe('chat history forwarding', () => {
it('passes approvalMode to in-process backend spawn configs', async () => {
mockBackend.type = 'in-process';
const manager = new ArenaManager(mockConfig as never);

await manager.start({
...createValidStartOptions(),
approvalMode: ApprovalMode.PLAN,
});

expect(mockBackend.spawnAgent).toHaveBeenCalledTimes(2);
for (const call of mockBackend.spawnAgent.mock.calls) {
const spawnConfig = call[0] as {
inProcess?: { approvalMode?: unknown };
};
expect(spawnConfig.inProcess?.approvalMode).toBe(ApprovalMode.PLAN);
}
});

it('should pass chatHistory to backend spawnAgent calls', async () => {
const manager = new ArenaManager(mockConfig as never);
const chatHistory = [
Expand Down
16 changes: 15 additions & 1 deletion packages/core/src/agents/arena/ArenaManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import * as fs from 'node:fs/promises';
import * as path from 'node:path';
import { GitWorktreeService } from '../../services/gitWorktreeService.js';
import { Storage } from '../../config/storage.js';
import type { Config } from '../../config/config.js';
import {
APPROVAL_MODES,
type ApprovalMode,
type Config,
} from '../../config/config.js';
import { getCoreSystemPrompt } from '../../core/prompts.js';
import { createDebugLogger } from '../../utils/debugLogger.js';
import { isNodeError } from '../../utils/errors.js';
Expand Down Expand Up @@ -1068,6 +1072,7 @@ export class ArenaManager {
inProcess: {
agentName: model.modelId,
initialTask: this.arenaConfig?.task,
approvalMode: toApprovalMode(this.arenaConfig?.approvalMode),
runtimeConfig: {
promptConfig: {
systemPrompt: getCoreSystemPrompt(
Expand Down Expand Up @@ -1802,6 +1807,15 @@ export class ArenaManager {
}
}

function toApprovalMode(mode: string | undefined): ApprovalMode | undefined {
if (!mode) {
return undefined;
}
return APPROVAL_MODES.includes(mode as ApprovalMode)
? (mode as ApprovalMode)
: undefined;
}

function truncateForPrompt(text: string, maxChars: number): string {
if (text.length <= maxChars) return text;
return `${text.slice(0, maxChars)}\n...[truncated]`;
Expand Down
Loading
Loading