The agent-run → prompt-run linkage rule, in one place.
MJ: AI Prompt Runs has NO AgentRunID column (its only agent-facing field is AgentID). A prompt
run is reachable from its agent run only through the step that invoked it — an
MJ: AI Agent Run Steps row whose TargetLogID is the AIPromptRun's ID. Filtering prompt runs on
AgentRunID is a SQL error, not an empty result set.
stepTypes decides WHICH linkage rows count; it is explicit because the correct answer differs
by purpose (see the two constants above). Step types outside the set are skipped because their
TargetLogID points at something else entirely — Sub-Agent at a child agent run, Actions at
an Action Execution Log — so treating those ids as prompt-run ids reads or deletes wrong rows.
The agent-run → prompt-run linkage rule, in one place.
MJ: AI Prompt Runshas NO AgentRunID column (its only agent-facing field is AgentID). A prompt run is reachable from its agent run only through the step that invoked it — anMJ: AI Agent Run Stepsrow whose TargetLogID is the AIPromptRun's ID. Filtering prompt runs on AgentRunID is a SQL error, not an empty result set.stepTypesdecides WHICH linkage rows count; it is explicit because the correct answer differs by purpose (see the two constants above). Step types outside the set are skipped because their TargetLogID points at something else entirely —Sub-Agentat a child agent run,Actionsat an Action Execution Log — so treating those ids as prompt-run ids reads or deletes wrong rows.