Outbound Interceptor Confusion

My application invokes different temporal workflows, where each activity needs value for sandbox-id. I can implement WorkflowClientCallsInterceptor and on start method add sandbox-id to WorkflowStartInput header field. I see this value coming on a worker side when implementing WorkflowClientCallsInterceptor execute method, correct content is set on WorkflowInboundCallsInterceptor.WorkflowInput.header. I see there is WorkflowOutboundCallsInterceptor.ActivityInput which has header and I set some hardcoded values, they show up in ActivityInboundCallsInterceptor.ActivityInput.header but what I don’t get is what is the intended way of propagating WorkflowInput.header to ActivityInput.header.

WorkflowInboundCallsInterceptor.init method instantiates an instance of WorkflowOutboundCallsInterceptor. I would assign that instance to a field of the WorkflowInboundCallsInterceptor and then pass the header value to it from the execute call. Something like:

public class MyWorkflowInboundCallsInterceptor extends WorkflowInboundCallsInterceptorBase {
     private MyWorkflowOutboundCallsInterceptor outbound;

     
  public void init(WorkflowOutboundCallsInterceptor outboundCalls) {
    this.outbound = new MyWorkflowOutboundCallsInterceptor())
    new MyWorkflowOutboundCallsInterceptor())
       super.init(outbound);
    }
  }

  public WorkflowOutput execute(WorkflowInput input) {
      this.outbound.setSendboxId(getSandboxId(input));
    return super.execute(input);
  }
....
}

Hi Maxim, this is great, thank you very much!