fix(worker): provision pieces used as agent tools; keep piece-not-found as engine error - #13798
Conversation
Confidence Score: 4/5Safe to merge — both code changes are correct and well-scoped; the only open item is a missing update to the workers feature doc. The provisioning and error-classification changes are straightforward and well-tested. The workers.md feature doc is not updated to reflect that agent tool pieces are now included in the sandbox provisioning pass. .agents/features/workers.md — the Resolver description needs a one-line update to mention agent tool piece resolution. Important Files Changed
Reviews (2): Last reviewed commit: "fix(worker): provision pieces referenced..." | Re-trigger Greptile |
Reverts the change from #13773 (9017def). A piece that passes provisioning but cannot be loaded from disk is an install-integrity fault, not a user/config condition, so it must surface as INTERNAL_ERROR and page rather than be masked as a quiet FAILED step. Restores EngineGenericError('PieceNotFoundError', ...) at both piece-loader throw sites and removes the USER-level PieceNotFoundError export. shared bumped 0.96.0 -> 0.96.1 (revert of an export added one version ago). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A run_agent step references pieces through settings.input.agentTools (the AGENT_TOOLS prop on @activepieces/piece-agent), not through the step's own pieceName. extractPiecePackages only walked PIECE/TRIGGER step settings, so a piece used *solely* as an agent tool was never provisioned and the engine failed to load it at run time. Extend extractPiecePackages to also collect PIECE-type agent tools (AgentPieceTool) from each step's input.agentTools, deduped against the step pieces. FLOW / MCP / KNOWLEDGE_BASE tools are skipped since they have no piece package to install. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
867b659 to
174f358
Compare
abuaboud
left a comment
There was a problem hiding this comment.
Rebased onto main and re-targeted the agent-tool piece extraction into the refactored provisioning path (flow-provisioning.ts resolvePieces), since the old worker flow-helpers path was removed by the sandbox-pool refactor. Kept the #13773 revert per intent. Typechecks clean (sandbox + core/execution).
What
Two related fixes around piece provisioning and how a missing piece surfaces.
1. Provision pieces referenced as agent tools
A
run_agentstep (@activepieces/piece-agent) references the pieces it can call through itssettings.input.agentToolsarray (theAGENT_TOOLSprop), not through the step's ownpieceName. The worker'sextractPiecePackagesonly walkedPIECE/TRIGGERstep settings, so a piece used solely as an agent tool was never installed into the sandbox — and the engine then failed to load it at run time.extractPiecePackagesnow also collectsPIECE-type agent tools (AgentPieceTool) from each step'sinput.agentTools, deduped against the normal step pieces.FLOW/MCP/KNOWLEDGE_BASEtools are skipped — they have no piece package to install.2. Revert #13773 — keep piece-not-found as an ENGINE error
#13773 reclassified the engine's
PieceNotFoundErroras a USER-level error so a missing piece failed the step quietly instead of paging. But a piece that passes provisioning yet cannot be loaded from disk is an install-integrity fault, not a user/config condition — masking it hides the real problem. This restoresEngineGenericError('PieceNotFoundError', …)at bothpiece-loaderthrow sites (→INTERNAL_ERROR→ failed job + page) and removes the USER-level export.Why
Both came out of investigating failed
EXECUTE_FLOWjobs surfacingPieceNotFoundError(e.g.perplexity-ai@0.2.8as an agent tool, andstore@0.6.15). Fix #1 is the concrete provisioning gap; the revert restores the loud signal so any remaining provisioning/skew faults stay visible rather than silent.Testing
packages/server/workerunit tests — 11/11 green (new agent-tool extraction cases included)npx turbo run lintonworker,@activepieces/shared,@activepieces/engine— 0 errors@activepieces/sharedbumped0.96.0 → 0.96.1(PieceNotFoundError export removed).🤖 Generated with Claude Code