Remove error thrown on no action taken
Merged
MI
7mo ago+65+65+01234567890123456789-50-50-01234567890123456789
why
After adding regex schema validation for element ids in act, the models were left with no choice to say 'no candidate found/no action to be taken' since an empty string on element id would fail validation. This PR corrects the regressed behavior
what changed
act() no longer throws when the model can't find a target. Callers get the structured success: false result, matching the behavior observe() already has ([]) when nothing matches.
packages/core/lib/inference.ts— wrap the act fields (elementId, description, method, arguments, twoStep) under action: {...}.nullable(). When the model returns action: null, inference returns element: undefined and the existing handler branch returns { success: false, actions: [], message: "Failed to perform act: No action found" }.- Lift
twoStepout of the nullable action object and back to the top level of the act schema — small models (gpt-4.1-nano) flatten booleans out of anyOf variants during structured output, causing spurious AI_NoObjectGeneratedError on otherwise-valid responses. packages/core/lib/prompt.ts— update buildActSystemPrompt, buildActPrompt, and buildStepTwoPrompt to instruct the model to set action: null when no element matches, with an explicit ban on empty strings / placeholder values.packages/core/lib/v3/handlers/actHandler.ts— no logic change; the existing no-action branch is now reachable.
Act will return the following on these cases:
test plan
Summary by cubic
Stops act from throwing when no element matches by making the response action nullable and updating prompts/parsing to treat “no action” as valid. Fixes the regression where empty element IDs failed validation. Aligns with Linear STG-1849.
- Bug Fixes
- Changed
actschema to{ action: { elementId, description, method, arguments } | null, twoStep: boolean }with the element ID regex;twoStepis top‑level and defaults tofalse. - Updated prompts to set
action: nullwhen no element matches and to not fabricate elements or use empty/placeholder values. - Adjusted parsing to handle
action === nulland returnelement: undefined, letting the existing no‑action path returnsuccess: false. - Updated integration tests and test utils to use the new
actionshape and top‑leveltwoStep.
- Changed