Repository navigation
feat: Let search-actors take a use case, except for Claude clients - #1715
Merged
Merged
Conversation
MQ37
force-pushed
the
feat/search-use-case-field
branch
from
October 26, 2026 23:07
e68bf97 to
010486f
Compare
…pic clients Optional useCase argument on search-actors and its widget twin, with a privacy warning in the description. Offered only to clients that declare a name outside the Claude/Anthropic blocklist, with telemetry on. The server takes it off the arguments before anything logs or validates them, drops it from any client that was not offered it, redacts API tokens, and sends it as the Store search _useCase. Removes the Apify-AI-only _meta path, logs only the method of a dev server request, masks an echoed use case in Store errors and drops the query from Sentry HTTP breadcrumbs.
MQ37
force-pushed
the
feat/search-use-case-field
branch
from
October 26, 2026 23:10
010486f to
5727602
Compare
MQ37
marked this pull request as ready for review
October 26, 2026 23:41
…e-field Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Follow-ups in #1720 (draft, targets this branch, four separate commits so any subset can be taken). |
jirispilka
approved these changes
Oct 27, 2026
jirispilka
left a comment
Collaborator
There was a problem hiding this comment.
It is ok.
First I addressed some minor comments in #1720
Then I looked closely and it seems there is a simpler design that was implemented by Claude, please take a look.
MQ37
pushed a commit
that referenced
this pull request
Oct 27, 2026
…#1720) ## Why Follow-ups to the review on #1715. Draft on purpose: it is your PR, so take the commits you want. Each stands alone and is green on its own. ## What changed 1. **`fix: Match every Claude Desktop local-agent-mode client name`** — the blocklist had the literal `local-agent-mode-apify`, but Claude Desktop names itself `local-agent-mode-<server name>`, so `local-agent-mode-espn-sports`, `local-agent-mode-Apify MCP server`, … (all in Mixpanel) counted as non-Anthropic and got `report-problem`. Now a prefix, like the other two entries. 2. **`fix: Remove the Store error masking`** — tested on the live API: it echoes `_useCase` only over 1024 characters, which `sanitizeUseCase` never sends, and the mask matched the full string, so it missed the truncated echo anyway. Details in the commit message. 3. **`docs: Say where the search use case goes`** — the README sentence now names the destination (Store search analytics; the Mixpanel `Store search` event carries `use_case`). 4. **`refactor: Put useCase in the search schema and withhold it per client`** — the opinionated one, below. ### About commit 4 I did not like the engine block that recognises the search tools by name, strips `useCase` from the arguments and parks it on `storeSearchTracking`: the engine should not know search tools exist. My first attempt kept your design and gave the variant its own validator, so nothing needs stripping. That works and is a fine small change on its own (about ten lines; the engine block goes, the rest stays). Then I tried the inverse: `useCase` as an ordinary field of the base schema, and for clients that are not offered it, serve a copy without the field. It turned out smaller with fewer concepts, so that is what the commit does. Honest comparison: | | #1715 | commit 4 | |---|---|---| | Where the field is defined | a second schema built from the base, plus a description patch (`addUseCaseToSearchTool`) | one optional field in `searchActorsBaseArgsSchema`; the widget inherits it | | Per-client difference | swap in a variant tool for allowed clients; map in `server.ts` | strip the field for withheld clients; `withoutUseCaseField` in `tools_loader` (12 lines, built once per tool, own validator) | | How the value reaches the API | engine strips the argument, side channel on `storeSearchTracking` | the tool passes `parsed.useCase` to `searchAgentSafeActors`, which sanitizes it | | Claude sends it anyway | engine drops it | the served copy's validator drops it | | `?client=` | gates | name only, like `report-problem` (ai-team#214 decision 4) | | Tool-level privacy note | yes | field description only | | Engine | knows the search tools | untouched | What goes: the tool-level note (you tested models with it present) and the `?client=` belt-and-braces. What stays: every guarantee in your gating tests, which still pass unchanged in meaning, plus "Claude sends it anyway", now on the validator. If you would rather keep your structure, say so and I turn commit 4 into the smaller version (own validator on the variant, engine block removed). ## Notes for reviewers (human-written) ## Proof it works - Unit suite green at every commit (3321 at HEAD); `tsc`, `oxlint`, `oxfmt`, `check:agents` clean. - Live `GET /v2/store` probe for commit 2: an over-limit `_useCase` is echoed in the 400; 1024 UTF-16 units of ASCII, `č`, `中` and `😀` are accepted; the removed mask left the echoed text in the message. - Integration cases (named client gets `useCase`, `claude-ai` does not) not run here (need `APIFY_TOKEN`). Internal's contract suite likely needs a matching case. - End to end with mcpc 0.6.0 against `36d8a942` (stdio, real token, `TELEMETRY_ENV=PROD`), every use case tagged `e2e1720-1206`: - Schema: `useCase` present for mcpc's own (non-Anthropic) name with telemetry on, in default and apps mode (`search-actors-widget` too); absent with telemetry off, where `report-problem` is absent as well. - Calls, all `isError: false`: plain use case; 1200-character use case (the API 400s above 1024, so success proves the cap); use case containing `apify_api_…`; empty and whitespace-only use case; empty keywords; unknown extra argument; the widget tool; a use case sent to the telemetry-off session. - Store search analytics (Mixpanel `Store search`, `meta_origin: MCP`): rows for the plain, capped, widget and apps-mode use cases, and the token one arrived as `… apify_api_***`. No row for the telemetry-off session's value, and none for the empty-keywords call (the API does not track searches without a term). The rows' `trace_id` equals the sessions' `MCP Tool Call` `trace_id`, so the join works. - Our telemetry (`MCP Tool Call`, client `mcpc`): 17 `search-actors` + 1 `search-actors-widget` events today, every one with a `trace_id`; the event has no property that could carry a use case. The telemetry-off session produced no event. - Not testable with mcpc: the per-client split (`claude-ai` withheld, `Cursor` served); mcpc cannot set `clientInfo.name`. Covered by unit tests and by the two integration cases in `registration.cases.ts`. - Observed, pre-existing: AJV runs with `coerceTypes`, so `useCase: 123` is sent as `"123"` and `null` becomes an empty string (dropped), instead of a validation error. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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.
Why
Part of apify/ai-team#272, follows #1650 (merged). The Store search takes
_useCase(why the user is searching). #1650 sends it only for Apify AI through_meta. This makes it an optionalsearch-actorsargument that any client's model can fill, so no per-client code is needed. Anthropic clients are not offered it, pending the directory review.What changed
search-actorsand its widget take an optionaluseCase, for clients that declare a name outsideANTHROPIC_CLIENT_NAMES(also not on?client=claude), with telemetry on. Field and tool description say: never send personal information or secrets, respect the user's privacy.prepareToolCallstripsuseCasefrom these tools' arguments for every client before logging, validation and the call; only a client that was offered the field gets it sent as_useCase(tokens redacted, 1024 characters)._meta['com.apify/useCase']path from feat: Send trace id and use case with Apify Store searches #1650.REPORT_PROBLEM_BLOCKED_CLIENTSis renamedANTHROPIC_CLIENT_NAMES: it now gates two things.Deliberate: Apify API access logs record the use case (it is in the URL).
Notes for reviewers (human-written)
TODO(author): where to look hardest, what you are unsure of, which AI-written parts you do not fully follow.
_metause case and clashes with this field; close it or reduce it to the thread id before release.apify_api_tokens are filtered. A user who explicitly asks the model to put their name and email in the field gets it through (haiku 2 of 3 runs, sonnet 0 of 3).Proof it works
tsc,oxlint,oxfmtclean. 13 mutations of the gates, redactions and masking each fail a unit test.?client=claude, telemetry off, widget mode: field listed or not,_useCasesent or not, no use case in captured logs or telemetry._useCase; other client, ordinary tasks with a name, email, phone or token in the prompt: the model filled the field in 22 of 24 runs and no personal data reached the API (haiku 36 runs, sonnet 12).