mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-04 16:03:06 +00:00
fix: cut the middle of a capped hub result instead of repeating its tail
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1433,7 +1433,10 @@ describe('createSearchHubScriptsTool', () => {
|
||||
toolCallbacks: { setToolStatus: vi.fn() }
|
||||
} as any)
|
||||
|
||||
expect(JSON.parse(raw).results.map((r: any) => r.integration)).toContain('salesforce')
|
||||
const integrations = JSON.parse(raw).results.map((r: any) => r.integration)
|
||||
expect(integrations).toContain('salesforce')
|
||||
// reserving room for the tail must not re-emit it when nothing was cut
|
||||
expect(new Set(integrations).size).toBe(integrations.length)
|
||||
})
|
||||
|
||||
// Ranking buries an integration the query names when other integrations' scripts
|
||||
|
||||
@@ -1519,14 +1519,13 @@ export const createSearchHubScriptsTool = (withContent: boolean = false) => ({
|
||||
}
|
||||
|
||||
// Each result costs a content fetch, so cap the fan-out when content is wanted.
|
||||
// Keep the tail: hits appended for a named integration sit there, and dropping
|
||||
// them would undo the reason they were fetched.
|
||||
const matches = withContent
|
||||
? [
|
||||
...scripts.slice(0, MAX_FETCHED_HUB_SCRIPTS - mentionedHits),
|
||||
...scripts.slice(scripts.length - mentionedHits)
|
||||
]
|
||||
: scripts
|
||||
// Cut from the middle: hits appended for a named integration sit at the tail,
|
||||
// and dropping those would undo the reason they were fetched.
|
||||
let matches = scripts
|
||||
if (withContent && scripts.length > MAX_FETCHED_HUB_SCRIPTS) {
|
||||
const mentioned = scripts.slice(scripts.length - mentionedHits)
|
||||
matches = [...scripts.slice(0, MAX_FETCHED_HUB_SCRIPTS - mentioned.length), ...mentioned]
|
||||
}
|
||||
toolCallbacks.setToolStatus(toolId, {
|
||||
content: `Found ${matches.length} hub script${matches.length === 1 ? '' : 's'} for ${subject}`
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user