feat(arena): forward chat history to spawned agents

Add stripStartupContext to remove env-info from parent history and pass
chatHistory through ArenaManager → InProcessBackend → AgentInteractive →
AgentCore. This allows arena agents to start with conversational context
from the main session.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-03-10 19:45:14 +08:00
parent 89f8751233
commit 9f7e3e054f
15 changed files with 249 additions and 2 deletions

View file

@ -21,6 +21,7 @@ import {
ArenaSessionStatus,
AuthType,
createDebugLogger,
stripStartupContext,
type Config,
type ArenaModelConfig,
type ArenaAgentErrorEvent,
@ -171,6 +172,18 @@ function executeArenaCommand(
ui: CommandContext['ui'],
input: ArenaExecutionInput,
): void {
// Capture the main session's chat history so arena agents start with
// conversational context. Strip the leading startup context (env info
// user message + model ack) because each agent generates its own for
// its worktree directory — keeping the parent's would duplicate it.
let chatHistory;
try {
const fullHistory = config.getGeminiClient().getHistory();
chatHistory = stripStartupContext(fullHistory);
} catch {
debugLogger.debug('Could not retrieve chat history for arena agents');
}
const manager = new ArenaManager(config);
const emitter = manager.getEventEmitter();
const detachListeners: Array<() => void> = [];
@ -331,6 +344,7 @@ function executeArenaCommand(
cols,
rows,
approvalMode: input.approvalMode,
chatHistory,
})
.then(
() => {

View file

@ -155,6 +155,7 @@ export const AgentChatView = ({ agentId }: AgentChatViewProps) => {
),
// eslint-disable-next-line react-hooks/exhaustive-deps
[
agentId,
messages.length,
pendingApprovals?.size,
liveOutputs?.size,