feat(arena): add info message for forwarded chat history

- Add info message when chatHistory is passed to spawned agents
- Add tests for info message presence and absence

This provides visibility to users when chat history context is included
in spawned agent sessions.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-03-10 20:37:08 +08:00
parent 9f7e3e054f
commit addbdcb0ef
2 changed files with 38 additions and 0 deletions

View file

@ -554,6 +554,37 @@ describe('AgentInteractive', () => {
await agent.shutdown();
});
it('should add info message when chatHistory is present', async () => {
const { core } = createMockCore();
const chatHistory = [
{ role: 'user' as const, parts: [{ text: 'earlier question' }] },
{ role: 'model' as const, parts: [{ text: 'earlier answer' }] },
];
const agent = new AgentInteractive(createConfig({ chatHistory }), core);
await agent.start(context);
const messages = agent.getMessages();
expect(messages).toHaveLength(1);
expect(messages[0]).toMatchObject({
role: 'info',
content: 'History context from parent session included (2 messages)',
});
await agent.shutdown();
});
it('should not add info message when chatHistory is absent', async () => {
const { core } = createMockCore();
const agent = new AgentInteractive(createConfig(), core);
await agent.start(context);
expect(agent.getMessages()).toHaveLength(0);
await agent.shutdown();
});
it('should pass undefined extraHistory when chatHistory is not set', async () => {
const { core } = createMockCore();
const config = createConfig();

View file

@ -111,6 +111,13 @@ export class AgentInteractive {
this.toolsList = this.core.prepareTools();
this.core.stats.start(Date.now());
if (this.config.chatHistory?.length) {
this.addMessage(
'info',
`History context from parent session included (${this.config.chatHistory.length} messages)`,
);
}
if (this.config.initialTask) {
this.queue.enqueue(this.config.initialTask);
this.executionPromise = this.runLoop();