Skip to content

Accept mixed-source valuable results in search feedback - #328

Open
firecrawl-spring[bot] wants to merge 3 commits into
mainfrom
david/okay-we-need-to-update-an-api
Open

Accept mixed-source valuable results in search feedback#328
firecrawl-spring[bot] wants to merge 3 commits into
mainfrom
david/okay-we-need-to-update-an-api

Conversation

@firecrawl-spring

@firecrawl-spring firecrawl-spring Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Stamp every search result with source and a 1-indexed position — all of data.web, data.images, data.news, not just web — so the model copies both straight into feedback instead of counting array elements.
  • Replace valuableResultPositions with valuableResults, an array of {source, position, reason?}, forwarding to /v2/search/{searchId}/feedback (Collect search feedback on results across all sources firecrawl#4109).
  • Update the tool instructions, both 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. Their url fields are optional, so valuableSources couldn'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 build
  • npx tsc --noEmit — clean
  • npm test — 19/19 passing (was 17/19 on the previous commit)

🤖 Generated with Claude Code

Co-Authored-By: dtaivpp <david@sideguide.dev>
@firecrawl-spring
firecrawl-spring Bot requested a review from dtaivpp July 23, 2026 13:24
dtaivpp and others added 2 commits July 23, 2026 16:18
…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>
@dtaivpp dtaivpp changed the title Accept valuable result positions in search feedback Accept mixed-source valuable results in search feedback Aug 12, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/index.ts
if (!Array.isArray(results)) continue;
data[source] = results.map((result, i) =>
result && typeof result === 'object'
? { source, position: i + 1, ...result }

@cubic-dev-ai cubic-dev-ai Bot Aug 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }
Fix with cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant