feat: Add get-actor-build tool - #1331
Draft
DaveHanns wants to merge 2 commits into
Draft
Conversation
Adds the opt-in deploy category with get-actor-build. The tool returns an Actor build's status and a bounded tail of its build log so an agent can diagnose a failed platform build over MCP. A missing build returns isError with "Build with ID '<id>' not found.", the same shape as get-actor-log. For Console UI token sessions the result also carries a personalized apifyConsoleUrl, built through the shared console_link helpers like the run and storage tools.
Matches get-actor-log, where 0 means the whole log. The previous behavior returned no log at all, the opposite convention.
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.
What
Adds
get-actor-build, a read-only tool in a new opt-indeploycategory. It returns an Actor build's status and the last N lines of its build log, plus a one-line summary and next step.Why
An agent developing an Actor over MCP can start a build (
call-actoralready acceptscallOptions.build) but has no way to see whether the build finished or why it failed; today it has to shell out toapify-clior call the REST API directly. This tool closes that gap in the build and debug part of the loop.Relates to #1217 (Deploy Actor source code using MCP). The deploy contract itself stays blocked on apify-core#29044; build inspection does not depend on it.
How
client.build(buildId).get()for the build document andclient.build(buildId).log().get()for the log, sliced to the trailinglineswith the same tail logic asget-actor-log.HELPER_TOOLS.ACTOR_BUILD_GET,src/tools/deploy/get_actor_build.ts, newdeploycategory insrc/tools/registry.ts(not enabled by default, not auto-injected, mode-agnostic).buildId(string, required) andlines(integer 0..50, default 20; 0 returns the entire log). Zod schema,fixZodSchemaRequiredfor the default.structuredContent={ build: { id, actorId, buildNumber, status, startedAt, finishedAt, apifyConsoleUrl? }, logTail: string[] }(allowlisted viatoBuildResult, internal fields such asuserId,meta,options,inspectorIddo not leak).content[0]mirrors it as JSON,content[1]is summary plus next step. A SUCCEEDED build suggestscall-actorwithcallOptions.buildonly when that tool is loaded (loadedToolNames), otherwise "The build is ready to run."; a failed build points at the log tail; a non-terminal build asks to call again in about 10 seconds.respondUserError("Build with ID '<id>' not found."), the same shape asget-actor-log(fix: Return not-found error from get-actor-log for missing runs #1234).buildConsoleBuildUrlinsrc/utils/console_link.ts;apifyConsoleUrland the verbatim-links nudge appear only for Console UI token sessions, following the apify-core#27286 policy the run and storage tools use.src/tools/AGENTS.mdfile list.Testing
pnpm run type-check,lint,format,test:unit,check:agentspass locally (99 files, 1571 unit tests, 1 pre-existing skip).tests/unit/tools.get_actor_build.test.ts(14 tests): allowlisted fields, log tail slicing and the default of 20 lines,lines: 0returns the entire log, missing log yields[], output-schema conformance, not-found soft fail with the exact message, ajv rejection oflines: 51and an emptybuildId, Console link for UI token sessions, and everynextStepbranch with and withoutcall-actorloaded.console_link.test.tscoversbuildConsoleBuildUrlfor personal, org and non-Console contexts;tools.mode_contract.test.tspins thedeploycategory in both modes.APIFY_TOKEN).Notes for reviewers
structuredContentshape consumed by the hosted server (apify-mcp-server-internal may need a contract test).paymentRequired: truemirrorsget-actor-runandget-actor-log. Confirm this is intended for build inspection.lines: 51is rejected by the AJV input validation intool_call_enginebeforecallruns, so the test checksajvValidaterather than a soft-fail result; re-validating inside the tool body is against the repo rules.logTail: [], the same as a missing log.build_helpers.tsreusestoIsoStringfromactors/actor_run_response.tsand the tool reusesapifyConsoleLinkTextfromstorage/storage_helpers.tsrather than duplicating them; say if you prefer those moved to a shared utils module.AI disclosure: implemented with Claude Code; awaiting human review.
🤖 Generated with Claude Code