Skip to content

refactor: Hoist search-actors guidance strings to builders#1075

Draft
jirispilka wants to merge 1 commit into
masterfrom
claude/apify-mcp-quick-wins-fysrwa-search-guidance
Draft

refactor: Hoist search-actors guidance strings to builders#1075
jirispilka wants to merge 1 commit into
masterfrom
claude/apify-mcp-quick-wins-fysrwa-search-guidance

Conversation

@jirispilka

Copy link
Copy Markdown
Collaborator

Part of #1066 (checkbox: hoist search-actors guidance strings).

What we're solving

Two LLM-guidance strings for the search-actors tool were duplicated, and they get tuned often:

  • The empty-results "broaden your search" text was byte-identical in search_actors.ts and search_actors_widget.ts.
  • The results footer/instructions was written twice inside search_actors.ts (the structured instructions field and the text footer), differing only by "please use" vs "use".

Editing the guidance meant changing several near-identical copies by hand.

How

Add two exported builders to search_actors.ts, next to the existing buildSearchActorsResult that the widget already imports:

  • buildNoActorsFoundInstructions(keywords) — used by both the default tool and the widget empty-results branches.
  • buildSearchActorsFooter(verbatimLinksNudge) — used by both footer copies in search_actors.ts.

All four inline copies now call the builders. The two footer copies collapse to one wording ("use …"), dropping "please" from the structured instructions field.

Alternatives considered

  • A new shared strings file — rejected; search_actors.ts is already the shared source the widget imports from.
  • Keeping the two footer copies separate — rejected; defeats the dedup.

Note

The wording unification only affects LLM-facing guidance prose, not any machine-parsed field. The existing search-actors unit tests assert stable substrings and pass unmodified.

Verification

  • Oracle green: type-check clean, lint 0/0, check:agents passed, test:unit 959 passed / 2 skipped (search-actors default + widget response tests: 10 passed), format no-op.
  • Scope: 2 source files, no test changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_016pXZvhEoE6Lz3DpBSL3n1Y


Generated by Claude Code

What we're solving: two LLM-guidance strings for the search-actors tool
were duplicated and get tuned often. The empty-results "broaden your
search" text was byte-identical in search_actors.ts and the widget, and
the results footer/instructions was written twice inside search_actors.ts,
differing only by "please use" vs "use". Editing the guidance meant
changing several near-identical copies by hand.

How: add two exported builders to search_actors.ts (next to the existing
buildSearchActorsResult that the widget already imports) —
buildNoActorsFoundInstructions(keywords) and
buildSearchActorsFooter(verbatimLinksNudge). All four inline copies now
call them. The two footer copies collapse to one wording ("use ..."),
dropping "please" from the structured instructions field.

Alternatives considered: a new shared strings file (rejected —
search_actors.ts is already the shared source the widget imports from);
keeping the two footer copies separate (rejected — defeats the dedup).

The wording unification only affects LLM-facing guidance prose, not any
machine-parsed field; existing unit tests assert stable substrings and
pass unmodified.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016pXZvhEoE6Lz3DpBSL3n1Y
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.

3 participants