Skip to content

Commit a534789

Browse files
authored
fix: structured output add instructions for the agent since some clients consider only structured output if present (#352)
1 parent fb17b1e commit a534789

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/tools/search-apify-docs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ Search results for "${query}":
7878
7979
${results.map((result) => `- Document URL: ${result.url}${result.fragment ? `\n Document fragment: ${result.fragment}` : ''}
8080
Content: ${result.content}`).join('\n\n')}`;
81+
8182
const structuredContent = {
8283
results: results.map((result) => ({
8384
url: result.url,
8485
fragment: result.fragment,
8586
content: result.content,
8687
})),
88+
instructions: `You can use the Apify docs fetch tool to retrieve the full content of a document by its URL. The document fragment refers to the section of the content containing the relevant part for the search result item.`,
8789
};
8890
return buildMCPResponse({ texts: [textContent], structuredContent });
8991
},

src/tools/store_collection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ Returns list of Actor cards with the following info:
172172
actors: structuredActorCards,
173173
query: parsed.keywords,
174174
count: actorCards.length,
175+
instructions: `If you need more detailed information about any of these Actors, including their input schemas and usage instructions, please use the ${HelperTools.ACTOR_GET_DETAILS} tool with the specific Actor name.
176+
If the search did not return relevant results, consider refining your keywords, use broader terms or removing less important words from the keywords.`,
175177
};
176178

177179
return buildMCPResponse({ texts, structuredContent });

src/tools/structured-output-schemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export const actorSearchOutputSchema = {
144144
},
145145
query: { type: 'string', description: 'The search query used' },
146146
count: { type: 'number', description: 'Number of Actors returned' },
147+
instructions: { type: 'string', description: 'Additional instructions for the LLM to follow when processing the search results.' },
147148
},
148149
required: ['actors', 'query', 'count'],
149150
};
@@ -163,6 +164,7 @@ export const searchApifyDocsToolOutputSchema = {
163164
required: ['url', 'content'],
164165
},
165166
},
167+
instructions: { type: 'string', description: 'Additional instructions for the LLM to follow when processing the search results.' },
166168
},
167169
required: ['results'],
168170
};

0 commit comments

Comments
 (0)