File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -491,7 +491,7 @@ public function lastMessage(): ?MessageInterface;
491
491
/**
492
492
* Get all chat keys associated with this agent class
493
493
*/
494
- public function getChatKeys(): array
494
+ public function getChatKeys(): array;
495
495
```
496
496
497
497
### Tools
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ public function handle()
31
31
if (!empty ($ chatKeys )) {
32
32
// Clear each chat history
33
33
foreach ($ chatKeys as $ key ) {
34
- $ agent = $ agentClass ::for ($ key );
34
+ // Create new chat history with save_chat_keys disabled
35
+ $ agent ->createChatHistory ($ key );
36
+ // Clear messages
35
37
$ agent ->clear ();
36
38
}
37
39
}
Original file line number Diff line number Diff line change @@ -72,13 +72,17 @@ protected function onInitialize()
72
72
$ agent ->message ('Hello ' )->respond ();
73
73
74
74
// Verify chat history exists
75
- expect ($ agent ->getChatKeys ())->not ->toBeEmpty ();
75
+ $ chatKeys = $ agent ->getChatKeys ();
76
+ expect ($ chatKeys )->toHaveCount (1 );
77
+ expect ($ chatKeys )->toContain ('TestAgent_gpt-4-mini_test_key ' );
76
78
77
79
// Clear the history
78
80
$ this ->artisan ('agent:chat:clear ' , ['agent ' => 'TestAgent ' ])
79
81
->assertSuccessful ()
80
82
->expectsOutput ('Successfully cleared chat history for agent: TestAgent ' );
81
83
82
- // Verify chat history is cleared
83
- expect (\App \AiAgents \TestAgent::for ('test_key ' )->chatHistory ()->getMessages ())->toBeEmpty ();
84
+ // Verify all chat histories are cleared but keys remain
85
+ $ agent = \App \AiAgents \TestAgent::for ('test_key ' );
86
+ expect ($ agent ->chatHistory ()->getMessages ())->toBeEmpty ();
87
+ expect ($ agent ->getChatKeys ())->toHaveCount (1 );
84
88
});
You can’t perform that action at this time.
0 commit comments