mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 20:50:34 +00:00
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:
parent
9f7e3e054f
commit
addbdcb0ef
2 changed files with 38 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue