@@ -17,6 +17,15 @@ interface CustomBlockExecutorContext {
1717 callChain ?: string [ ]
1818 isDeployedContext ?: boolean
1919 billingAttribution ?: BillingAttributionSnapshot
20+ /**
21+ * The INVOKING agent run's execution id. Server-set, never model-supplied.
22+ * Without it the child's correlation would name an id no log row ever has, so
23+ * a publisher could not trace the run back to the consumer execution — and the
24+ * cancellation bridge would subscribe to an id nothing ever cancels.
25+ */
26+ executionId ?: string
27+ /** The invoking run's request id, so both sides share one trace identifier. */
28+ requestId ?: string
2029}
2130
2231interface CustomBlockToolParams {
@@ -29,8 +38,9 @@ interface CustomBlockToolParams {
2938
3039/**
3140 * Build a minimal top-level `ExecutionContext` for running a custom block as an
32- * agent tool. Every value comes from the server-set `_context` (LLM-proof) plus a
33- * fresh executionId. `WorkflowBlockHandler`'s custom-block path re-derives owner
41+ * agent tool. Every value comes from the server-set `_context` (LLM-proof),
42+ * including the invoking run's execution and request ids so the child's log
43+ * correlation names a real execution. `WorkflowBlockHandler`'s path re-derives owner
3444 * identity, env, and billing from `getCustomBlockAuthority`, so this only needs the
3545 * fields that path reads — `workspaceId` (org-scopes the authority lookup),
3646 * `metadata` (read unconditionally at `executeCore`), and `callChain` (recursion
@@ -40,7 +50,9 @@ interface CustomBlockToolParams {
4050export function buildCustomBlockExecutionContext (
4151 context : CustomBlockExecutorContext
4252) : ExecutionContext {
43- const executionId = generateId ( )
53+ // Prefer the invoking agent run's ids so correlation and cancellation both
54+ // point at a real execution; fall back only when a caller could not supply them.
55+ const executionId = context . executionId ?? generateId ( )
4456 return {
4557 workflowId : context . workflowId ?? 'custom-block-tool' ,
4658 workspaceId : context . workspaceId ,
@@ -61,7 +73,7 @@ export function buildCustomBlockExecutionContext(
6173 // custom-block path; `duration` is the sole required field on the metadata type.
6274 metadata : {
6375 duration : 0 ,
64- requestId : generateId ( ) ,
76+ requestId : context . requestId ?? generateId ( ) ,
6577 executionId,
6678 workflowId : context . workflowId ,
6779 workspaceId : context . workspaceId ,
0 commit comments