Skip to content

Commit 489d292

Browse files
plcclaude
andcommitted
Fix 2 failing recommendation tests
The recommendation engine was correct — tests had wrong expectations: - "recommendation changes based on agent state" now tests full progression: no name → PATCH /agents → no calendar → POST /calendars → welcome only → POST events → has events → GET upcoming - "agent with name, description, and events gets no recommendations" now creates a persistent event before asserting (earlier tests delete theirs) 133/133 pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7c173e1 commit 489d292

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tests/api.test.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,21 +1484,25 @@ describe('POST /man', { concurrency: 1 }, () => {
14841484
});
14851485

14861486
it('recommendation changes based on agent state', async () => {
1487-
// Create a fresh agent with no calendars
1487+
// Create a fresh agent (no name) — first recommendation is to name it
14881488
const { data: fresh } = await api('POST', '/agents');
1489+
const { data: noNameData } = await api('GET', '/man?guide', { token: fresh.api_key });
1490+
assert.equal(noNameData.recommended_next_step.endpoint, 'PATCH /agents');
1491+
1492+
// Name the agent — next recommendation is to create a calendar
1493+
await api('PATCH', '/agents', { token: fresh.api_key, body: { name: 'Rec Agent' } });
14891494
const { data: noCalData } = await api('GET', '/man?guide', { token: fresh.api_key });
14901495
assert.equal(noCalData.recommended_next_step.endpoint, 'POST /calendars');
14911496

1492-
// Give it a calendar
1497+
// Give it a calendar (welcome event auto-created, event_count=1 means "create an event")
14931498
const { data: cal } = await api('POST', '/calendars', {
14941499
token: fresh.api_key,
14951500
body: { name: 'Rec Test' },
14961501
});
1497-
// Calendar now has a welcome event auto-created, so recommendation skips to upcoming
14981502
const { data: noEvtData } = await api('GET', '/man?guide', { token: fresh.api_key });
1499-
assert.equal(noEvtData.recommended_next_step.endpoint, 'GET /calendars/:id/upcoming');
1503+
assert.equal(noEvtData.recommended_next_step.endpoint, 'POST /calendars/:id/events');
15001504

1501-
// Give it an event
1505+
// Give it a user-created event (event_count>1) — recommendation shifts to upcoming
15021506
await api('POST', `/calendars/${cal.calendar_id}/events`, {
15031507
token: fresh.api_key,
15041508
body: { title: 'Test', start: futureDate(1), end: futureDate(2) },
@@ -1968,9 +1972,15 @@ describe('API Changelog', { concurrency: 1 }, () => {
19681972
});
19691973

19701974
it('agent with name, description, and events gets no recommendations', async () => {
1971-
// state agent has name, description, calendars, and events from prior tests
1975+
// Earlier tests deleted their events, so create one to ensure event_count > 1
1976+
const { data: evt } = await api('POST', `/calendars/${state.calendarId}/events`, {
1977+
token: state.apiKey,
1978+
body: { title: 'Persistent', start: futureDate(10), end: futureDate(11) },
1979+
});
19721980
const { data } = await api('GET', '/changelog', { token: state.apiKey });
19731981
assert.equal(data.recommendations, undefined, 'Fully set up agent should have no recommendations');
1982+
// Clean up
1983+
await api('DELETE', `/calendars/${state.calendarId}/events/${evt.id}`, { token: state.apiKey });
19741984
});
19751985

19761986
it('new agent without name gets recommendations with correct structure', async () => {

0 commit comments

Comments
 (0)