Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move command requests to card message matrix events and add support for multiple commands per message #2145

Merged
merged 25 commits into from
Mar 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b40c860
Convert tool calls to CommandRequests on boxel message events, and su…
lukemelia Feb 5, 2025
c7a2bd6
WIP Update host types for changes to how command requests are encoded
lukemelia Feb 13, 2025
e927512
Add aibot test coverage for handling multiple tool calls in one response
lukemelia Feb 17, 2025
899da9b
aibot should not respond to CommandResultEvent until all tool calls h…
lukemelia Feb 17, 2025
69acba1
Merge branch 'return-of-the-skill-commands' into cs-7993-support-mult…
lukemelia Feb 26, 2025
66cc8cc
Merge branch 'main' into cs-7993-support-multiple-tool-calls-per-ai-r…
lukemelia Feb 26, 2025
622d887
Fix aibot tests
lukemelia Feb 26, 2025
5d4dcaf
Fix and improve test of executing command that came from a skill card
lukemelia Feb 26, 2025
b9bcbec
host app support for multiple command requests in one message
lukemelia Feb 27, 2025
bbbf2c4
Before trying to load command code refs, we need to ensure they are u…
lukemelia Feb 27, 2025
9979d51
Merge branch 'main' into cs-7993-support-multiple-tool-calls-per-ai-r…
lukemelia Mar 3, 2025
6a87a81
WIP retry failed command
lukemelia Mar 3, 2025
af729d4
Retrying failed commands and failed command state
lukemelia Mar 4, 2025
264eebc
Move commandRequestId out of data node
lukemelia Mar 4, 2025
141eb81
Rename and move CommandRequestContent interface
lukemelia Mar 4, 2025
3911dc8
Minor tweaks
lukemelia Mar 4, 2025
3ad64b3
Merge branch 'main' into cs-7993-support-multiple-tool-calls-per-ai-r…
lukemelia Mar 4, 2025
44bfe64
Defensive check for attachedCardEventIds for backwards compat.
lukemelia Mar 4, 2025
1ff046c
Fix real-world streaming
lukemelia Mar 5, 2025
bdfcfc2
Restore scroll into view behavior
lukemelia Mar 5, 2025
c5ec57a
Fix assertion message
lukemelia Mar 5, 2025
53a898d
Adopt custom rel_type for command results
lukemelia Mar 6, 2025
0d84b50
Fix how command results are added to prompt when there is no body
lukemelia Mar 6, 2025
8d2d4c6
Add coverage for responder.ensureThinkingMessageSent behavior
lukemelia Mar 6, 2025
8b4e305
Merge branch 'main' into cs-7993-support-multiple-tool-calls-per-ai-r…
lukemelia Mar 6, 2025
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
Prev Previous commit
Next Next commit
Add aibot test coverage for handling multiple tool calls in one response
  • Loading branch information
lukemelia committed Feb 17, 2025
commit e927512e2c6fd52edb316d33c98144ec43188891
108 changes: 108 additions & 0 deletions packages/ai-bot/tests/responding-test.ts
Original file line number Diff line number Diff line change
@@ -425,4 +425,112 @@ module('Responding', (hooks) => {
'The replacement event with the tool call event should replace the original message',
);
});

test.only('Handles multiple tool calls', async () => {
const weatherCheck1Args = {
description: 'Check the weather in NYC',
attributes: {
zipCode: '10011',
},
};
const weatherCheck2Args = {
description: 'Check the weather in Beverly Hills',
attributes: {
zipCode: '90210',
},
};
await responder.initialize();

await responder.onChunk({} as any, snapshotWithContent('some content'));

let snapshot = {
choices: [
{
message: {
tool_calls: [
{
id: 'tool-call-1-id',
type: 'function' as 'function',
function: {
name: 'checkWeather',
arguments: JSON.stringify(weatherCheck1Args),
},
},
{
id: 'tool-call-2-id',
type: 'function' as 'function',
function: {
name: 'checkWeather',
arguments: JSON.stringify(weatherCheck2Args),
},
},
],
},
finish_reason: null,
logprobs: null,
index: 0,
},
],
id: '',
created: 0,
model: 'llm',
};
await responder.onChunk({} as any, snapshot);

await responder.finalize();

let sentEvents = fakeMatrixClient.getSentEvents();
assert.equal(
sentEvents.length,
3,
'Thinking message, and event with content, and event with two tool calls should be sent',
);
assert.equal(
sentEvents[0].content.body,
thinkingMessage,
'Thinking message should be sent first',
);
assert.deepEqual(
sentEvents[2].content[APP_BOXEL_COMMAND_REQUESTS_KEY],
[
{
id: 'tool-call-1-id',
name: 'checkWeather',
arguments: {
description: 'Check the weather in NYC',
attributes: {
zipCode: '10011',
},
},
},
{
id: 'tool-call-2-id',
name: 'checkWeather',
arguments: {
description: 'Check the weather in Beverly Hills',
attributes: {
zipCode: '90210',
},
},
},
],
'Command requests should be sent with correct content',
);
assert.deepEqual(
sentEvents[1].content['m.relates_to'],
{
rel_type: 'm.replace',
event_id: '0',
},
'The replacement event with content should replace the original message',
);
assert.deepEqual(
sentEvents[2].content['m.relates_to'],
{
rel_type: 'm.replace',
event_id: '0',
},
'The replacement event with the tool calls should replace the original message',
);
});
});
Loading
Oops, something went wrong.