Skip to content

Commit d7d8756

Browse files
Copilotkentcdodds
andauthored
Fix Exercise 1.2 structured output comments and create_entry tags bug (#14)
Co-authored-by: kentcdodds <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Kent C. Dodds <[email protected]>
1 parent d776451 commit d7d8756

File tree

2 files changed

+13
-5
lines changed
  • exercises/01.advanced-tools

2 files changed

+13
-5
lines changed

exercises/01.advanced-tools/02.problem.structured/src/tools.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export async function initializeTools(agent: EpicMeMCP) {
4141
}
4242
}
4343

44+
// 🐨 refetch entry to get updated tags
45+
// 💰 agent.db.getEntry(createdEntry.id)
46+
// 💯 add invariant to check if the entry was found
47+
4448
// 🐨 create a structuredContent here that matches the outputSchema
4549
return {
4650
// 🐨 add structuredContent here
@@ -330,7 +334,7 @@ export async function initializeTools(agent: EpicMeMCP) {
330334
openWorldHint: false,
331335
} satisfies ToolAnnotations,
332336
inputSchema: entryTagIdSchema,
333-
// 🐨 add an outputSchema here with a success boolean and a tagEntry that is an entryTagSchema
337+
// 🐨 add an outputSchema here with a success boolean and an entryTag that is an entryTagSchema
334338
},
335339
async ({ entryId, tagId }) => {
336340
const tag = await agent.db.getTag(tagId)
@@ -382,7 +386,7 @@ export async function initializeTools(agent: EpicMeMCP) {
382386
'If set to > 0, use mock mode and this is the mock wait time in milliseconds',
383387
),
384388
},
385-
// 🐨 add an outputSchema here with a video that includes videoUri (you're on your own here!)
389+
// 🐨 add an outputSchema here with a videoUri field (you're on your own here!)
386390
},
387391
async ({ year = new Date().getFullYear(), mockTime }) => {
388392
const entries = await agent.db.getEntries()

exercises/01.advanced-tools/02.solution.structured/src/tools.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ export async function initializeTools(agent: EpicMeMCP) {
4141
}
4242
}
4343

44-
const structuredContent = { entry: createdEntry }
44+
// Refetch entry to get updated tags
45+
const entryWithTags = await agent.db.getEntry(createdEntry.id)
46+
invariant(entryWithTags, `Failed to refetch created entry`)
47+
48+
const structuredContent = { entry: entryWithTags }
4549
return {
4650
structuredContent,
4751
content: [
4852
createText(
49-
`Entry "${createdEntry.title}" created successfully with ID "${createdEntry.id}"`,
53+
`Entry "${entryWithTags.title}" created successfully with ID "${entryWithTags.id}"`,
5054
),
51-
createEntryResourceLink(createdEntry),
55+
createEntryResourceLink(entryWithTags),
5256
createText(structuredContent),
5357
],
5458
}

0 commit comments

Comments
 (0)