docs(skills): add common Actor patterns to apify-actor-development SKILL.md#61
Draft
DaveHanns wants to merge 1 commit into
Draft
docs(skills): add common Actor patterns to apify-actor-development SKILL.md#61DaveHanns wants to merge 1 commit into
DaveHanns wants to merge 1 commit into
Conversation
…ILL.md
Add a "Common patterns" section covering six gaps that repeatedly trip up
agents (both human and LLM) authoring Actors:
- Network robustness — wrap fetch() in try/catch with retry + exponential
backoff, so a transient upstream 503 does not surface as an Actor-level
RUNTIME_ERROR. Full reference at references/robust-fetch.ts.
- API keys and secrets — mark input fields carrying tokens/keys with
isSecret: true so they are encrypted at rest and censored in the UI.
- Persisting state across scheduled / cron runs — two documented patterns
(named KV store for full-scope tokens; previous-run-lookup via REST for
LIMITED_PERMISSIONS scheduled runs where Actor.openKeyValueStore('name')
fails with "Permission denied"). Full reference at
references/cross-run-state.ts.
- Key-value store key charset — explicit regex and one-line sanitizer for
the ArgumentError thrown when a natural key contains colons, slashes,
spaces, or unicode.
- Progress reporting — Actor.setStatusMessage snippet with the
isStatusTerminal option for terminal failure states.
- Prefer MCP tools over raw REST — enumerate the common mcp__apify__*
tools so agents reach for them before hand-rolling curl calls against
api.apify.com.
Each SKILL.md entry is a copy-pasteable snippet; the two larger reference
implementations live under references/ following the existing layout.
Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
DaveHanns
marked this pull request as draft
July 5, 2026 11:21
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
The
apify-actor-developmentskill currently omits several patterns that come up in almost every non-trivial Actor. Agents (both human and LLM) authoring Actors from this skill repeatedly rediscover them the hard way — with a stack trace or a data leak.This PR adds a Common patterns section to
skills/apify-actor-development/SKILL.mdcovering six such gaps, each with a copy-pasteable snippet. Two larger reference implementations go underreferences/, following the existing layout.The six gaps
1. Network robustness — wrap
fetchin try/catch + retryUnwrapped
fetch()turns a transient upstream 503 into an Actor-levelRUNTIME_ERROR. The skill mentions "Implement retry strategies with exponential backoff" in the best-practices bullet list but never shows what that looks like for a plainfetchcall outside a Crawlee crawler. New snippet + full reference atreferences/robust-fetch.ts.2. API keys and secrets —
isSecret: truereferences/input-schema.mddoes not mentionisSecret. Without it, anapiKeyfield is stored in plaintext in the run object and shown in the Console UI. New snippet demonstrates the input-schema declaration + reading it viaActor.getInput().3. Persisting state across scheduled / cron runs
Each run gets its own default key-value store, so
Actor.setValue(key, val)does not survive to the next run. Two documented patterns:Actor.openKeyValueStore('my-actor-state')) — requires a full-scope token.LIMITED_PERMISSIONSscheduled runs where opening a named store fails withPermission denied. Lists the Actor's previous SUCCEEDED runs and reads the newest one's default KV store.Also documents
.actor/actor.json'senvironmentVariablesobject form (I've seen the array form attempted and silently ignored) and the@secretNamereference syntax withapify secrets add. Full reference atreferences/cross-run-state.ts.4. Key-value store key charset
KV keys must match
/^[a-zA-Z0-9!\-_.'()]{1,256}$/. A natural key likeuser:${userId}:${timestamp}throws:from
setValue(). New snippet gives the regex explicitly + a one-line sanitizer.5. Progress reporting —
Actor.setStatusMessageLong-running Actors should surface progress so the Console UI shows what phase they're in. New snippet demonstrates both the normal call and the
isStatusTerminal: trueoption for terminal failure states.6. Prefer MCP tools over raw REST
The existing "MCP tools" section only lists
search-apify-docsandfetch-apify-docs. In practice agents fall back to hand-rolledcurlcalls againstapi.apify.combecause they don't know an MCP tool covers what they need. New enumeration of the commonmcp__apify__*tools (search-actors,get-actor,call-actor,get-actor-run,get-actor-run-log,get-dataset-items,get-key-value-store-record) with one-line descriptions.Files changed
skills/apify-actor-development/SKILL.md— new "Common patterns" section between "Best practices" and "Logging"; six subsections as above.skills/apify-actor-development/references/robust-fetch.ts— new file, full retry helper with timeouts and configurable retry statuses.skills/apify-actor-development/references/cross-run-state.ts— new file, helpers for both cross-run KV patterns plus asanitizeKvKeyutility.Test plan
SKILL.mdrenders on GitHub — each of the six subsections has a working code snippet.mcp__apify__*tool names with one-line descriptions.references/robust-fetch.tscompiles under the skill's TypeScript target (no top-level imports beyondapify).references/cross-run-state.tscompiles under the skill's TypeScript target; both the named-store and previous-run patterns are exercised.Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.