Accept mixed-source valuable results in search feedback - #328
Open
firecrawl-spring[bot] wants to merge 3 commits into
Open
Accept mixed-source valuable results in search feedback#328firecrawl-spring[bot] wants to merge 3 commits into
firecrawl-spring[bot] wants to merge 3 commits into
Conversation
Co-Authored-By: dtaivpp <david@sideguide.dev>
…eedback Stamp each data.web result with a 1-indexed position field so models reference positions directly instead of counting array elements. Rework the feedback prompting: positions must be exhaustive (unlisted = not useful), are web-only, and valuableSources is reserved for URLs outside data.web so the same result is never double-reported. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Search results come back grouped — data.web, data.images, data.news — and
each group is numbered from 1 independently, so valuableResultPositions
could only ever mean "web" and had no way to cite a news or image result.
- Stamp every result with `source` and `position`, not just data.web, so
the model copies both straight into feedback instead of counting.
- Replace valuableResultPositions with valuableResults, an array of
{source, position, reason?}, matching the API (firecrawl/firecrawl#4109).
- Update the tool instructions, Returns descriptions, and README example.
Also fixes the two smoke tests that the position stamping in b59f184 broke:
they asserted the search envelope passed through untouched.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/index.ts">
<violation number="1" location="src/index.ts:671">
P1: When an API result already contains `source` or `position`, `...result` overwrites the identifiers this helper adds; news publisher fields can make copied feedback identifiers invalid. Spread the result first, then assign `source` and `position`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| if (!Array.isArray(results)) continue; | ||
| data[source] = results.map((result, i) => | ||
| result && typeof result === 'object' | ||
| ? { source, position: i + 1, ...result } |
There was a problem hiding this comment.
P1: When an API result already contains source or position, ...result overwrites the identifiers this helper adds; news publisher fields can make copied feedback identifiers invalid. Spread the result first, then assign source and position.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/index.ts, line 671:
<comment>When an API result already contains `source` or `position`, `...result` overwrites the identifiers this helper adds; news publisher fields can make copied feedback identifiers invalid. Spread the result first, then assign `source` and `position`.</comment>
<file context>
@@ -650,6 +650,31 @@ function asText(data: unknown): string {
+ if (!Array.isArray(results)) continue;
+ data[source] = results.map((result, i) =>
+ result && typeof result === 'object'
+ ? { source, position: i + 1, ...result }
+ : result
+ );
</file context>
Suggested change
| ? { source, position: i + 1, ...result } | |
| ? { ...result, source, position: i + 1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sourceand a 1-indexedposition— all ofdata.web,data.images,data.news, not just web — so the model copies both straight into feedback instead of counting array elements.valuableResultPositionswithvaluableResults, an array of{source, position, reason?}, forwarding to/v2/search/{searchId}/feedback(Collect search feedback on results across all sources firecrawl#4109).Returns:descriptions, and the README example.Why the source is required
Results are returned grouped and each group is numbered from 1 independently, so
valuableResultPositions: [1]could only ever mean "the first web result" — news and image results had no way to be cited. Theirurlfields are optional, sovaluableSourcescouldn't reliably address them either.{"source":"web","position":1}and{"source":"news","position":1}are now distinct.Also
Fixes the two smoke tests that the position stamping in b59f184 broke — they asserted the search envelope passed through untouched, and were failing on this branch before this commit.
Tests
npm run buildnpx tsc --noEmit— cleannpm test— 19/19 passing (was 17/19 on the previous commit)🤖 Generated with Claude Code